Hello,
I hope this is the correct forum to ask a question about the VTK legacy file format. I have this application (not mine) that produces VTK legacy files, and it does something funky with the DIMENSIONS
line and I was hoping someone could tell me whether it’s allowed by the spec. For context, here is a sample file:
# vtk DataFile Version 2.0
PRIMITIVE vars at time= 1.202073e-01, level= 0, domain= 0
BINARY
DATASET STRUCTURED_POINTS
DIMENSIONS 1025 1 1
ORIGIN -5.000000e-01 -5.000000e-01 -5.000000e-01
SPACING 9.765625e-04 1.000000e+00 1.000000e+00
CELL_DATA 1024
SCALARS density float
LOOKUP_TABLE default
... <binary data goes here> ...
In this example, the data is actually a 1D array with 1024 entries. The application encodes the dimensionality of the array by adding 1 to all the dimentions that it considers “real” dimensions, so any dimension of length 1 is supposed to be ignored. For example:
1D array with 16 cells --> DIMENSIONS 17 1 1
2D array with 16x15 cells --> DIMENSIONS 17 16 1
3D array with 16x15x14 cells --> DIMENSIONS 17 16 15
You see how that works? What that means is that if you multiply the dimensions as written in the file you do not get the value in CELL_DATA. In the first example that I wrote above we have:
DIMENSIONS 1025 1 1
...
CELL_DATA 1024
So my question is: Is this legal? Is this a valid VTK legacy file? I tried to find a detailed specification for the VTK legacy file format but I couldn’t. So I would appreciate some clarification.
Thanks!