Skip to content
Snippets Groups Projects
Commit 7323f95c authored by Lucas Givord's avatar Lucas Givord
Browse files

OpenGLBatchedPolyDataMapper: add test for overlapping cells

parent 5b04869c
No related branches found
No related tags found
No related merge requests found
vtk_module_test_data(
Data/pen_1.cur
Data/pen_1.xcursor
Data/overlap_faces.vtm
Data/overlap_faces/overlap_faces_0_0.vtp
Data/overlap_faces/overlap_faces_1_0.vtp
Data/overlap_faces/overlap_faces_2_0.vtp
)
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
......@@ -19,6 +23,7 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests
TestCameraShiftScale.cxx,NO_DATA
TestCoincident.cxx
TestCoincidentFloor.cxx
TestCompositeDataOverlappingCells.cxx,
TestCompositeDataPointGaussian.cxx,NO_DATA
TestCompositeDataPointGaussianSelection.cxx,NO_DATA
TestCompositePolyDataMapper2.cxx,NO_DATA
......
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include <vtkActor.h>
#include <vtkCompositeDataDisplayAttributes.h>
#include <vtkCompositePolyDataMapper.h>
#include <vtkFeatures.h>
#include <vtkInformation.h>
#include <vtkNew.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#include <vtkXMLMultiBlockDataReader.h>
#include <vtkLogger.h>
#include <vtkRegressionTestImage.h>
#include <vtkTesting.h>
/**
* The purpose of this test is to make sure that we always have the same image produced by the
* composite polydata mapper if we do multiple render call, it was previously not the case when
* a multiblock have some overlap between these blocks.
*/
int TestCompositeDataOverlappingCells(int argc, char* argv[])
{
vtkDebugWithObjectMacro(nullptr, "Load the multiblock.");
vtkNew<vtkTesting> testing;
testing->AddArguments(argc, argv);
std::string filename = testing->GetDataRoot();
filename += "/Data/overlap_faces.vtm";
vtkNew<vtkXMLMultiBlockDataReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
vtkDebugWithObjectMacro(nullptr, "Setup everything to be able to render with VTK this data");
vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
win->AddRenderer(ren);
win->SetInteractor(iren);
win->SetSize(400, 400);
vtkSmartPointer<vtkCompositePolyDataMapper> mapper =
vtkSmartPointer<vtkCompositePolyDataMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
mapper->SelectColorArray("SpatioTemporalHarmonics");
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
ren->AddActor(actor);
vtkDebugWithObjectMacro(nullptr,
"Everything should be setup now, do multiple render call and check that we always "
"have the same result.");
int status = EXIT_SUCCESS;
int numberOfRenderCalls = 10;
for (int i = 0; i < numberOfRenderCalls; i++)
{
reader->GetOutputInformation(0)->Set(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP(), i);
reader->Update();
int retVal = vtkRegressionTestImageThreshold(win, 0.05);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
// if we test this executable we don't want to do multiple render call, skip.
break;
}
if (retVal == vtkRegressionTester::FAILED)
{
vtkErrorWithObjectMacro(
nullptr, << "The " << i
<< "th image produced is wrong, we should always have the same image produced.");
status = EXIT_FAILURE;
break;
}
}
return status;
}
e56901c48fd5a3bc110cc876a83faf0cf4c6f22e8542812e62e9377510bf5dc7a9ff9f72ca3f2f9a08030f153740db367f128d83f19191beffde55c54e09a28e
3194f0d02f60d93f72b7591a49aa0eeacf7d8d560eb6a88d012ab5790e8b680a6164ea5cc33b5c0793017431439fba1b94f270d779b73d3294b8ddee8c3fcc0d
1a4f71ffcd5b4affe75447f01eb811936c0b5c72b63f6d1ffac7898699d5b6e435f3127e0b507f0a6407e047177f651400e94aa27f98c84d9fe620daf37cc0f7
83f1f8ea810227c728a194e392ed464c8fcbd07f38427749136fdcf8c561b6919b1d2f334113bf67cf05086a94148b1e4f8b243d87ac677ef4b23dc5de273215
4cc78a1e91fe9a6bc4d004457de40aae709c28ea0a98ee6ddb9353bcec164d1bc4ffb028f59a6e445840672011647ff3f6f7e881fcecb7f3079cb84d5ea6fbf3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment