[vtkusers] Reading a .vtp
David Doria
daviddoria+vtk at gmail.com
Wed May 19 10:49:53 EDT 2010
On Wed, May 19, 2010 at 10:33 AM, <mariagrazia.madaschi at unibg.it> wrote:
> Hi,
> I really know very little about vtk. Maybe my answer could be a bit stupid
> to many of you.
> I've got a problem to resolve. I create a file .vtp with many cells of
> kidney. This cells are obviously composed of many points. I need to
> calculate the centroid of every cells and to do this I need all points
> coordinates of every cells.
> I know that .vtp contain the information I need, but I really don't know
> how to get it.
> (I usually use Python as language)
>
> Can someone help me?
>
> Thanks.
Hi,
You will find an increasing number of python examples here:
http://www.vtk.org/Wiki/VTK/Examples#Example_Usage_.28Python.29
Here is the closest one we have so far:
http://www.vtk.org/Wiki/VTK/Examples/Python/STLReader
I imagine that this work work, though I've never tried it:
import vtk
filename = "myfile.vtp"
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName(filename)
polyDataOutput = reader.GetOutput()
Please add examples as you figure out how to do things like this!
Thanks,
David
More information about the vtkusers
mailing list