I have the following VTK file, which is generate by OpenFOAM:
# vtk DataFile Version 2.0
sampleSurface
ASCII
DATASET POLYDATA
POINTS 4 float
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
1.0 1.0 0.0
POLYGONS 2 8
3 0 1 2
3 2 1 3
POINT_DATA 4
FIELD attributes 1
U 3 4 float
1.0 2.0 3.0
1.0 2.0 3.0
1.0 2.0 3.0
1.0 2.0 3.0
It is a flat cutting plane of a 3D domain. There is 4 points, which create two triangles. On each points, the vector U is defined. I can get the number of points and the points with the following code:
import vtk
reader = vtk.vtkPolyDataReader()
reader.SetFileName('myVTKfile.vtk')
reader.ReadAllScalarsOn()
reader.ReadAllVectorsOn()
reader.ReadAllTensorsOn()
reader.Update()
vtkdata = reader.GetOutput()
print vtkdata.GetNumberOfPoints()
print vtkdata.GetPoint(0)
Unfortunately, I haven't found a possibility to get the list of triangles (the polygons) and the list of data (the vectors U). Can somebody help me on this matter?
Marcel