Commit cc96bd93 authored by Bill Lorensen's avatar Bill Lorensen

BUG: OpenGLPolyDataMapper2D regression

OpenGLPolyDataMapper2D for OpenGL was clipping the z components
between -1,0 or 0,1. The logic is a bit different in OpenGL2 versus
OpenGL. I believe it has somethiong to do with where the
transformations are performed. I'm pretty sure z-clipping should not
apply for 2D mappers. A new test was added that has polydata with a
large z range.

NOTE: To see the bug, download this patch and revert to the
original mapper:

git checkout master Rendering/OpenGL2

and
ctest -R TestLegendBoxActor2
parent 5d7b8d01
......@@ -18,6 +18,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestCubeAxesWithZInnerPolys.cxx
TestCubeAxesWithZLines.cxx
TestLegendBoxActor.cxx
TestLegendBoxActor2.cxx
TestLegendScaleActor.cxx
TestPieChartActor.cxx
TestPolarAxes.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestLegendBoxActor2.cxx
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.
=========================================================================*/
// This tests the terrain annotation capabilities in VTK.
#include "vtkCamera.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkLegendBoxActor.h"
#include "vtkSphereSource.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRegressionTestImage.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
//----------------------------------------------------------------------------
int TestLegendBoxActor2( int argc, char * argv [] )
{
// Create the RenderWindow, Renderer and both Actors
//
vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
renWin->SetMultiSamples(0);
renWin->AddRenderer(ren1);
ren1->GetActiveCamera()->ParallelProjectionOn();
vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
iren->SetInteractorStyle(style);
// Colors.
double textColor[5][3] = {{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0},
{1.0, 0.5, 0.5},
{0.5, 1.0, 0.5}};
double backgroundColor[3] = {0.8, 0.5, 0.0};
const char *text[5] = {"Text1",
"Text2",
"Text3",
"Text4",
"Text5"};
// Create the actor
vtkSmartPointer<vtkLegendBoxActor> actor = vtkSmartPointer<vtkLegendBoxActor>::New();
actor->SetNumberOfEntries(5);
actor->SetUseBackground(1);
actor->SetBackgroundColor(backgroundColor);
actor->SetBackgroundOpacity(1.0);
actor->GetPositionCoordinate()->SetCoordinateSystemToView();
actor->GetPositionCoordinate()->SetValue(-0.7, -0.8);
actor->GetPosition2Coordinate()->SetCoordinateSystemToView();
actor->GetPosition2Coordinate()->SetValue(0.7, 0.8);
// Create a test pipeline
//
for(int i=0; i < 5; ++i)
{
vtkSmartPointer<vtkSphereSource> sphere =
vtkSmartPointer<vtkSphereSource>::New();
sphere->SetRadius(static_cast<double> (10 * (i + 1)));
sphere->Update();
actor->SetEntry(i, sphere->GetOutput(), text[i], textColor[i]);
}
// Add the actors to the renderer, set the background and size
ren1->AddViewProp(actor);
ren1->SetBackground(0.0, 0.0, 0.0);
renWin->SetSize(350, 350);
// render the image
//
iren->Initialize();
renWin->Render();
int retVal = vtkRegressionTestImage( renWin );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
......@@ -481,11 +481,11 @@ void vtkOpenGLPolyDataMapper2D::SetCameraShaderParameters(
}
float nearV = 0;
float farV = 1;
float farV = VTK_FLOAT_MAX;
if (actor->GetProperty()->GetDisplayLocation() !=
VTK_FOREGROUND_LOCATION)
{
nearV = -1;
nearV = -VTK_FLOAT_MAX;;
farV = 0;
}
......
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