Cannot read VTK files with METADATA

Issue #125 new
Karol Lewandowski created an issue

When we try to load a vtk file (moab.load_file("plane.vtk", 0, "");) created for example with ParaView 5.7.0 we get the following error:

MOAB ERROR: Parsing error at line 230: expected one of { VERTICES LINES POLYGONS TRIANGLE_STRIPS } got "METADATA"!
MOAB ERROR: match_token() line 378 in src/io/FileTokenizer.cpp
MOAB ERROR: --------------------- Error Message ------------------------------------
MOAB ERROR: Failed to load file after trying all possible readers!
MOAB ERROR: serial_load_file() line 623 in src/Core.cpp
MOAB ERROR: load_file() line 514 in src/Core.cpp

However, when we delete the metadata lines from vtk e.g.:

INFORMATION 2
NAME L2_NORM_RANGE LOCATION vtkDataArray
DATA 2 0.516745 1.17908 
NAME L2_NORM_FINITE_RANGE LOCATION vtkDataArray
DATA 2 0.516745 1.17908

Everything works fine.

Comments (20)

  1. Vijay M

    Thanks for raising the issue. We will add some switches to accomodate these section changes. I will let you know when a PR is ready for review.

  2. Antoine Mazuyer

    Yes, it seems to have issues with MOAB and the file format support. Paraview and vtk writes only the version 5.1 now. And MOAB reads only v3.0 or below.

  3. Antoine Mazuyer

    Hi @Iulian Grindeanu . According to this post, there is no official documentation for the new legacy format, it’s still work in progress

  4. Iulian Grindeanu

    Thanks Antoine; so I assume the only solution is to look at the source code, and try to reverse engineer the format; maybe the source code is documented. Does anybody know ? Is Paraview using directly vtk reader/writers for the new legacy code? Or do they process it ? Probably I have to see vtk source code, not Paraview

  5. Antoine Mazuyer

    You are right : the vtk code is included within Paraview, and this is this code which is called by Paraview.

    My conclusions were that Paraview/VTK has the backward compatibility to read the old file format (<= 3.0), but can’t save them anymore (just the 5.1).

    As far as I know, the main difference are in the way the cells are written. Indeed, there is “three” subsections after the “CELL” sections (CONNECTIVITY, CELL_TYPES and OFFSETS) that are handled by this :

    https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Legacy/vtkUnstructuredGridWriter.cxx#L38

    and this

    https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Legacy/vtkDataWriter.cxx#L2292

  6. Antoine Mazuyer

    I gathered simple data set in the “old” and “new” format : one sphere meshed with tetrahedra (I also put some simple field data for the new version), and one cube meshed with arbitrary polyhedron.

    I hope it can help.

    https://gofile.io/d/RB2jTf

  7. Iulian Grindeanu

    no, sorry; it seems that the solution is to reverse engineer / understand what paraview does; we have a list of tokens that we process; and should adapt what we do to the new format; even vtk examples site is outdated:
    https://kitware.github.io/vtk-examples/site/VTKFileFormats/

    we support polyhedra in our moab vtk reader / writer since 4.9.1; there is no doc though on how to interpret the metadata, and what can be skipped 😞 safely;

  8. Iulian Grindeanu

    @Antoine Mazuyer can you please update the link with your example? it expired and I missed it :)

  9. Iulian Grindeanu

    so there are several issues; legacy format is vtk 3.0, which we support, including polyhedra and polygons; paraview 5.7 exports in format 4.2, which seems to be very similar to 3.0, except for metadata info; paraview 5.8 exports in vtk format 5.0, which is different, because it introduces, as Antoine pointed out, new subsections, OFFSETS, CONNECTIVITY and then old CELL_TYPES ; The only way to even obtain example files is to run paraview 5.7, 5.8 and export old files in new format; I just deleted 5. 7 from my laptop, I have to install again 🙂

  10. Log in to comment