write vkthdf file with points only.

I am trying to understand how to write a vtkhdf file.
To that end I tried to make it as simple as possible and write only points with point data. My script looks like this:

import h5py as h5
import numpy    as np
pnts = np.array([[0,0,0],
                 [1,0,0],
                 [1,1,1]])
with h5.File('points.vtkhdf', 'w') as f:
    root = f.create_group('VTKHDF', track_order=True)
    root.attrs['Version'] = (2,1)
    ascii_type = 'UnstructuredGrid'.encode('ascii')
    root.attrs.create('Type', ascii_type, dtype=h5.string_dtype('ascii', len(ascii_type)))
    
    n_steps = 1
    root.create_dataset('NumberOfPoints'         , data=[pnts.shape[0]], dtype='i8')
    root.create_dataset('NumberOfConnectivityIds', data=[0]            , dtype='i8')
    root.create_dataset('NumberOfCells'          , data=[0]            , dtype='i8')
    
    root.create_dataset('Types',        data = []  , dtype=np.uint8)
    root.create_dataset('Points',       data = pnts, dtype='f'     )
    root.create_dataset('Offsets',      data = []  , dtype='i8'    )
    root.create_dataset('Connectivity', data = []  , dtype='i8'  )

    point_data = root.create_group("PointData")
    pressure_field = (1, 2, 3, )
    point_data.create_dataset("Pressure", data=(pressure_field), dtype="f")

Paraview can open the generated “points.vtkhdf” file. Unfortunately, the points are not rendered. However, I see the points and the data in the spread sheet view.

Have I done something wrong or is it not possible to display points only with the unstructured grid vtkhdf file?

The VTK model relies on cell for most of work, specially rendering. While you can define an unstructured grid with points without cells, it is expected that nothing shows up.

That said ParaView offers several way to display them anyway:

  • change the representation: use Point Gaussian
  • create some cell with Convert to Point Cloud filter

Thanks for clarifying things. I was not aware of that.