Skip to content

Enable loading cell/point data arrays in the BaseVTKLoader#2

Open
th-skam wants to merge 16 commits intoSofaDefrost:mainfrom
InfinyTech3D:dev-create-loaders
Open

Enable loading cell/point data arrays in the BaseVTKLoader#2
th-skam wants to merge 16 commits intoSofaDefrost:mainfrom
InfinyTech3D:dev-create-loaders

Conversation

@th-skam
Copy link
Contributor

@th-skam th-skam commented Mar 11, 2026

This PR adds support for loading VTK cell and point data arrays as Data fields. Its creation was motivated by one recent use-case.

Two fields must be specified in the scene file:

<UnstructuredGridVTKLoader name="loader" filename="mesh.vtu"
    cellDataNames="pressure fiber_direction material_id"
    pointDataNames="temperature velocity"/>

Most of the new functions are inside the BaseVTKLoader.

  • For each given name, the data arrays are loaded through loadDataArrayByName().
  • The loader now manages ptrs to the newly created Data and has to delete them in doClearBuffers().
  • The vtkArrayDispatch from the vtk library is used to decide the types of the data among float, double, signed/unsigned char, int, unsigned int, long, unsigned long, long long, unsigned long long. This should cover the types supported (at one point) by SOFA's native vtk loader (Int32/64/8 etc.).
  • long and unsigned long are mapped to fixed-size equivalents depending on platform.
  • Multi-component arrays are limited to 9 components, covering up to 3x3 tensors. Beyond that, data are rejected with a warning.

An example can be found in examples/xml/LoadDataArrays.scn and a test in TestCellPointData.cpp.

I used an AI-agent to assist with development here so some care should be taken in review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants