I don't think anyone has been systematic about documenting it. So the scattered collection of what is on the VTK examples project, the ParaView wiki, and of course pydoc and the source itself, are your best bets.
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 4:00 PM, Gang Song <[email protected]> wrote: > Hi David, > > fromvtkarray works like a charm. Terrific! Thank you. > > Is there any extra online documentation / examples for these paraview > python libraries? I could only find limited examples on Paraview wiki > pages. I hope I can learn from more examples. > > > Thanks > > Gang > > On Thu, Oct 25, 2012 at 3:40 PM, David E DeMarle > <[email protected]> wrote: >> Try this modern version of that: >> >> from paraview.numeric import fromvtkarray >> array = fromvtkarray( >> self.GetInput().GetPoints().GetData() >> ) >> print array >> >> 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:56 PM, Gang Song <[email protected]> wrote: >>> Thanks for explanation. I will write the numpy expression for this. >>> One related question is how to convert the vtkPoints to a numpy array. >>> From wiki, I saw it asks to use vtkDataArrayToVTKArray, but I coulnd't >>> find an example for this. The following code doesn't work: >>> >>> points = vtk.vtkPoints(); >>> # .... >>> points_array = vtkDataArrayToVTKArray(points.GetData()) >>> >>> Seems I am missing some arguments here. >>> >>> >>> Thanks >>> >>> Gang >>> >>> >>> On Thu, Oct 25, 2012 at 2:50 PM, David E DeMarle >>> <[email protected]> wrote: >>>> 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
