For a vtkImageData, I want to modify the scalar using SetScalarComponentFromDouble. But, I find the GetScalarRange do not return the correct result after SetScalarComponentFromDouble.
My test code is:
import vtkmodules.all as vtk
img = vtk.vtkImageData()
img.SetDimensions(100, 100, 1)
img.AllocateScalars(vtk.VTK_DOUBLE, 1)
for i in range(100):
for j in range(100):
img.SetScalarComponentFromDouble(i, j, 0, 0, i+j)
range1 = img.GetScalarRange()
print('range1: ', range1)
img.SetScalarComponentFromDouble(0, 0, 0, 0, 1000)
img.Modified()
range2 = img.GetScalarRange()
print('range2: ', range2)
The range2 is the same with range1 (0~198) even img.SetScalarComponentFromDouble(0, 0, 0, 0, 1000).
After look at the c++ code, I find that the range do not computer after SetScalarComponentFromDouble. For vtkDataArray, the GetRange explain that:
The range is computed and then cached, and will not be re-computed on subsequent calls to GetRange().
How can I force it to re-compute range?