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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview

Reply via email to