Commit 11e0f703 authored by Francois Bertel's avatar Francois Bertel

BUG:Fixed double *GetBounds() on vtkAbstractMapper3D subclasses. In...

BUG:Fixed double *GetBounds() on vtkAbstractMapper3D subclasses. In vtkAbstractMapper3D, GetCenter() and GetLength() call GetBounds and rely on the side effect that it will update this->Bounds, the subclasses implementations were not changing this->Bounds to uninitialized (1,-1,1,-1,1,-1) and were returning some arbitrary (-1,1,-1,1,-1,1) valid bounds instead when the input is null. It could be problematic if the scene has one mapper with a valid input with bounds out of (-1,1,-1,1-1,1) and another mapper with an empty input. Fixed another bug in vtkCompositePolyDataMapper2.cxx where input can be used before checking it is not null.
parent a689b765
......@@ -52,7 +52,7 @@
#include "vtkVertexGlyphFilter.h"
#include "vtkViewTheme.h"
vtkCxxRevisionMacro(vtkGraphMapper, "1.26");
vtkCxxRevisionMacro(vtkGraphMapper, "1.27");
vtkStandardNewMacro(vtkGraphMapper);
#define VTK_CREATE(type,name) \
......@@ -705,12 +705,11 @@ int vtkGraphMapper::FillInputPortInformation(
//----------------------------------------------------------------------------
double *vtkGraphMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
vtkGraph *graph = vtkGraph::SafeDownCast(this->GetExecutive()->GetInputData(0, 0));
if (!graph)
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
if (!this->Static)
{
......@@ -719,7 +718,8 @@ double *vtkGraphMapper::GetBounds()
}
if (!graph)
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
graph->GetBounds(this->Bounds);
return this->Bounds;
......
......@@ -43,6 +43,7 @@ public:
// Description:
// Return bounding box (array of six doubles) of data expressed as
// (xmin,xmax, ymin,ymax, zmin,zmax).
// Update this->Bounds as a side effect.
virtual double *GetBounds()=0;
// Description:
......@@ -56,7 +57,7 @@ public:
{
double *rc = this->GetCenter();
center[0] = rc[0]; center[1] = rc[1]; center[2] = rc[2];
};
}
// Description:
// Return the diagonal length of this mappers bounding box.
......@@ -65,16 +66,16 @@ public:
// Description:
// Is this a ray cast mapper? A subclass would return 1 if the
// ray caster is needed to generate an image from this mapper.
virtual int IsARayCastMapper() {return 0;};
virtual int IsARayCastMapper() {return 0;}
// Description:
// Is this a "render into image" mapper? A subclass would return 1 if the
// mapper produces an image by rendering into a software image buffer.
virtual int IsARenderIntoImageMapper() {return 0;};
virtual int IsARenderIntoImageMapper() {return 0;}
protected:
vtkAbstractMapper3D();
~vtkAbstractMapper3D() {};
~vtkAbstractMapper3D() {};
double Bounds[6];
double Center[3];
......
......@@ -19,7 +19,7 @@
#include "vtkInformation.h"
#include "vtkMath.h"
vtkCxxRevisionMacro(vtkAbstractVolumeMapper, "1.11");
vtkCxxRevisionMacro(vtkAbstractVolumeMapper, "1.12");
// Construct a vtkAbstractVolumeMapper
vtkAbstractVolumeMapper::vtkAbstractVolumeMapper()
......@@ -44,11 +44,10 @@ vtkAbstractVolumeMapper::~vtkAbstractVolumeMapper()
// (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
double *vtkAbstractVolumeMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
if ( ! this->GetDataSetInput() )
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
else
{
......
......@@ -28,7 +28,7 @@
#include <vtkstd/vector>
vtkCxxRevisionMacro(vtkCompositePolyDataMapper, "1.1");
vtkCxxRevisionMacro(vtkCompositePolyDataMapper, "1.2");
vtkStandardNewMacro(vtkCompositePolyDataMapper);
class vtkCompositePolyDataMapperInternals
......@@ -272,24 +272,22 @@ void vtkCompositePolyDataMapper::ComputeBounds()
this->BoundsMTime.Modified();
}
double* vtkCompositePolyDataMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
double *vtkCompositePolyDataMapper::GetBounds()
{
if ( ! this->GetExecutive()->GetInputData(0, 0) )
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
else
{
this->Update();
//only compute bounds when the input data has changed
vtkCompositeDataPipeline * executive = vtkCompositeDataPipeline::SafeDownCast(this->GetExecutive());
if( executive->GetPipelineMTime() > this->BoundsMTime.GetMTime() )
{
ComputeBounds();
this->ComputeBounds();
}
return this->Bounds;
......
......@@ -31,7 +31,7 @@
#include "vtkDefaultPainter.h"
vtkStandardNewMacro(vtkCompositePolyDataMapper2);
vtkCxxRevisionMacro(vtkCompositePolyDataMapper2, "1.1");
vtkCxxRevisionMacro(vtkCompositePolyDataMapper2, "1.2");
//----------------------------------------------------------------------------
vtkCompositePolyDataMapper2::vtkCompositePolyDataMapper2()
{
......@@ -158,8 +158,6 @@ void vtkCompositePolyDataMapper2::ComputeBounds()
vtkCompositeDataSet *input = vtkCompositeDataSet::SafeDownCast(
this->GetInputDataObject(0, 0));
input->Update();
// If we don't have hierarchical data, test to see if we have
// plain old polydata. In this case, the bounds are simply
// the bounds of the input polydata.
......@@ -168,7 +166,9 @@ void vtkCompositePolyDataMapper2::ComputeBounds()
this->Superclass::GetBounds();
return;
}
input->Update();
// We do have hierarchical data - so we need to loop over
// it and get the total bounds.
vtkCompositeDataIterator* iter = input->NewIterator();
......@@ -211,13 +211,12 @@ void vtkCompositePolyDataMapper2::ComputeBounds()
}
//-----------------------------------------------------------------------------
double* vtkCompositePolyDataMapper2::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
double *vtkCompositePolyDataMapper2::GetBounds()
{
if ( !this->GetExecutive()->GetInputData(0, 0) )
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
else
{
......
......@@ -22,7 +22,7 @@
#include "vtkPointData.h"
#include "vtkMath.h"
vtkCxxRevisionMacro(vtkMapper, "1.122");
vtkCxxRevisionMacro(vtkMapper, "1.123");
// Initialize static member that controls global immediate mode rendering
static int vtkMapperGlobalImmediateModeRendering = 0;
......@@ -90,12 +90,10 @@ vtkMapper::~vtkMapper()
// (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
double *vtkMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
vtkDataSet *input = this->GetInput();
if ( ! input )
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
}
else
{
......@@ -104,8 +102,8 @@ double *vtkMapper::GetBounds()
this->Update();
}
input->GetBounds(this->Bounds);
return this->Bounds;
}
return this->Bounds;
}
vtkDataSet *vtkMapper::GetInput()
......
......@@ -36,7 +36,7 @@
#include "vtkStandardPolyDataPainter.h"
vtkStandardNewMacro(vtkPainterPolyDataMapper);
vtkCxxRevisionMacro(vtkPainterPolyDataMapper, "1.15")
vtkCxxRevisionMacro(vtkPainterPolyDataMapper, "1.16")
//-----------------------------------------------------------------------------
class vtkPainterPolyDataMapperObserver : public vtkCommand
......@@ -333,12 +333,11 @@ void vtkPainterPolyDataMapper::RenderPiece(vtkRenderer* ren, vtkActor* act)
//-------------------------------------------------------------------------
double* vtkPainterPolyDataMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
// do we have an input
if ( ! this->GetNumberOfInputConnections(0) )
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
else
{
......
......@@ -21,7 +21,7 @@
#include "vtkPolyData.h"
#include "vtkRenderWindow.h"
vtkCxxRevisionMacro(vtkPolyDataMapper, "1.49");
vtkCxxRevisionMacro(vtkPolyDataMapper, "1.50");
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -122,12 +122,11 @@ void vtkPolyDataMapper::Update()
// (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
double *vtkPolyDataMapper::GetBounds()
{
static double bounds[] = {-1.0,1.0, -1.0,1.0, -1.0,1.0};
// do we have an input
if ( ! this->GetNumberOfInputConnections(0))
{
return bounds;
vtkMath::UninitializeBounds(this->Bounds);
return this->Bounds;
}
else
{
......
Markdown is supported
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