From 8b27b7d54881a391e5da41a79d34d65526709cf4 Mon Sep 17 00:00:00 2001 From: artem-ogre Date: Mon, 21 Aug 2023 15:15:03 +0200 Subject: [PATCH] #7 Refactor edgeTriangle --- CDT/include/Triangulation.h | 1 - CDT/include/Triangulation.hpp | 37 ++++++++--------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/CDT/include/Triangulation.h b/CDT/include/Triangulation.h index d33a630..5a80c0c 100644 --- a/CDT/include/Triangulation.h +++ b/CDT/include/Triangulation.h @@ -510,7 +510,6 @@ class CDT_EXPORT Triangulation VertInd iV2, VertInd iV3, VertInd iV4) const; - TriInd edgeTriangle(Edge edge) const; bool isRefinementNeeded( const Triangle& tri, RefinementCriterion::Enum refinementCriterion, diff --git a/CDT/include/Triangulation.hpp b/CDT/include/Triangulation.hpp index cfeafb8..0641aff 100644 --- a/CDT/include/Triangulation.hpp +++ b/CDT/include/Triangulation.hpp @@ -1234,26 +1234,6 @@ bool Triangulation::isFlipNeeded( return isInCircumcircle(v, v2, v3, v4); } -template -TriInd Triangulation::edgeTriangle(const Edge edge) const -{ - TriInd iT = invalidIndex; - const TriInd start = m_vertTris[edge.v1()]; - TriInd currTri = start; - do - { - const Triangle& t = triangles[currTri]; - if(t.next(edge.v1()).second == edge.v2()) - { - iT = currTri; - break; - } - currTri = t.next(edge.v1()).first; - } while(currTri != start); - assert(iT != invalidIndex); - return iT; -} - template bool Triangulation::isRefinementNeeded( const Triangle& tri, @@ -1286,8 +1266,9 @@ EdgeQue Triangulation::detectEncroachedEdges() ++cit) { const Edge edge = *cit; - const TriInd iT = edgeTriangle(edge); - const TriInd iTopo = edgeNeighbor(triangles[iT], edge.v1(), edge.v2()); + TriInd iT, iTopo; + std::tie(iT, iTopo) = edgeTriangles(edge.v1(), edge.v2()); + assert(iT != invalidIndex && iTopo != invalidIndex); const Triangle& t = triangles[iT]; const Triangle& tOpo = triangles[iTopo]; VertInd v1 = opposedVertex(t, iTopo); @@ -1344,13 +1325,11 @@ TriIndVec Triangulation::resolveEncroachedEdges( { continue; } - TriInd iT = edgeTriangle(edge); - const Triangle& t = triangles[iT]; - VertInd i = splitEncroachedEdge( - edge, - iT, - edgeNeighbor(triangles[iT], edge.v1(), edge.v2()), - steinerVerticesOffset); + TriInd iT, iTopo; + std::tie(iT, iTopo) = edgeTriangles(edge.v1(), edge.v2()); + assert(iT != invalidIndex && iTopo != invalidIndex); + const VertInd i = + splitEncroachedEdge(edge, iT, iTopo, steinerVerticesOffset); --newVertBudget; TriInd start = m_vertTris[i];