[Paraview] How to generate/access Points array from vtkImageData Inbox
Gang Song
songgang97 at gmail.com
Thu Oct 25 14:37:14 EDT 2012
Hi,
I am writing a Python programmable filter in Paraview. The input
source is a type of vtkImageData. I want to get the coordinates of all
the points and use them to generate an output of type
vtkStructuredGrid. Currently I am using a for loop:
pdi = self.GetInput()
pdo = self.GetOutput()
numPts = pdi.GetNumberOfPoints()
points = vtk.vtkPoints()
points.Allocate(numPts, numPts)
for i in xrange(numPts):
point = pdi.GetPoint(i)
# ...
# other manipulations on point
# ...
points.InsertNextPoint(point)
# ...
pdo.SetDimensions(pdi.GetDimensions())
pdo.SetPoints(points)
My problem is that for loop became very slow for large image volumes.
So I am replacing it with numpy. But I couldn't find a way to get
points array directly from vtkImageData, something like:
points = pdi.Points
points = points * 0.5
newPoints.SetData(numpyTovtkDataArray(points))
It seems that there is no internal points array stored in
vtkImageData. Is there a easy way to do this?
Thanks
Gang
More information about the ParaView
mailing list