diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.hxx b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.hxx index ca6bedc8a30..9729d9d4e3d 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.hxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/include/itkDelaunayConformingQuadEdgeMeshFilter.hxx @@ -158,14 +158,15 @@ DelaunayConformingQuadEdgeMeshFilter::Process() const auto il_id = qe->GetLeft(); // Input Left ID const auto ir_id = qe->GetRight(); // Input Right ID qe = m_FlipEdge->Evaluate(qe); - const auto ol_id = qe->GetLeft(); // Output Left ID - const auto or_id = qe->GetRight(); // Output Right ID - - this->ReassignCellData(il_id, ol_id); - this->ReassignCellData(ir_id, or_id); if (qe != nullptr) { + const auto ol_id = qe->GetLeft(); // Output Left ID + const auto or_id = qe->GetRight(); // Output Right ID + + this->ReassignCellData(il_id, ol_id); + this->ReassignCellData(ir_id, or_id); + ++this->m_NumberOfEdgeFlips; list_qe[4] = qe; diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/itk-module.cmake b/Modules/Filtering/QuadEdgeMeshFiltering/itk-module.cmake index 410a475d355..03b711a59cf 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/itk-module.cmake +++ b/Modules/Filtering/QuadEdgeMeshFiltering/itk-module.cmake @@ -15,6 +15,7 @@ itk_module(ITKQuadEdgeMeshFiltering TEST_DEPENDS ITKTestKernel ITKIOMesh + ITKStatistics DESCRIPTION "${DOCUMENTATION}" ) diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/CMakeLists.txt b/Modules/Filtering/QuadEdgeMeshFiltering/test/CMakeLists.txt index 5ce66e9e502..62f13ae108d 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/CMakeLists.txt +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/CMakeLists.txt @@ -83,7 +83,7 @@ endforeach() itk_add_test(NAME itkDelaunayConformingQuadEdgeMeshFilterTest COMMAND ITKQuadEdgeMeshFilteringTestDriver - itkDelaunayConformingQuadEdgeMeshFilterTest DATA{${INPUTDATA}/mushroom.vtk} ${TEMP}/mushrom_delaunay.vtk) + itkDelaunayConformingQuadEdgeMeshFilterTest DATA{${INPUTDATA}/mushroom.vtk} ${TEMP}/mushroom_delaunay.vtk) itk_add_test(NAME itkCleanQuadEdgeMeshFilterTest COMMAND ITKQuadEdgeMeshFilteringTestDriver itkCleanQuadEdgeMeshFilterTest diff --git a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx index 64732562aec..07b3b0a7bf0 100644 --- a/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx +++ b/Modules/Filtering/QuadEdgeMeshFiltering/test/itkDelaunayConformingQuadEdgeMeshFilterTest.cxx @@ -19,6 +19,7 @@ #include "itkMeshFileReader.h" #include "itkMeshFileWriter.h" #include "itkQuadEdgeMesh.h" +#include "itkNormalVariateGenerator.h" // NEW #include "itkDelaunayConformingQuadEdgeMeshFilter.h" @@ -44,6 +45,20 @@ itkDelaunayConformingQuadEdgeMeshFilterTestHelper(const std::string & input, MeshType::Pointer mesh = reader->GetOutput(); + using GeneratorType = itk::Statistics::NormalVariateGenerator; + const auto generator = GeneratorType::New(); + generator->Initialize(0); + + const double sigma = 0.01; + + for (auto it = mesh->GetPoints()->Begin(); it != mesh->GetPoints()->End(); ++it) + { + for (size_t d = 0; d < MeshType::MeshTraits::PointDimension; ++d) + { + it.Value()[d] += (generator->GetVariate() * sigma); + } + } + if (cell_data) { for (auto it = mesh->GetCells()->Begin(); it != mesh->GetCells()->End(); ++it) @@ -54,16 +69,15 @@ itkDelaunayConformingQuadEdgeMeshFilterTestHelper(const std::string & input, const auto filter = DelaunayConformFilterType::New(); filter->SetInput(mesh); - filter->Update(); + ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update()); if (cell_data) { for (auto it = mesh->GetCells()->Begin(); it != mesh->GetCells()->End(); ++it) { - mesh->SetCellData(it.Index(), it.Index()); - itkAssertOrThrowMacro(mesh->GetCellData()->IndexExists(it.Index()), - "Incorrect number of cells in cell data array."); + ITK_TEST_EXPECT_TRUE(mesh->GetCellData()->IndexExists(it.Index())); } + ITK_TEST_EXPECT_EQUAL(mesh->GetNumberOfCells(), mesh->GetCellData()->Size()); } // ** WRITE OUTPUT **