From af0f42fedfb1da53fe890c702ba2d060d3e64201 Mon Sep 17 00:00:00 2001 From: giorgiomarcias Date: Fri, 17 Oct 2014 08:54:34 +0000 Subject: [PATCH] "public"-ized some previously "private" static method which are useful also outside. Added a "PC_OTHER" result code for user-defined purposes. --- .../algorithms/polygon_polychord_collapse.h | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/vcg/complex/algorithms/polygon_polychord_collapse.h b/vcg/complex/algorithms/polygon_polychord_collapse.h index 97b7571e..582da069 100644 --- a/vcg/complex/algorithms/polygon_polychord_collapse.h +++ b/vcg/complex/algorithms/polygon_polychord_collapse.h @@ -69,7 +69,8 @@ public: PC_NOLINKCOND = 4, PC_SINGBOTH = 8, PC_SELFINTERSECT = 16, - PC_VOID = 32 + PC_VOID = 32, + PC_OTHER = 64 }; /** @@ -1061,24 +1062,6 @@ public: } } -private: - /** - * @brief IsVertexAdjacentToAnyNonManifoldEdge checks if a vertex is adjacent to any non-manifold edge. - * @param pos The starting position. - * @return true if adjacent to non-manifold edges, false otherwise. - */ - static bool IsVertexAdjacentToAnyNonManifoldEdge (const vcg::face::Pos &pos) { - assert(!pos.IsNull()); - vcg::face::JumpingPos jmpPos; - jmpPos.Set(pos.F(), pos.E(), pos.V()); - do { - if (!jmpPos.IsManifold()) - return true; - jmpPos.NextFE(); - } while (jmpPos != pos); - return false; - } - /** * @brief CheckPolychordFindStartPosition checks if it's a collapsable polychord. * @param pos Input The starting position. @@ -1191,62 +1174,6 @@ private: return PC_SUCCESS; } - /** - * @brief IsPolychordSelfIntersecting checks if the input polychord intersects itself. - * @warning Don't call this function without being sure that it's a polychord - * (i.e. call CheckPolychordFindStartPoint() before calling IsPolychordSelfIntersecting(). - * @param mesh The mesh used for getting the face index. - * @param startPos The starting position. - * @param chords The vector of chords. - * @param mark The current mark, used to identify quads already visited. - * @return true if it intersects itself, false otherwise. - */ - static bool IsPolychordSelfIntersecting (const PolyMeshType &mesh, - const vcg::face::Pos &startPos, - const PC_Chords &chords, - const unsigned long mark) { - assert(!startPos.IsNull()); - vcg::face::Pos runPos = startPos; - vcg::face::Pos tmpPos; - std::pair face_edge(std::numeric_limits::max(), 0); - do { - assert(runPos.F()->VN() == 4); - // check if we've already crossed this face - face_edge.first = vcg::tri::Index(mesh, runPos.F()); - face_edge.second = (runPos.E()+1)%2; - if (chords[face_edge].mark == mark) - return true; - // if this coord is adjacent to another coord of the same polychord - // i.e., this polychord touches itself without intersecting - // it might cause a wrong collapse, producing holes and non-2manifoldness - tmpPos = runPos; - tmpPos.FlipE(); - if (!tmpPos.IsBorder()) { - tmpPos.FlipF(); - face_edge.first = vcg::tri::Index(mesh, tmpPos.F()); - face_edge.second = (tmpPos.E()+1)%2; - if (chords[face_edge].mark == mark) - return true; - } - tmpPos = runPos; - tmpPos.FlipV(); - tmpPos.FlipE(); - if (!tmpPos.IsBorder()) { - tmpPos.FlipF(); - face_edge.first = vcg::tri::Index(mesh, tmpPos.F()); - face_edge.second = (tmpPos.E()+1)%2; - if (chords[face_edge].mark == mark) - return true; - } - runPos.FlipE(); - runPos.FlipV(); - runPos.FlipE(); - runPos.FlipF(); - } while (runPos != startPos && !runPos.IsBorder()); - - return false; - } - /** * @brief VisitPolychord updates the information of a polychord. * @param mesh The mesh used for getting the face index. @@ -1303,6 +1230,79 @@ private: assert(runPos == startPos || vcg::face::IsBorder(*startPos.F(),startPos.E()) || runPos.F()->VN() != 4 || startPos.FFlip()->VN() != 4); } + + /** + * @brief IsVertexAdjacentToAnyNonManifoldEdge checks if a vertex is adjacent to any non-manifold edge. + * @param pos The starting position. + * @return true if adjacent to non-manifold edges, false otherwise. + */ + static bool IsVertexAdjacentToAnyNonManifoldEdge (const vcg::face::Pos &pos) { + assert(!pos.IsNull()); + vcg::face::JumpingPos jmpPos; + jmpPos.Set(pos.F(), pos.E(), pos.V()); + do { + if (!jmpPos.IsManifold()) + return true; + jmpPos.NextFE(); + } while (jmpPos != pos); + return false; + } + + /** + * @brief IsPolychordSelfIntersecting checks if the input polychord intersects itself. + * @warning Don't call this function without being sure that it's a polychord + * (i.e. call CheckPolychordFindStartPoint() before calling IsPolychordSelfIntersecting(). + * @param mesh The mesh used for getting the face index. + * @param startPos The starting position. + * @param chords The vector of chords. + * @param mark The current mark, used to identify quads already visited. + * @return true if it intersects itself, false otherwise. + */ + static bool IsPolychordSelfIntersecting (const PolyMeshType &mesh, + const vcg::face::Pos &startPos, + const PC_Chords &chords, + const unsigned long mark) { + assert(!startPos.IsNull()); + vcg::face::Pos runPos = startPos; + vcg::face::Pos tmpPos; + std::pair face_edge(std::numeric_limits::max(), 0); + do { + assert(runPos.F()->VN() == 4); + // check if we've already crossed this face + face_edge.first = vcg::tri::Index(mesh, runPos.F()); + face_edge.second = (runPos.E()+1)%2; + if (chords[face_edge].mark == mark) + return true; + // if this coord is adjacent to another coord of the same polychord + // i.e., this polychord touches itself without intersecting + // it might cause a wrong collapse, producing holes and non-2manifoldness + tmpPos = runPos; + tmpPos.FlipE(); + if (!tmpPos.IsBorder()) { + tmpPos.FlipF(); + face_edge.first = vcg::tri::Index(mesh, tmpPos.F()); + face_edge.second = (tmpPos.E()+1)%2; + if (chords[face_edge].mark == mark) + return true; + } + tmpPos = runPos; + tmpPos.FlipV(); + tmpPos.FlipE(); + if (!tmpPos.IsBorder()) { + tmpPos.FlipF(); + face_edge.first = vcg::tri::Index(mesh, tmpPos.F()); + face_edge.second = (tmpPos.E()+1)%2; + if (chords[face_edge].mark == mark) + return true; + } + runPos.FlipE(); + runPos.FlipV(); + runPos.FlipE(); + runPos.FlipF(); + } while (runPos != startPos && !runPos.IsBorder()); + + return false; + } }; }