diff --git a/CDT/include/CDTUtils.h b/CDT/include/CDTUtils.h index f7a4cde..bb320ae 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 0e52e25..cf80d66 100644 --- a/CDT/include/Triangulation.h +++ b/CDT/include/Triangulation.h @@ -523,15 +523,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 59a666e..0357ed2 100644 --- a/CDT/include/Triangulation.hpp +++ b/CDT/include/Triangulation.hpp @@ -1283,24 +1283,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) || @@ -1313,18 +1310,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); @@ -1335,8 +1331,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, @@ -1345,9 +1341,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())) { @@ -1358,9 +1354,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 { @@ -1417,7 +1413,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) { @@ -1432,7 +1428,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)); @@ -2279,10 +2275,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) @@ -2312,7 +2308,7 @@ void Triangulation::refineTriangles( const Triangle& t = triangles[iT]; badTriangles.pop(); if(!isRefinementNeeded(t, refinementCriterion, refinementThreshold) || - newVertBudget == 0) + remainingVertexBudget == 0) { continue; } @@ -2328,7 +2324,7 @@ void Triangulation::refineTriangles( const TriIndVec badTris = resolveEncroachedEdges( detectEncroachedEdges(vert), - newVertBudget, + remainingVertexBudget, steinerVerticesOffset, &vert, refinementCriterion, @@ -2338,7 +2334,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);