From 01f40d5d419a9bea4c00287449b1d997d790a77d Mon Sep 17 00:00:00 2001 From: artem-ogre Date: Thu, 11 Mar 2021 14:30:58 +0100 Subject: [PATCH] #31 Fix incomplete handling of custom super-geometry --- CDT/include/CDT.h | 11 +++++++---- CDT/include/CDT.hpp | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CDT/include/CDT.h b/CDT/include/CDT.h index f40f0983..45a99ce6 100644 --- a/CDT/include/CDT.h +++ b/CDT/include/CDT.h @@ -55,11 +55,10 @@ struct CDT_EXPORT SuperGeometryType enum Enum { SuperTriangle, ///< conventional super-triangle - Custom, ///< user-specified custom geometry (e.g., grid) + Custom, ///< user-specified custom geometry (e.g., grid) }; }; - /// Constant representing no valid neighbor for a triangle const static TriInd noNeighbor(std::numeric_limits::max()); /// Constant representing no valid vertex for a triangle @@ -131,7 +130,11 @@ class CDT_EXPORT Triangulation TGetEdgeVertexEnd getEnd); /// Insert constraints (fixed edges) into triangulation void insertEdges(const std::vector& edges); - /// Erase triangles adjacent to super triangle + /** + * Erase triangles adjacent to super triangle + * + * @note does nothing if custom geometry is used + */ void eraseSuperTriangle(); /// Erase triangles outside of constrained boundary using growing void eraseOuterTriangles(); @@ -201,7 +204,7 @@ class CDT_EXPORT Triangulation TriInd addTriangle(); // note: invalidates triangle iterators! void makeDummy(const TriInd iT); void eraseDummies(); - void eraseSuperTriangleVertices(); + void eraseSuperTriangleVertices(); // no effect if custom geometry is used template void eraseTrianglesAtIndices(TriIndexIter first, TriIndexIter last); TriIndUSet growToBoundary(std::stack seeds) const; diff --git a/CDT/include/CDT.hpp b/CDT/include/CDT.hpp index 3df2d4f7..bfce9db1 100644 --- a/CDT/include/CDT.hpp +++ b/CDT/include/CDT.hpp @@ -91,6 +91,8 @@ void Triangulation::eraseDummies() template void Triangulation::eraseSuperTriangleVertices() { + if(m_superGeomType != SuperGeometryType::SuperTriangle) + return; for(TriangleVec::iterator t = triangles.begin(); t != triangles.end(); ++t) for(Index i(0); i < Index(3); ++i) t->vertices[i] -= 3; @@ -110,6 +112,8 @@ void Triangulation::eraseSuperTriangleVertices() template void Triangulation::eraseSuperTriangle() { + if(m_superGeomType != SuperGeometryType::SuperTriangle) + return; // make dummy triangles adjacent to super-triangle's vertices for(TriInd iT(0); iT < TriInd(triangles.size()); ++iT) { @@ -171,6 +175,7 @@ void Triangulation::initializedWithCustomSuperGeometry() } #endif m_nTargetVerts = vertices.size(); + m_superGeomType = SuperGeometryType::Custom; } template