In the following vtk data file. I don't know how to access the field data. I am familiar with the functions to read the Polydata but not sure how to read the field data below it. Can somebody help me with it ?
# vtk DataFile Version 2.0
sampleSurface
ASCII
DATASET POLYDATA
POINTS 3721 float
0 0 0 0 0.0139286 0 0 0.0278571 0 0 0.0417857
0 0 0.0557143 0 0 0.0696429 0 0 0.0835714 0
0 0.0975 0 0 0.111429 0 0 0.125357 0 0
0.139286 0 0 0.153214 0 0 0.167143 0 0 0.181071
0 0 0.195 0 0 0.208929 0 0 0.222857 0
0 0.236786 0 0 0.250714 0 0 0.264643 0 0
0.278571 0 0 0.2925 0 0 0.306429 0 0 0.320357
0 0 0.334286 0 0 0.348214 0 0 0.362143 0
POLYGONS 3600 18000
4 62 61 0 1 4 63 62 1 2 4
64 63 2 3 4 65 64 3 4 4
66 65 4 5 4 67 66 5 6 4
68 67 6 7 4 69 68 7 8 4
70 69 8 9 4 71 70 9 10 4
72 71 10 11 4 73 72 11 12 4
74 73 12 13 4 75 74 13 14 4
76 75 14 15 4 77 76 15 16 4
78 77 16 17 4 79 78 17 18 4
80 79 18 19 4 81 80 19 20 4
82 81 20 21 4 83 82 21 22 4
84 83 22 23 4 85 84 23 24 4
86 85 24 25 4 87 86 25 26 4
88 87 26 27 4 89 88 27 28 4
90 89 28 29 4 91 90 29 30 4
92 91 30 31 4 93 92 31 32 4
CELL_DATA 3600
FIELD attributes 2
p 1 3600 float
81.7602 82.0853 81.4747 81.251 80.6114 79.9061 79.044 78.027 76.8713 75.5719 74.1311
72.551 70.8329 68.9783 66.9892 64.8677 62.6162 60.2374 57.7347 55.1119 52.3734
49.5245 46.5713 43.5209 40.3816 37.163 33.8764 30.5347 27.1528 23.7481 20.3405
16.953 13.6121 10.3482 7.19618 4.19617 1.39389 -1.15773 -3.3983 -5.2636 -6.67261
-7.52487 -7.68399 -7.59999 -7.35818 -6.99297 -6.53171 -5.99927 -5.41668 -4.80168 -4.16905
-3.52961 -2.89437 -2.27506 -1.67807 -1.03211 -0.572529 -0.157589 1.07343 0.446295 82.0853
82.4052 81.7922 81.5632 80.9185 80.2079 79.3401 78.3174 77.1558 75.8504 74.4034
Consider a very simple vtk data file:
data.vtk:You can use the following code to read the vtk data file:
This is the output:
The vtk data file describes a single triangle with vertices at
(0,0,0),(1,0,0),(0,1,0):POINTS 3 floatspecifies that there are 3 points, in floating point data type, in the datasets. The coordinates of the 3 points are in the following 3 lines:POLYGONS 1 4specifies that there is one polygon in the dataset, and 4 integers to index the points: 3: There are 3 points in the polygon 0: The 1st point is at index 0 of datasets, i.e.,(0,0,0)1: The 2nd point is at index 1 of datasets, i.e.,(1,0,0)2: The 3rd point is at index 2 of datasets, i.e.,(0,1,0)You can find out more about vtk data format from https://examples.vtk.org/site/VTKFileFormats/