diff --git a/CDT/include/CDTUtils.h b/CDT/include/CDTUtils.h index 6c301bc..065330d 100644 --- a/CDT/include/CDTUtils.h +++ b/CDT/include/CDTUtils.h @@ -244,7 +244,7 @@ inline Edge edge_make(VertInd iV1, VertInd iV2) } typedef std::vector EdgeVec; ///< Vector of edges -typedef std::queue EdgeQue; ///< Queue of edges +typedef std::queue EdgeQueue; ///< Queue of edges typedef unordered_set EdgeUSet; ///< Hash table of edges typedef unordered_set TriIndUSet; ///< Hash table of triangles typedef unordered_map TriIndUMap; ///< Triangle hash map diff --git a/CDT/include/Triangulation.h b/CDT/include/Triangulation.h index 97e76e7..eca2574 100644 --- a/CDT/include/Triangulation.h +++ b/CDT/include/Triangulation.h @@ -515,15 +515,15 @@ class CDT_EXPORT Triangulation /// Search in all fixed edges to find encroached edges, each fixed edge is /// checked against its opposite vertices /// Returns queue of encroached edges - EdgeQue detectEncroachedEdges(); + EdgeQueue detectEncroachedEdges(); /// Search in all fixed edges to find encroached edges, each fixed edge is /// checked against its opposite vertices and vertex v /// Returns queue of encroached edges - EdgeQue detectEncroachedEdges(const V2d& v); + EdgeQueue detectEncroachedEdges(const V2d& v); /// Recursively split encroached edges /// @return vector of badly shaped triangles TriIndVec resolveEncroachedEdges( - EdgeQue encroachedEdges, + EdgeQueue encroachedEdges, VertInd& newVertBudget, VertInd steinerVerticesOffset, const V2d* circumcenterOrNull = NULL, diff --git a/CDT/include/Triangulation.hpp b/CDT/include/Triangulation.hpp index 506fdee..556e7a6 100644 --- a/CDT/include/Triangulation.hpp +++ b/CDT/include/Triangulation.hpp @@ -1250,24 +1250,21 @@ bool Triangulation::isRefinementNeeded( } template -EdgeQue Triangulation::detectEncroachedEdges() +EdgeQueue Triangulation::detectEncroachedEdges() { // Search in all fixed edges to find encroached edges, each fixed edge is // checked against its opposite vertices // Returns queue of encroached edges - EdgeQue encroachedEdges; - for(EdgeUSet::const_iterator cit = fixedEdges.begin(); - cit != fixedEdges.end(); - ++cit) + EdgeQueue encroachedEdges; + typedef EdgeUSet::const_iterator Iter; + for(Iter it = fixedEdges.begin(); it != fixedEdges.end(); ++it) { - const Edge edge = *cit; + const Edge edge = *it; 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); - VertInd v2 = opposedVertex(tOpo, iT); + const VertInd v1 = opposedVertex(triangles[iT], iTopo); + const VertInd v2 = opposedVertex(triangles[iTopo], iT); const V2d& edgeStart = vertices[edge.v1()]; const V2d& edgeEnd = vertices[edge.v2()]; if(isEncroachingOnEdge(vertices[v1], edgeStart, edgeEnd) || @@ -1280,18 +1277,17 @@ EdgeQue Triangulation::detectEncroachedEdges() } template -EdgeQue +EdgeQueue Triangulation::detectEncroachedEdges(const V2d& v) { // Search in all fixed edges to find encroached edges, each fixed edge is // checked against its opposite vertices and vertex v // Returns queue of encroached edges - EdgeQue encroachedEdges; - for(EdgeUSet::const_iterator cit = fixedEdges.begin(); - cit != fixedEdges.end(); - ++cit) + EdgeQueue encroachedEdges; + typedef EdgeUSet::const_iterator Iter; + for(Iter it = fixedEdges.begin(); it != fixedEdges.end(); ++it) { - const Edge edge = *cit; + const Edge edge = *it; if(isEncroachingOnEdge(v, vertices[edge.v1()], vertices[edge.v2()])) { encroachedEdges.push(edge); @@ -1302,8 +1298,8 @@ Triangulation::detectEncroachedEdges(const V2d& v) template TriIndVec Triangulation::resolveEncroachedEdges( - EdgeQue encroachedEdges, - VertInd& newVertBudget, + EdgeQueue encroachedEdges, + VertInd& remainingVertexBudget, const VertInd steinerVerticesOffset, const V2d* const circumcenterOrNull, const RefinementCriterion::Enum refinementCriterion, @@ -1312,9 +1308,9 @@ TriIndVec Triangulation::resolveEncroachedEdges( IndexSizeType numOfSplits = 0; std::vector badTriangles; - while(!encroachedEdges.empty() && newVertBudget > 0) + while(!encroachedEdges.empty() && remainingVertexBudget > 0) { - Edge edge = encroachedEdges.front(); + const Edge edge = encroachedEdges.front(); encroachedEdges.pop(); if(!hasEdge(edge.v1(), edge.v2())) { @@ -1325,9 +1321,9 @@ TriIndVec Triangulation::resolveEncroachedEdges( assert(iT != invalidIndex && iTopo != invalidIndex); const VertInd i = splitEncroachedEdge(edge, iT, iTopo, steinerVerticesOffset); - --newVertBudget; + --remainingVertexBudget; - TriInd start = m_vertTris[i]; + const TriInd start = m_vertTris[i]; TriInd currTri = start; do { @@ -1384,7 +1380,7 @@ VertInd Triangulation::splitEncroachedEdge( // that introduces FP rounding erros, so it's avoided. const T len = distance(start, end); const T d = T(0.5) * len; - // Find the splitting distance. + // Find the splitting distance T nearestPowerOfTwo = T(1); while(d > nearestPowerOfTwo) { @@ -1399,7 +1395,7 @@ VertInd Triangulation::splitEncroachedEdge( if(splitEdge.v1() >= steinerVerticesOffset) split = T(1) - split; } - V2d mid = V2d::make( + const V2d mid = V2d::make( detail::lerp(start.x, end.x, split), detail::lerp(start.y, end.y, split)); @@ -2246,10 +2242,10 @@ void Triangulation::refineTriangles( } tryInitNearestPointLocator(); - VertInd newVertBudget = maxVerticesToInsert; + VertInd remainingVertexBudget = maxVerticesToInsert; const VertInd steinerVerticesOffset = vertices.size(); resolveEncroachedEdges( - detectEncroachedEdges(), newVertBudget, steinerVerticesOffset); + detectEncroachedEdges(), remainingVertexBudget, steinerVerticesOffset); std::queue badTriangles; for(TriInd iT(0), n = triangles.size(); iT < n; ++iT) @@ -2279,7 +2275,7 @@ void Triangulation::refineTriangles( const Triangle& t = triangles[iT]; badTriangles.pop(); if(!isRefinementNeeded(t, refinementCriterion, refinementThreshold) || - newVertBudget == 0) + remainingVertexBudget == 0) { continue; } @@ -2295,7 +2291,7 @@ void Triangulation::refineTriangles( const TriIndVec badTris = resolveEncroachedEdges( detectEncroachedEdges(vert), - newVertBudget, + remainingVertexBudget, steinerVerticesOffset, &vert, refinementCriterion, @@ -2305,7 +2301,7 @@ void Triangulation::refineTriangles( badTriangles.push(badTris[i]); } - if(badTris.empty() && newVertBudget > 0) + if(badTris.empty() && remainingVertexBudget > 0) { const VertInd iVert = static_cast(vertices.size()); addNewVertex(vert, noNeighbor);