[vtkusers] BUG: vtkImageData::ComputeBounds() ... + solution
Schaap, J.A. (LKEB)
J.A.Schaap at lumc.nl
Thu Jul 18 05:44:34 EDT 2002
Hi,
maybe I have a different understanding of the concept "bounds", but I think the current implementation of vtkImageData::ComputeBounds() isn't quite right. (vtk version 4.0)
void vtkImageData::ComputeBounds()
{
float *origin = this->GetOrigin();
float *spacing = this->GetSpacing();
this->Bounds[0] = origin[0] + (this->Extent[0] * spacing[0]);
this->Bounds[2] = origin[1] + (this->Extent[2] * spacing[1]);
this->Bounds[4] = origin[2] + (this->Extent[4] * spacing[2]);
this->Bounds[1] = origin[0] + (this->Extent[1] * spacing[0]);
this->Bounds[3] = origin[1] + (this->Extent[3] * spacing[1]);
this->Bounds[5] = origin[2] + (this->Extent[5] * spacing[2]);
}
I think it should be replaced by:
void vtkImageData::ComputeBounds()
{
float *origin = this->GetOrigin();
float *spacing = this->GetSpacing();
this->Bounds[0] = origin[0] + (this->Extent[0] * spacing[0]);
this->Bounds[2] = origin[1] + (this->Extent[2] * spacing[1]);
this->Bounds[4] = origin[2] + (this->Extent[4] * spacing[2]);
this->Bounds[1] = origin[0] + ((this->Extent[1] + 1) * spacing[0]);
this->Bounds[3] = origin[1] + ((this->Extent[3] + 1) * spacing[1]);
this->Bounds[5] = origin[2] + ((this->Extent[5] + 1) * spacing[2]);
}
Just to clarify this with an example...
suppose I would create a piece of vtkImageData with dimensions 32x32x32.
This would give me an extent of [0, 31, 0, 31, 0, 31]
I set the spacing to (10, 10, 10) and the origin to (0, 0, 0)
IMHO this would give me bounds of [0, 320, 0, 320, 0, 320], but the current implementation yields [0, 310, 0, 310, 0, 310]
If you agree, could this be corrected?
Best regards, Jorrit Schaap
More information about the vtkusers
mailing list