vtkImageIterator / GetScalarRange does not play well
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The following code does not work:
void FillImage(vtkImageData im, int ext[6], int timestep) { vtkImageIterator<signed char> it(im,ext); while (!it.IsAtEnd()) { signed char imSI = it.BeginSpan(); signed char* imSIEnd = it.EndSpan();
while (imSI != imSIEnd)
{
*imSI = (signed char)timestep;
++imSI;
}
it.NextSpan();
}
im->GetPointData()->Modified(); im->Modified(); }
int main() { vtkImageData *im = vtkImageData::New(); int ext[6] = {0,10,0,10,0,10}; im->SetExtent(ext); im->SetScalarType ( VTK_SIGNED_CHAR );
FillImage(im, ext, 0); double *range = im->GetScalarRange(); std::cerr << range[0] << "," << range[1] << std::endl; std::cout << "V=" << im->GetScalarComponentAsDouble ( 0, 0, 0, 0) << std::endl;
FillImage(im, ext, 100); double *range = im->GetScalarRange(); std::cerr << range[0] << "," << range[1] << std::endl; std::cout << "V=" << im->GetScalarComponentAsDouble ( 0, 0, 0, 0) << std::endl; }