Skip to content

Commit

Permalink
#7 Refactor edgeTriangle
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-ogre committed Oct 6, 2023
1 parent 02a99ef commit 248ed51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
1 change: 0 additions & 1 deletion CDT/include/Triangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,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,
Expand Down
37 changes: 8 additions & 29 deletions CDT/include/Triangulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,26 +1229,6 @@ bool Triangulation<T, TNearPointLocator>::isFlipNeeded(
return isInCircumcircle(v, v2, v3, v4);
}

template <typename T, typename TNearPointLocator>
TriInd Triangulation<T, TNearPointLocator>::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 <typename T, typename TNearPointLocator>
bool Triangulation<T, TNearPointLocator>::isRefinementNeeded(
const Triangle& tri,
Expand Down Expand Up @@ -1281,8 +1261,9 @@ EdgeQue Triangulation<T, TNearPointLocator>::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);
Expand Down Expand Up @@ -1339,13 +1320,11 @@ TriIndVec Triangulation<T, TNearPointLocator>::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];
Expand Down

0 comments on commit 248ed51

Please sign in to comment.