[vtkusers] Loading Point Data using Python

David E DeMarle dave.demarle at kitware.com
Fri Apr 20 08:33:10 EDT 2012


On Fri, Apr 20, 2012 at 7:05 AM, Dan Barker <dbpvusrlist at hotmail.co.uk> wrote:
> Dear All,
>
> I have some data files which are written by our simulation they are .vtp
> format with point data. Each point has several properties such as "Density"
> or "Pressure" associated with it. I wish to load these files using a python
> script which I can then use to look at their properties and extract the
> results I'm interested in. I have successfully loaded the files and I can
> read the points positions' but I have no idea how to access the accompanying
> properties, could anybody suggest how to do this?
>
> Currently to load the file I am doing the following;
>
> reader = vtk.vtkXMLPolyDataReader()
> reader.SetFileName(file)
> reader.Update()
> data = reader.GetOutput()
> data.Update()
>
> print(str(type(data)))  #outputs <type 'vtkobject'>
>
>  for i in range(data.GetNumberOfPoints()):
>   p = data.GetPoints().GetPoint(i) #p is a tuple with the x,y & z

     valueFoo = data.GetPointData().GetArray("Foo").GetTuple(i)
     valueBar = data.GetPointData().GetArray("Bar").GetTuple(i)

> coordinates.
>
>
> Thanks,
>
> Dan
>
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list