Skip to content

Incorrect visualization of vtkLongArray cell scalars when using vtk.js local rendering #900

Description

@user27182

Describe the bug

Using trame-vtk with vtkLongArray cell scalars results in incorrect visualization of the data. Using vtkTypeInt64Array instead produces the correct result.

In VTK 9.6.2, the conversion between NumPy and VTK array dtypes was incorrect, resulting in long being converted to int64. This was fixed in VTK 9.7.0 with https://gitlab.kitware.com/vtk/vtk/-/merge_requests/13430.

Consequently, downstream users like PyVista which use vtk_to_numpy and numpy_to_vtk are now seeing this bug surface in VTK 9.7, since the numpy conversion would previously "mask" the bug by changing the dtype from long (broken) to int64 (working), whereas now the NumPy conversion is correct and we go from long (broken) back to long (still broken). See pyvista/pyvista#8810 (comment)

I created a matrix using the reproducer below to show how the different arrays and how the use of a NumPy round-trip conversion affects the output. The table shows the apparent regression with vtkLongArray previously working in 9.6.2 with a NumPy round-trip, which breaks with vtk 9.7.

This issue with vtkLongArray is only visible when using trame-vtk. The correct output is observed in all cases when using vtk outside of a trame app.

Args vtk-9.6.2 vtk-9.7.0rc2
vtkLongArray Image Image
vtkLongArray --numpy-roundtrip Image Image
vtkTypeInt64Array Image Image
vtkTypeInt64Array --numpy-roundtrip Image Image

To Reproduce

Download the script dtype_bug.py. Create a new env and install deps:

pip install trame trame-vuetify trame-vtk vtk

Run the script with the args listed in the table above to generate the outputs, along with a port, e.g.

python ./dtype_bug.py vtkLongArray --port 1234
python ./dtype_bug.py vtkLongArray --numpy-roundtrip --port 1234
python ./dtype_bug.py vtkTypeInt64Array --port 1234
python ./dtype_bug.py vtkTypeInt64Array --numpy-roundtrip --port 1234

Platform:

Device:

  • Desktop
  • Mobile

OS:

  • Windows
  • MacOS
  • Linux
  • Android
  • iOS

Browsers Affected:

  • Chrome
  • Firefox
  • Microsoft Edge
  • Safari
  • Opera
  • Brave
  • IE 11

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions