Reputation: 11
I'm just new to python and I can't seem to find a solution to my problem, since it seems to be pretty simple. I have a geometry on paraview, I'm saving it as a vtk file and I'm trying to use python to calculate it's volume.
This is the code I'm using:
import vtk
reader = vtk.vtkPolyDataReader()
reader.SetFileName("C:\Users\Pauuu\Google Drive\2016-01\SURF\Sim Vascular\Modelos\apoE183 Day 14 3D\AAA.vtk")
reader.Update()
polydata = reader.GetOutput()
Mass = vtk.vtkMassProperties()
Mass.SetInputConnection(polydata.GetOutput())
Mass.Update()
print "Volume = ", Mass.GetVolume()
print "Surface = ", Mass.GetSurfaceArea()
I think there might be a problem with the way im loding the data, and i get the AttributeError: GetOutput
.
Do you know what might be happening or what I'm doing wrong? Thank you in advance.
Upvotes: 1
Views: 4033
Reputation: 789
Depending on your version of vtk
package you may want to test the following syntax if your version <= 5
:
Mass.SetInput(polydata.GetOutput());
Otherwise, the actual syntax is:
Mass.SetInputData(polydata.GetOutputPort());
PS: you can check the python-wrapped vtk
version by running:
import vtk
print vtk.vtkVersion.GetVTKSourceVersion()
Upvotes: 2
Reputation: 2956
I guess you have VTK 6 , you can provide as input to a filter either the output port of a filter or a vtkDataObject :
Mass.SetInputConnection(reader.GetOutputPort())
Mass.SetInputData(polydata) #that is Mass.SetInputData(reader.GetOutput())
For understanding why these method are not equivalent when updating a pipeline, and for comparison with the previous version, see http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_GetProducerPort http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput
Upvotes: 0
Reputation: 96
You have assigned reader.GetOutput()
in polydata
. From polydata
, I believe you need to do, polydata.GetOutputPort()
Upvotes: 1