Creating a simple polyline VTKHDF

I have created a simple legacy VTK for a bunch of lines as shown below:

# vtk DataFile Version 3.0
vtk output
ASCII
DATASET POLYDATA
POINTS 4 float
0 0 0
1 1 0
1 2 0
2 0 0
LINES 2 8
3 0 1 3
3 4 2 0

I want to create the same geometry in VTKHDF (using Fortran code). I read through the example “test_poly_data.hdf” but i am confused as to when to create a group or a dataset or an attribute, some datasets in the example are within some groups and other datasets don’t belong to any group. So far I was able to create the header of VTKHDF

HDF5 "file.hdf" {
GROUP "/" {
   GROUP "VTKHDF" {
      ATTRIBUTE "Type" {
         DATATYPE  H5T_STRING {
            STRSIZE 9;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
         DATA {
         (0): "PolyData"
         }
      }
      ATTRIBUTE "Version" {
         DATATYPE  H5T_STD_I32LE
         DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
         DATA {
         (0): 2, 2
         }
      }
   }
}
}


Do I need to create a stand alone dataset called “Points” next? How do I create the lines?

I created the following hdf5 file:

HDF5 "file.hdf" {
GROUP "/" {
   DATASET "LINES" {
      DATATYPE  H5T_STD_I32LE
      DATASPACE  SIMPLE { ( 2, 2 ) / ( 2, 2 ) }
      DATA {
      (0,0): 1, 3,
      (1,0): 2, 4
      }
   }
   DATASET "POINTS" {
      DATATYPE  H5T_IEEE_F32LE
      DATASPACE  SIMPLE { ( 4, 3 ) / ( 4, 3 ) }
      DATA {
      (0,0): 1.2, 4.5, 1,
      (1,0): 6, 2.3, 5,
      (2,0): 8, 5, 3.4,
      (3,0): 6, 9, 3
      }
   }
   GROUP "VTKHDF" {
      ATTRIBUTE "Type" {
         DATATYPE  H5T_STRING {
            STRSIZE 9;
            STRPAD H5T_STR_NULLTERM;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
         }
         DATASPACE  SCALAR
         DATA {
         (0): "PolyData"
         }
      }
      ATTRIBUTE "Version" {
         DATATYPE  H5T_STD_I32LE
         DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
         DATA {
         (0): 2, 2
         }
      }
   }
}
}

It contains a dataset named “POINTS” and another one named “LINES” similar to the legacy VTK file. But Paraview 5.12.0 can’t read it. A pop-up window appears called “Open Data Wtih…” with the default option ADIOS2VTXReader. I click OK and Paraview crashes.

Can you find an example of the file that loads successfully and just compare the formats?

Hello @Nikolaos_Beratlis,

There is complete documentation about the file format which explain what you’ll need to create in term of groups, datasets and attributes here: VTK File Formats - VTK documentation

You can also check this repository which contains several python scripts to generate valid vtkhdf file, sadly the script for polydata is a bit complex but it can help you: https://gitlab.kitware.com/keu-public/vtkhdf/vtkhdf-scripts