DIMENSIONS field of the VTK legacy format

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!

Hi,
The DIMENSIONS specifies the number of points. This is why they are one more than the number of cells.

Dan

Hi Dan,

What is the difference between a point and a cell? From your reply, I’m imagining that points must correspond to the edges of a grid cell, but in that case what does it mean for there to be just 1 point? The program I have here uses “1 point” to denote that an dimension does not exist.

Is there a place where I can read a more detailed spec of the legacy format? Or maybe find a few examples?

Thanks!

Hi Daniel,
Take a look at VTK Text book section 5.3

https://lorensen.github.io/VTKExamples/site/VTKBook/05Chapter5/

The points correspond to edge intersections, cells which can be 2D or 3D cover the space between the points - they are used for interpolation = finding out values at places other than points.

If one of the dimensions is one means that the model is flat in that direction.

Dan