Commit 82021e42 authored by Haocheng LIU's avatar Haocheng LIU

VTK Bug15270: Correct empty condition for vtkGlyph3DMapper

When working on an empty polydata, vtkGlyph3DMapper::GetBounds would
return the bounds of the glyph instead of vtkMath::UninitializedBounds.
This would be confusing because glyph's bounds has nothing to do with
the rest of the scene and discrupts
vtkRenderer::ResetCameraClippingRange. To fix this, a check condition is
added and a new test file is included.
parent 8bc5f126
Pipeline #25630 passed with stage
......@@ -37,6 +37,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestEdgeFlags.cxx
TestFollowerPicking.cxx
TestGlyph3DMapper.cxx
TestGlyph3DMapper2.cxx,NO_VALID,NO_RT,NO_DATA
TestGlyph3DMapperArrow.cxx
TestGlyph3DMapperMasking.cxx
TestGlyph3DMapperOrientationArray.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Test case of empty input for vtkGlyph3DMapper. Refer to MR!1529.
#include "vtkTestUtilities.h"
#include "vtkRegressionTestImage.h"
#include <vtkMath.h>
#include <vtkSmartPointer.h>
#include <vtkCubeSource.h>
#include <vtkPolyData.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkGlyph3DMapper.h>
int TestGlyph3DMapper2(int vtkNotUsed(argc), char *vtkNotUsed(argv)[])
{
// create empty input data
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();
vtkSmartPointer<vtkCubeSource> cubeSource =
vtkSmartPointer<vtkCubeSource>::New();
vtkSmartPointer<vtkGlyph3DMapper> glyph3Dmapper =
vtkSmartPointer<vtkGlyph3DMapper>::New();
glyph3Dmapper->SetSourceConnection(cubeSource->GetOutputPort());
glyph3Dmapper->SetInputData(polydata);
glyph3Dmapper->Update();
double *boundsResult, boundsAnswer[6];
vtkMath::UninitializeBounds(boundsAnswer);
// since there is nothing inside the scene, the boundsResult should be an
// uninitializeBounds
boundsResult = glyph3Dmapper->GetBounds();
for (int i = 0; i < 6; ++i)
{
if (boundsResult[i] != boundsAnswer[i]) return -1;
}
return 0;
}
......@@ -442,7 +442,12 @@ bool vtkGlyph3DMapper::GetBoundsInternal(vtkDataSet* ds, double ds_bounds[6])
}
ds->GetBounds(ds_bounds);
// if there is nothing inside the scene, just return uninitializedBounds
if ((ds_bounds[0] > ds_bounds[1]) && (ds_bounds[2] > ds_bounds[3]) && \
(ds_bounds[4] > ds_bounds[5]))
{
return false;
}
// if the input is not conform to what the mapper expects (use vector
// but no vector data), nothing will be mapped.
// It make sense to return uninitialized bounds.
......
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