Hi all,
I am facing a strange behavior and I am pretty sure I am missing something. Using VTK 8.0.1.
I have a 3D VtkImageData to which I need to modify the scalar values. When I get the ScalarRange is ok before changing them all.
I proceed to change the values, but then after the cycle, the scalar range is exactly the same. I print a value inside the cycle to make sure there is a change.
The code goes as follows:
int dims[3];
img->GetDimensions(dims);
float* beamBuf = (float*)img->GetScalarPointer();
cout << "my nf = " << nf << endl;
cout<< img->GetScalarRange()[0] << "," << img->GetScalarRange()[1] <<endl;
for (int j = 0; j < dims[0] * dims[1] * dims[2]; j++)
{
if(dims[0] * dims[1] * dims[2]/3 == j) cout << beamBuf[j] << endl;
beamBuf[j] = (float)beamBuf[j] / (float)nf;
if(dims[0] * dims[1] * dims[2]/3 == j) cout << beamBuf[j] << endl;
}
// force modified…
img->Modified();
img->GetPointData()->Modified();
img->GetPointData()->Update();
cout<< img->GetScalarRange()[0] << “,” << img->GetScalarRange()[1] <<endl;
and this is the output:
my nf = 16
0, 25.1817
0.176752
0.011047
0, 25.1817
Later on, I use this same image to perform a calculation and then the values are the ones I updated on the buffer.
I am utterly confused.
LoneWolf.