Changes in VTK lagacy format from V3.0 to V5.0 - causes cell offset error

I’m trying to write a legacy VTK file for an unstructured tetrahedral grid. All of the VTK documentation I can find suggests that the cell linkage block should have a header as follows
CELLS <# cells> <total number of points in all cells + # points in each cell array>
e.g.
CELLS 2233592 11167960
4 51509 26695 53716 54650
4 225124 286911 289432 347607
If I do that with a VTK header of # vtk DataFile Version 5.0
I get an error on import to Paraview
ERROR: In vtkDataReader.cxx, line 3335
vtkUnstructuredGridReader (0x6a6e0480): Error reading cell array offset header.
If I change the VTK header to # vtk DataFile Version 3.0 the file loads correctly
Taking some hints from the xml format documentation and AI I tried changing the cell header line to
CELLS <# cells>
e.g.
CELLS 2233592 8934368
51509 26695 53716 54650
225124 286911 289432 347607
but that just gave me the same array offset read error.

All but one of the example Unstructured grid VTK files in the PV download are for Version <=3. The one example with Version 5 is binary. If I import it and export to ascii from PV it looks like I’m missing the OFFSET and CONNECTIVITY arrays but the CELLS line format looks like it should be

CELLS <# cells+1>

It also appears that if you have n cells then you have n+1 elements in the OFFSET array?

so the CELLS header format could be

CELLS

What is the correct syntax for V5.0 files, please? Better still can someone point me to a VTK file format manual which describes it, preferably with an example.

Also it appears that Paraview is limited to 256 characters on a line in an ASCII VTK. Is that a VTK limitation of one imposed by the Paraview reader?

Hello @KimF ,

tbh, if it’s possible for you, I recommend you to write it in HDF5, there is multiple examples showing how to do that following the VTKHDF File Format.

Lucas

That would require rewriting over a thousand lines of code in my vtk library which would take me a day or two so I’d rather avoid it if I can. Also the only HDF5 writers I have been able to find are in python and so either require continual maintenance or won’t work in a years time as the support libraries change without backward compatibility. I’m only really interested in solutions that will still work in 20 years time. A stretch I know but I’m still compiling code that was written in the 70s and runs perfectly. Also my VTKs are typically not huge (a few gig at most) and thus not warranting the compaction of an HDF5 container. If size becomes an issue I could switch to binary relatively easily as I made allowances for that when I wrote the libraries, just need to add a few lines of code to do the work.

The current web based VTK manual documents the pre V5 approach for ASCII legacy files. Is there anywhere where the V5 ASCII format is documented?

The editor has removed some of the variables after CELLS so as displayed it does not make sense sorry. There are two integers after CELLS but the second has been dropped from the top two examples and both are missing from the last, not sure what is going on there but hopefully it doesn’t destroy the meaning