Skip to content
Snippets Groups Projects
Commit d7f1dbbf authored by Nicolas Vuaille's avatar Nicolas Vuaille
Browse files

Add DegeneratedCell Test

With previous behavior, one boundary face was not extracted so
we saw the "interior" of the mesh. Thus coloring backface makes
the failure obvious.
parent 04952f01
No related branches found
No related tags found
No related merge requests found
vtk_module_test_data(
Data/degenerated-hexahedrons.vtu
Data/explicitStructuredGrid.vtu
Data/ghost_cells.vtu
Data/quadraticTetra01.vtu
......
......@@ -7,6 +7,7 @@ vtk_add_test_cxx(vtkFiltersGeometryCxxTests tests
TestExplicitStructuredGridSurfaceFilter.cxx
TestExtractSurfaceNonLinearSubdivision.cxx
TestFastUnstructuredGridWithPolyDataGeometryFilter.cxx,NO_DATA
TestGeometryFilterDegeneratedCells.cxx
TestImageDataToUniformGrid.cxx,NO_VALID
TestLinearToQuadraticCellsFilter.cxx
TestProjectSphereFilter.cxx,NO_VALID
......@@ -31,4 +32,6 @@ set(all_tests
${tests}
${no_data_tests}
)
vtk_test_cxx_executable(vtkFiltersGeometryCxxTests all_tests)
vtk_test_cxx_executable(vtkFiltersGeometryCxxTests all_tests
RENDERING_FACTORY
)
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* Test the vtkGeometryFilter on degenerated cells.
*
* By degenerated cell we mean here a "cell that is defined using a same point several time".
* This was found as a community workaround to store tetrahedron as hexahedron.
* https://discourse.paraview.org/t/paraview-versions-greater-5-11-fail-to-display-all-mesh-elements/15810
*
* While this is not supported in VTK, the vtkGeometryFilter used to provide
* an acceptable output when computing the external surface, as for Rendering purpose:
* external faces are correctly extracted (but a lot of *inner* faces too).
*
* This test uses a dataset made of 2 tetrahedron stored as hexahedron.
* They are rendered with white faces and red backfaces: a missing
* face should make some backface visible. Also test the number of produced faces.
*
* See more discussion on https://gitlab.kitware.com/vtk/vtk/-/issues/19600
*/
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkGeometryFilter.h"
#include "vtkLogger.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestUtilities.h"
#include "vtkXMLUnstructuredGridReader.h"
int TestGeometryFilterDegeneratedCells(int argc, char* argv[])
{
char* filename =
vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/degenerated-hexahedrons.vtu");
vtkNew<vtkXMLUnstructuredGridReader> reader;
reader->SetFileName(filename);
delete[] filename;
vtkNew<vtkGeometryFilter> geomFilter;
geomFilter->SetInputConnection(reader->GetOutputPort());
geomFilter->Update();
auto out = geomFilter->GetOutput();
if (out->GetNumberOfCells() != 12)
{
vtkLog(
ERROR, "wrong number of output cells. Has " << out->GetNumberOfCells() << " but expects 12");
}
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(geomFilter->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
// red backfaces to detect missing external face.
vtkNew<vtkProperty> backfaceProp;
backfaceProp->SetColor(255, 0, 0);
actor->SetBackfaceProperty(backfaceProp);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
vtkNew<vtkRenderWindow> win;
win->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(win);
win->Render();
// orient to catch the regression from 4a46c5dd
vtkCamera* cam = renderer->GetActiveCamera();
cam->Azimuth(-90);
interactor->Start();
return EXIT_SUCCESS;
}
390f1e583d1471378e78df5575c790e1be830794c95cf35ee4c11bf277cd458aaef0f7bc41077d400c3e73cc19b5fd4d19c7a27b0851ba542aa29c7c52d29f1b
fbd1fe5cc695ab886e88f0e8da2542cf973a09200957b27dd5c139696ce7e1f98323fb9d534613b98d885310ad9903088cb6ec64f9279a74b0994853a7da2cef
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