Commit 5bad9d3d authored by David Gobbi's avatar David Gobbi
Browse files

BUG: Fix for bug 2524. Now GetBounds works when spacing is negative.

parent 5ebbb7b2
......@@ -32,7 +32,7 @@
#include "vtkVoxel.h"
#include "vtkInformationVector.h"
vtkCxxRevisionMacro(vtkImageData, "1.17");
vtkCxxRevisionMacro(vtkImageData, "1.18");
vtkStandardNewMacro(vtkImageData);
//----------------------------------------------------------------------------
......@@ -933,13 +933,18 @@ void vtkImageData::ComputeBounds()
vtkMath::UninitializeBounds(this->Bounds);
return;
}
this->Bounds[0] = origin[0] + (extent[0] * spacing[0]);
this->Bounds[2] = origin[1] + (extent[2] * spacing[1]);
this->Bounds[4] = origin[2] + (extent[4] * spacing[2]);
this->Bounds[1] = origin[0] + (extent[1] * spacing[0]);
this->Bounds[3] = origin[1] + (extent[3] * spacing[1]);
this->Bounds[5] = origin[2] + (extent[5] * spacing[2]);
int swapXBounds = (spacing[0] < 0); // 1 if true, 0 if false
int swapYBounds = (spacing[1] < 0); // 1 if true, 0 if false
int swapZBounds = (spacing[2] < 0); // 1 if true, 0 if false
this->Bounds[0] = origin[0] + (extent[0+swapXBounds] * spacing[0]);
this->Bounds[2] = origin[1] + (extent[2+swapYBounds] * spacing[1]);
this->Bounds[4] = origin[2] + (extent[4+swapZBounds] * spacing[2]);
this->Bounds[1] = origin[0] + (extent[1-swapXBounds] * spacing[0]);
this->Bounds[3] = origin[1] + (extent[3-swapYBounds] * spacing[1]);
this->Bounds[5] = origin[2] + (extent[5-swapZBounds] * spacing[2]);
}
//----------------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment