From 3fa06872294a3088d3929282bc89b71a5b4b7744 Mon Sep 17 00:00:00 2001 From: Thomas Galland Date: Wed, 4 May 2022 16:13:06 +0200 Subject: [PATCH] Allow Delaunay to skip bad constraints --- vespa/Delaunay/vtkCGALDelaunay2.cxx | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/vespa/Delaunay/vtkCGALDelaunay2.cxx b/vespa/Delaunay/vtkCGALDelaunay2.cxx index b2b0e66..eb07aa0 100644 --- a/vespa/Delaunay/vtkCGALDelaunay2.cxx +++ b/vespa/Delaunay/vtkCGALDelaunay2.cxx @@ -98,7 +98,17 @@ int vtkCGALDelaunay2::RequestData( { poly.emplace_back(pts[p->GetId(i)]); } - delaunay.insert_constraint(poly.begin(), poly.end(), true); + try + { + delaunay.insert_constraint(poly.begin(), poly.end(), true); + } + catch(const std::exception& e) + { + // If we have an invalid constraint (for example overlaping edges) + // we just ignore the constraint and continue + vtkWarningMacro("Ill-formed constraint detected : constraint ignored."); + continue; + } } vtkCellArray* lines = input->GetLines(); @@ -113,7 +123,17 @@ int vtkCGALDelaunay2::RequestData( { line.emplace_back(pts[l->GetId(i)]); } - delaunay.insert_constraint(line.begin(), line.end()); + try + { + delaunay.insert_constraint(line.begin(), line.end()); + } + catch(const std::exception& e) + { + // If we have an invalid constraint (for example overlaping edges) + // we just ignore the constraint and continue + vtkWarningMacro("Ill-formed constraint detected : constraint ignored."); + continue; + } } // Add points -- GitLab