Skip to content

(io): serialize Image (.vti), Mesh (.vtp) with SessionWriter/SessionReader

Description

The serialization is done through four classes: MeshSerializer, MeshDeserializer, ImageSerializer and ImageDeserializer. The serializers converts Sight images / meshes into VTK format using Sight helpers. The VTK image / mesh are then saved with the now "standard" VTK way using vtkXMLImageDataWriter for image and vtkXMLPolyDataWriter for meshes.

As a side notes, since the files are stored in a zstd compressed zip file, and since VTK doesn't provide any way to use an output streams, the VTK writers are configured as such (image and mesh are equivalent):

vtkWriter->SetCompressorTypeToNone();
vtkWriter->SetDataModeToBinary();
vtkWriter->WriteToOutputStringOn();
vtkWriter->SetInputData(vtkImage);

This allow us to compress only one time and use fast zstd. Since the compression level can be set independently, some test need to be done to find the best efficiency. For now it is the "default" mode that is used, but better compression ratio at the expense of compression speed (not decompression!) is also possible.

The drawback for using WriteToOutputStringOn() is that the complete data need to be written in memory before being able to serialize it. Shame on VTK for not providing an easy way to use c++ streams...

The format choice is purely arbitrary. This can be discussed as needed.

Closes #685 (closed)

How to test it?

Launch io_sessionTest.

Edited by Didier WECKMANN

Merge request reports