diff --git a/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt b/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt index 7bc0cccb3d8ccb780ca725f581319e5fb7210e16..797cc3c633ddd1831c4a9ecc1b3b5d4e3ef9b8b5 100644 --- a/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt +++ b/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt @@ -1,6 +1,10 @@ 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 diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositeDataOverlappingCells.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositeDataOverlappingCells.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3f37d2c8cfe88606dd3050d7a7b70647f528c9a9 --- /dev/null +++ b/Rendering/OpenGL2/Testing/Cxx/TestCompositeDataOverlappingCells.cxx @@ -0,0 +1,90 @@ +// 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; +} diff --git a/Rendering/OpenGL2/Testing/Data/Baseline/TestCompositeDataOverlappingCells.png.sha512 b/Rendering/OpenGL2/Testing/Data/Baseline/TestCompositeDataOverlappingCells.png.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..8d9845ae191deb472b279c273921a7dd4dac3dc3 --- /dev/null +++ b/Rendering/OpenGL2/Testing/Data/Baseline/TestCompositeDataOverlappingCells.png.sha512 @@ -0,0 +1 @@ +e56901c48fd5a3bc110cc876a83faf0cf4c6f22e8542812e62e9377510bf5dc7a9ff9f72ca3f2f9a08030f153740db367f128d83f19191beffde55c54e09a28e diff --git a/Testing/Data/overlap_faces.vtm.sha512 b/Testing/Data/overlap_faces.vtm.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..539524bb9b62f50065911fa60a21e5146132e8e7 --- /dev/null +++ b/Testing/Data/overlap_faces.vtm.sha512 @@ -0,0 +1 @@ +3194f0d02f60d93f72b7591a49aa0eeacf7d8d560eb6a88d012ab5790e8b680a6164ea5cc33b5c0793017431439fba1b94f270d779b73d3294b8ddee8c3fcc0d diff --git a/Testing/Data/overlap_faces/overlap_faces_0_0.vtp.sha512 b/Testing/Data/overlap_faces/overlap_faces_0_0.vtp.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..991c55ec835ec27227bf3908e9d3557494d19b57 --- /dev/null +++ b/Testing/Data/overlap_faces/overlap_faces_0_0.vtp.sha512 @@ -0,0 +1 @@ +1a4f71ffcd5b4affe75447f01eb811936c0b5c72b63f6d1ffac7898699d5b6e435f3127e0b507f0a6407e047177f651400e94aa27f98c84d9fe620daf37cc0f7 diff --git a/Testing/Data/overlap_faces/overlap_faces_1_0.vtp.sha512 b/Testing/Data/overlap_faces/overlap_faces_1_0.vtp.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..9940f2a011ac253e07dee7549a3a5e57cb92f0f6 --- /dev/null +++ b/Testing/Data/overlap_faces/overlap_faces_1_0.vtp.sha512 @@ -0,0 +1 @@ +83f1f8ea810227c728a194e392ed464c8fcbd07f38427749136fdcf8c561b6919b1d2f334113bf67cf05086a94148b1e4f8b243d87ac677ef4b23dc5de273215 diff --git a/Testing/Data/overlap_faces/overlap_faces_2_0.vtp.sha512 b/Testing/Data/overlap_faces/overlap_faces_2_0.vtp.sha512 new file mode 100644 index 0000000000000000000000000000000000000000..02a617360d0d9edf68a63ca1fb3344cfa843109e --- /dev/null +++ b/Testing/Data/overlap_faces/overlap_faces_2_0.vtp.sha512 @@ -0,0 +1 @@ +4cc78a1e91fe9a6bc4d004457de40aae709c28ea0a98ee6ddb9353bcec164d1bc4ffb028f59a6e445840672011647ff3f6f7e881fcecb7f3079cb84d5ea6fbf3