zaidb
(Zaïd)
October 3, 2022, 9:04pm
1
Hello,
When defining a vtkDataArray
with NaN, getRange
returns [NaN, NaN]
.
const data = [NaN, 1, 0, 100];
const scalar = vtkDataArray.newInstance({
name: "test",
values: data
});
I guess this is a wanted behaviour, but perhaps getRange
could take in a parameter to return the range excluding NaN [0, 100]
?
finetjul
(Julien Finet)
October 4, 2022, 2:47pm
2
It is indeed different from the C++/Python behavior.
>>> di = vtk.vtkIntArray()
>>> di.SetNumberOfTuples(4)
>>> di.SetTuple1(0, float("nan"))
>>> di.SetTuple1(1, 1)
>>> di.SetTuple1(2, 0)
>>> di.SetTuple1(3, 100)
>>> di.GetRange()
(-2147483648.0, 100.0)
>>> df = vtk.vtkFloatArray()
>>> df.SetNumberOfTuples(4)
>>> df.SetTuple1(0, float("nan"))
>>> df.SetTuple1(1, 1)
>>> df.SetTuple1(2, 0)
>>> df.SetTuple1(3, 100)
>>> df.GetRange()
(0.0, 100.0)
It makes sense to me to have the same default behavior (ignore NaN when computing range).
I would suggest you can make a PR that modifies the range computation in VTK.js.