You should come up with numpy expression that derives each point's location.
vtkImageData's point locations are implicitly determined by the image data's origin, extent, and spacing. David E DeMarle Kitware, Inc. R&D Engineer 21 Corporate Drive Clifton Park, NY 12065-8662 Phone: 518-881-4909 On Thu, Oct 25, 2012 at 2:37 PM, Gang Song <[email protected]> wrote: > 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 _______________________________________________ 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
