diff --git a/include/Algo/Geometry/area.hpp b/include/Algo/Geometry/area.hpp index ccf101d6e5bd5c80e9d0d954045196cf7c13b020..d38e13f0fa5dd8c75f072432aedf51a89fe97b54 100644 --- a/include/Algo/Geometry/area.hpp +++ b/include/Algo/Geometry/area.hpp @@ -51,7 +51,7 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename { typedef typename PFP::VEC3 VEC3 ; - if(map.isFaceTriangle(d)) + if(map.faceDegree(d) == 3) return triangleArea(map, d, position) ; else { diff --git a/include/Algo/Geometry/normal.hpp b/include/Algo/Geometry/normal.hpp index 194b5ce98318b8ef65ffe1e5aa745a469505f5a8..ed9d3c383097bf3cde00e06eb1f382442406b952 100644 --- a/include/Algo/Geometry/normal.hpp +++ b/include/Algo/Geometry/normal.hpp @@ -69,7 +69,7 @@ typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename P template typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) { - if(map.isFaceTriangle(d)) + if(map.faceDegree(d) == 3) return triangleNormal(map, d, position) ; else return newellNormal(map, d, position) ; diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index a47ef64cc59d4e27ab08a230512090a2291b5fbb..6cbb3d4096f054f604a3d49ca4946f50c9b917b8 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -423,7 +423,7 @@ Dart Polyhedron::cylinder_topo(int n, int z, bool top_closed, bool bottom_c if(m_map.closeHole(d,false)) { d = m_map.phi2(d); - if(!m_map.isFaceTriangle(d)) + if(m_map.faceDegree(d) > 3) { Algo::Modelisation::trianguleFace(m_map,d); @@ -452,7 +452,7 @@ Dart Polyhedron::cylinder_topo(int n, int z, bool top_closed, bool bottom_c if(m_map.closeHole(d,true)) { d = m_map.phi2(d); - if(!m_map.isFaceTriangle(d)) + if(m_map.faceDegree(d) > 3) { Algo::Modelisation::trianguleFace(m_map,d); diff --git a/include/Topology/map/embeddedMap2.h b/include/Topology/map/embeddedMap2.h index 290c211d747288cff8dae80b57e9dc4146fc1af3..134aaf37d4e39268012550f5128396bd337071a1 100644 --- a/include/Topology/map/embeddedMap2.h +++ b/include/Topology/map/embeddedMap2.h @@ -50,12 +50,6 @@ public: */ virtual bool deleteVertex(Dart d) ; - /** - * No attribute is attached to the new edge - * The attributes attached to the face of dart d are kept on the resulting face - */ - virtual void linkVertices(Dart d, Dart e) ; - /** * No attribute is attached to the new vertex * The attributes attached to the old edge are duplicated on both resulting edges @@ -91,23 +85,23 @@ public: */ virtual bool flipBackEdge(Dart d) ; - /** - * The attributes attached to the vertex of dart d are kept on the resulting vertex - * The attributes attached to the face of dart d are overwritten on the face of dart e - */ - virtual void insertEdgeInVertex(Dart d, Dart e); - - /** - * The attributes attached to the vertex of dart d are kept on the resulting vertex - * The attributes attached to the face of dart d are overwritten on the face of dart e - */ - virtual void removeEdgeFromVertex(Dart d); +// /** +// * The attributes attached to the vertex of dart d are kept on the resulting vertex +// * The attributes attached to the face of dart d are overwritten on the face of dart e +// */ +// virtual void insertEdgeInVertex(Dart d, Dart e); +// +// /** +// * The attributes attached to the vertex of dart d are kept on the resulting vertex +// * The attributes attached to the face of dart d are overwritten on the face of dart e +// */ +// virtual void removeEdgeFromVertex(Dart d); /** * The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge * The attributes attached to the edge of d are kept on the resulting edge */ - virtual void sewFaces(Dart d, Dart e, bool withBoundary=true) ; + virtual void sewFaces(Dart d, Dart e, bool withBoundary = true) ; /** * The attributes attached to the vertices of the old edge of d are duplicated on the vertices of both resulting edges diff --git a/include/Topology/map/map1.h b/include/Topology/map/map1.h index 3686f834a4eb8ad52683faccd3d58993d281870e..6f7c93db23fa26088e8a378d550adabf153d121e 100644 --- a/include/Topology/map/map1.h +++ b/include/Topology/map/map1.h @@ -111,7 +111,7 @@ public: /*! @param nbEdges the number of edges * @return return a dart of the face */ - Dart newBoundaryCycle(unsigned nbEdges); + Dart newBoundaryCycle(unsigned int nbEdges); //! Delete an oriented face erasing all its darts /*! @param d a dart of the face @@ -125,44 +125,43 @@ public: *************************************************************************/ //@{ - //! Cut an edge inserting a new dart between d and its successor in the face + //! Cut an edge inserting a new dart between d and its successor in the cycle /*! @param d the edge to cut * \image hmtl map1_cutEdge.png */ void cutEdge(Dart d); - //! Collapse an edge of a face + //! Collapse an edge of a cycle /*! \warning Dart d no longer exists after the call * @param d the edge */ void collapseEdge(Dart d); - //! Split a face between vertices d and e + //! Split a cycle between vertices d and e /*! \pre Dart d and e MUST be different and belong to the same face * @param d first dart in the face * @param e second dart in the face */ - void splitFace(Dart d, Dart e); + void splitCycle(Dart d, Dart e); - //! Link two vertices belonging to distinct faces (add an edge between the two vertices) - /*! \pre Dart d and e MUST be different and belong to distinct face - * @param d first dart in the face - * @param e second dart in the face - */ - void linkVertices(Dart d, Dart e); - - //! Merge the two faces of d and e, darts d & e disappear + //! Merge two cycles on vertices d and e /*! \pre Dart d and e MUST belong to distinct faces - * \warning Darts d and e no longer exist after the call * @param d a dart in the first face * @param e a dart in the second face */ - void mergeFaces(Dart d, Dart e); + void mergeCycles(Dart d, Dart e); + + //! Link two vertices belonging to distinct cycles (add an edge between the two vertices) + /*! \pre Dart d and e MUST be different and belong to distinct face + * @param d first dart in the face + * @param e second dart in the face + */ + void linkCycles(Dart d, Dart e); //! reverse a face (phi1 become phi_1 and ...) /*! @param d a dart of face */ - void reverseFace(Dart d) ; + void reverseCycle(Dart d) ; //@} /*! @name Topological Queries @@ -170,29 +169,23 @@ public: *************************************************************************/ //@{ - //! Test if dart d and e belong to the same oriented face + //! Test if darts d and e belong to the same cycle /*! @param d a dart * @param e a dart */ - bool sameOrientedFace(Dart d, Dart e) ; + bool sameCycle(Dart d, Dart e) ; - //! Test if dart d and e belong to the same face - /*! @param d a dart - * @param e a dart + //! Length of a cycle (its number of oriented edges) + /*! @param d a dart of the cycle + * @return the length of the cycle */ - bool sameFace(Dart d, Dart e) ; - - //! Length of a face (its number of oriented edges) - /*! @param d a dart of the face - * @return the length of the face - */ - unsigned int faceDegree(Dart d) ; + unsigned int cycleDegree(Dart d) ; /** - * check if the face of d is a triangle - * @return a boolean indicating if the face is a triangle + * check if the cycle of d is a triangle + * @return a boolean indicating if the cycle is a triangle */ - bool isFaceTriangle(Dart d); + bool isCycleTriangle(Dart d); //@} /*! @name Cell Functors @@ -204,33 +197,37 @@ public: /*! @param d a dart of the vertex * @param f the functor to apply */ - bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread=0); + bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0); //! Apply a functor on every dart of an edge /*! @param d a dart of the edge * @param f the functor to apply */ - bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread=0); + bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0); //! Apply a functor on every dart of an oriented face /*! @param d a dart of the face * @param f the functor to apply */ - bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread=0) ; + bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0) ; - bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread=0); + //! Apply a functor on every dart of a face + /*! @param d a dart of the face + * @param f the functor to apply + */ + bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0); //! Apply a functor on every dart of a volume /*! @param d a dart of the volume * @param f the functor to apply */ - bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread=0); + bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0); //! Apply a functor on every dart of a connected component - /*! @param d a dart of the onnected component + /*! @param d a dart of the connected component * @param f the functor to apply */ - bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread=0); + bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0); //@} } ; diff --git a/include/Topology/map/map1.hpp b/include/Topology/map/map1.hpp index eb92a290e7ad7d9040fe48a272d1d93c9d6d4bce..dae307234a5805110ac6b882f28a6251dfe2d033 100644 --- a/include/Topology/map/map1.hpp +++ b/include/Topology/map/map1.hpp @@ -151,37 +151,57 @@ inline void Map1::collapseEdge(Dart d) deleteDart(d) ; // Dart d is erased } -inline void Map1::splitFace(Dart d, Dart e) +inline void Map1::splitCycle(Dart d, Dart e) { - assert(d != e && sameOrientedFace(d, e)) ; - Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d) - Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e) - phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts + assert(d != e && sameCycle(d, e)) ; + phi1sew(phi_1(d), phi_1(e)) ; } -inline void Map1::linkVertices(Dart d, Dart e) +inline void Map1::mergeCycles(Dart d, Dart e) { - assert(d != e && !sameOrientedFace(d, e)) ; - Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d) - Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e) - phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts + assert(!sameCycle(d, e)) ; + phi1sew(phi_1(d), phi_1(e)) ; } -inline void Map1::mergeFaces(Dart d, Dart e) +inline void Map1::linkCycles(Dart d, Dart e) { - assert(!sameOrientedFace(d, e)) ; - phi1sew(d, phi_1(e)) ; - phi1sew(e, phi_1(d)) ; - deleteCycle(d) ; + assert(d != e && !sameCycle(d, e)) ; + Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d) + Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e) + phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts } /*! @name Topological Queries * Return or set various topological information *************************************************************************/ -inline bool Map1::sameFace(Dart d, Dart e) +inline bool Map1::sameCycle(Dart d, Dart e) { - return sameOrientedFace(d, e) ; + Dart it = d ; + do + { + if(it == e) + return true ; + it = phi1(it) ; + } while(it != d) ; + return false ; +} + +inline unsigned int Map1::cycleDegree(Dart d) +{ + unsigned int count = 0 ; + Dart it = d ; + do + { + ++count ; + it = phi1(it) ; + } while (it != d) ; + return count ; +} + +inline bool Map1::isCycleTriangle(Dart d) +{ + return (phi1(d) != d) && (phi1(phi1(phi1(d))) == d) ; } /*! @name Cell Functors @@ -198,6 +218,18 @@ inline bool Map1::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thre return f(d) ; } +inline bool Map1::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread) +{ + Dart it = d ; + do + { + if (f(it)) + return true ; + it = phi1(it) ; + } while (it != d) ; + return false ; +} + inline bool Map1::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread) { return foreach_dart_of_oriented_face(d, f, thread) ; diff --git a/include/Topology/map/map2.h b/include/Topology/map/map2.h index 98392283a1a45e4ee86dec13d93beb60d8195d04..20d9efcb697f8ca65659a1b94da37fd7ff507968 100644 --- a/include/Topology/map/map2.h +++ b/include/Topology/map/map2.h @@ -99,15 +99,15 @@ protected: * Function used to merge boundary faces properly *************************************************************************/ - //! merge a face that has been tag as boundary with existing boundary if needed - /* @param d a dart of the face - */ - void mergeFaceWithBoundary(Dart d); +// /** +// * merge two faces of boundary +// */ +// void mergeBoundaryFaces(Dart dd, Dart ee); - /** - * merge two faces of boundary - */ - void mergeBoundaryFaces(Dart dd, Dart ee); +// //! merge a face that has been tag as boundary with existing boundary if needed +// /* @param d a dart of the face +// */ +// void mergeFaceWithBoundary(Dart d); /*! @name Generator and Deletor * To generate or delete faces in a 2-map @@ -122,14 +122,18 @@ public: * @param withBoudary create the face and its boundary (default true) * @return return a dart of the face */ - virtual Dart newFace(unsigned int nbEdges, bool withBoundary=true) ; + virtual Dart newFace(unsigned int nbEdges, bool withBoundary = true) ; - //! Delete an oriented face erasing all its darts (not really tags as boundary). - /*! The phi2-links around the face are removed - * @param d a dart of the face + //! Delete the face of d + /*! @param d a dart of the face */ virtual void deleteFace(Dart d) ; + //! Fill a hole with a face + /*! \pre Dart d is boundary marked + * @param d a dart of the face to fill + */ + virtual void fillHole(Dart d) ; //@} /*! @name Topological Operators @@ -152,13 +156,6 @@ public: */ virtual bool deleteVertex(Dart d); - //! Link two vertices belonging to distinct faces (add an edge between the two vertices) - /*! \pre Dart d and e MUST be different and belong to distinct face - * @param d first dart in the face - * @param e second dart in the face - */ - virtual void linkVertices(Dart d, Dart e); //TODO remove ?? - //! Cut the edge of d by inserting a new vertex /*! @param d a dart of the edge to cut */ @@ -198,27 +195,28 @@ public: */ virtual bool flipBackEdge(Dart d); - //! Insert an edge after a dart in the vertex orbit - /*! \pre Dart d and e MUST be different and belong to distinct face - * \pre Dart e must be phi2-linked with its phi_1 dart - * @param d dart of the vertex - * @param e dart of the edge - */ - virtual void insertEdgeInVertex(Dart d, Dart e); - - //! Remove an edge from a vertex orbit - /*! \pre Dart d must be phi2 sewn - * @param d the dart of the edge to remove from the vertex - */ - virtual void removeEdgeFromVertex(Dart d); +// //! Insert an edge after a dart in the vertex orbit +// /*! \pre Dart d and e MUST be different and belong to distinct face +// * \pre Dart e must be phi2-linked with its phi_1 dart +// * @param d dart of the vertex +// * @param e dart of the edge +// */ +// virtual void insertEdgeInVertex(Dart d, Dart e); +// +// //! Remove an edge from a vertex orbit +// /*! \pre Dart d must be phi2 sewed +// * @param d the dart of the edge to remove from the vertex +// * @return true if the removal has been executed, false otherwise +// */ +// virtual bool removeEdgeFromVertex(Dart d); //! Sew two oriented faces along oriented edges /*! \pre Edges of darts d & e MUST be boundary edges * @param d a dart of the first face * @param e a dart of the second face - * @param withBoundary: face have no fixed points (false only for construction: import/primitives) + * @param withBoundary: if false, faces have phi2 fixed points (only for construction: import/primitives) */ - virtual void sewFaces(Dart d, Dart e, bool withBoundary=true); + virtual void sewFaces(Dart d, Dart e, bool withBoundary = true); //! Unsew two oriented faces along oriented edges /*! @param d a dart of one face @@ -262,19 +260,11 @@ public: void insertTrianglePair(Dart d, Dart v1, Dart v2) ; /** - * Unsew the faces consisting of the umbrella of a vertex - * \warning Darts may have + * Unsew the faces of the umbrella of the vertex of d * @param d a dart from the vertex */ void unsewAroundVertex(Dart d) ; - /** - * Unsew the Umbrella aroud a vertex, close the hole and then - * create a symetric to construct a polyedron - * @param d a dart from the vertex - */ -// void explodPolyhedron(Dart d); //TODO modification for new boundary managing method ??? - //! Merge two volumes along two faces. /*! Works only if the two faces have the same number of edges. * The faces adjacent to the two given faces are pairwise phi2-linked @@ -311,11 +301,22 @@ public: */ bool sameVertex(Dart d, Dart e) ; + //! Test if dart d and e belong to the same face + /*! @param d a dart + * @param e a dart + */ + bool sameFace(Dart d, Dart e) ; + /** * compute the number of edges of the vertex of d */ unsigned int vertexDegree(Dart d) ; + /** + * compute the number of edges of the face of d + */ + unsigned int faceDegree(Dart d) ; + /** * compute the number of faces in the volume of d */ @@ -420,7 +421,7 @@ public: * @param forboundary tag the created face as boundary (default is true) * @return the degree of the created face */ - virtual unsigned int closeHole(Dart d, bool forboundary=true); + virtual unsigned int closeHole(Dart d, bool forboundary = true); //! Close the map removing topological holes: DO NOT USE, only for import algorithm /*! Add faces to the map that close every existing hole. diff --git a/include/Topology/map/map2.hpp b/include/Topology/map/map2.hpp index 9e5d2aa9619ae4c88eab18c798defb3ef321f1bb..7734505353f9602ec051004170a0d55a0e20b571 100644 --- a/include/Topology/map/map2.hpp +++ b/include/Topology/map/map2.hpp @@ -101,48 +101,11 @@ inline Dart Map2::alpha1(Dart d) return phi2(phi_1(d)) ; } -// alpha1 avec bord: bye bye -//inline Dart Map2::alpha1(Dart d) -//{ -// Dart e = phi_1(d); -// Dart f = phi2(e); -// -// if (f != e) -// return f; -// -// f = d; -// e = phi2(f); -// while (e != f) -// { -// f = phi1(e); -// e = phi2(f); -// } -// return f; -//} - inline Dart Map2::alpha_1(Dart d) { return phi1(phi2(d)) ; } -// alpha_1 avec bord : bye bye !! -//inline Dart Map2::alpha_1(Dart d) -//{ -// Dart e = phi2(d); -// -// if (e != d) -// return phi1(e); -// -// e = d; -// Dart f = phi_1(d); -// while (phi2(f) != f) -// { -// e = phi2(f); -// f = phi_1(e); -// } -// return e; -//} - inline void Map2::phi2sew(Dart d, Dart e) { assert((*m_phi2)[d.index] == d) ; @@ -158,7 +121,6 @@ inline void Map2::phi2unsew(Dart d) (*m_phi2)[e.index] = e ; } - /*! @name Topological Queries * Return or set various topological information *************************************************************************/ @@ -168,6 +130,16 @@ inline bool Map2::sameVertex(Dart d, Dart e) return sameOrientedVertex(d, e) ; } +inline bool Map2::sameFace(Dart d, Dart e) +{ + return Map1::sameCycle(d, e) ; +} + +inline unsigned int Map2::faceDegree(Dart d) +{ + return Map1::cycleDegree(d) ; +} + /*! @name Cell Functors * Apply functors to all darts of a cell *************************************************************************/ diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 7967fb01338bfaf89c7bad06ed2e85ccfc3729ea..f574340f1238f6fc8eaa5e3ba7bb8cdaf4d53c3e 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -630,33 +630,14 @@ bool GenericMap::foreach_dart_of_orbit(unsigned int orbit, Dart d, FunctorType& bool GenericMap::foreach_orbit(unsigned int orbit, FunctorType& fonct, const FunctorSelect& good, unsigned int thread) { TraversorCell trav(*this, orbit, good, thread); - bool found = false; // Store the result + bool found = false; for (Dart d = trav.begin(); !found && d != trav.end(); d = trav.next()) { - if ((fonct)(d)) // Apply functor + if ((fonct)(d)) found = true; } return found; - -// DartMarker marker(*this, thread); // Lock a marker -// bool found = false; // Store the result -// -// // Scan all darts of the map -// for (Dart d = begin(); !found && d != end(); next(d)) -// { -// if (good(d)) // If d is selected -// { -// if (!marker.isMarked(d)) // If d is in a not yet visited cell -// { -// if ((fonct)(d)) // Apply functor -// found = true; -// else -// marker.markOrbit(orbit, d); // Mark the cell as visited -// } -// } -// } -// return found; } unsigned int GenericMap::getNbOrbits(unsigned int orbit, const FunctorSelect& good) @@ -669,28 +650,27 @@ unsigned int GenericMap::getNbOrbits(unsigned int orbit, const FunctorSelect& go void GenericMap::viewAttributesTables() { std::cout << "======================="<< std::endl; - for (unsigned int i=0; i< NB_ORBITS; ++i) + for (unsigned int i = 0; i < NB_ORBITS; ++i) { - std::cout << "ATTRIBUTE_CONTAINER "< listeNames; cont.getAttributesNames(listeNames); - for (std::vector::iterator it=listeNames.begin(); it!=listeNames.end(); ++it) - std::cout<< " " << *it << std::endl; - std::cout << "-------------------------"<< std::endl; + for (std::vector::iterator it = listeNames.begin(); it != listeNames.end(); ++it) + std::cout << " " << *it << std::endl; + std::cout << "-------------------------" << std::endl; } - std::cout << "m_embeddings: "<operator[](d.index).testMark(m_boundaryMarker); } - void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d) { FunctorMark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; foreach_dart_of_orbit(orbit, d, fm, 0) ; } - void GenericMap::boundaryUnmarkOrbit(unsigned int orbit, Dart d) { FunctorUnmark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; foreach_dart_of_orbit(orbit, d, fm, 0) ; } - void GenericMap::boundaryUnmarkAll() { AttributeContainer& cont = getAttributeContainer(DART) ; @@ -730,6 +707,4 @@ void GenericMap::boundaryUnmarkAll() m_markTables[DART][0]->operator[](i).unsetMark(m_boundaryMarker); } - - } // namespace CGoGN diff --git a/src/Topology/map/embeddedMap2.cpp b/src/Topology/map/embeddedMap2.cpp index c3461b24d49872696c067a0c1f95c86aec0364e1..f1140af7da07926859ec59c9c4a3380658a1c4e2 100644 --- a/src/Topology/map/embeddedMap2.cpp +++ b/src/Topology/map/embeddedMap2.cpp @@ -66,24 +66,6 @@ bool EmbeddedMap2::deleteVertex(Dart d) return false ; } -void EmbeddedMap2::linkVertices(Dart d, Dart e) -{ - Dart dNext = phi1(d) ; - - Map2::linkVertices(d,e); - - if (isOrbitEmbedded(VERTEX)) - { - copyDartEmbedding(VERTEX, phi_1(e), d) ; - copyDartEmbedding(VERTEX, phi_1(d), e) ; - } - - if (isOrbitEmbedded(FACE)) - { - embedOrbit(FACE, dNext, getEmbedding(FACE, dNext)) ; - } -} - void EmbeddedMap2::cutEdge(Dart d) { Map2::cutEdge(d) ; @@ -130,14 +112,14 @@ bool EmbeddedMap2::edgeCanCollapse(Dart d) if(val_v1 + val_v2 < 8 || val_v1 + val_v2 > 14) return false ; - if(isFaceTriangle(d)) + if(faceDegree(d) == 3) { if(vertexDegree(phi_1(d)) < 4) return false ; } Dart dd = phi2(d) ; - if(isFaceTriangle(dd)) + if(faceDegree(dd) == 3) { if(vertexDegree(phi_1(dd)) < 4) return false ; @@ -228,54 +210,54 @@ bool EmbeddedMap2::flipBackEdge(Dart d) return false ; } -void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) -{ - Map2::insertEdgeInVertex(d, e); - - if (isOrbitEmbedded(VERTEX)) - { - copyDartEmbedding(VERTEX, e, d) ; - } - - if (isOrbitEmbedded(FACE)) - { - if(!sameFace(d,e)) - { - embedNewCell(FACE, e); - copyCell(FACE, e, d) ; - } - else - { - embedOrbit(FACE, d, getEmbedding(FACE, d)) ; - } - } -} - -void EmbeddedMap2::removeEdgeFromVertex(Dart d) -{ - Dart dPrev = alpha_1(d); - - Map2::removeEdgeFromVertex(d); - - if (isOrbitEmbedded(VERTEX)) - { - embedNewCell(VERTEX, d); - copyCell(VERTEX, d, dPrev); - } - - if (isOrbitEmbedded(FACE)) - { - if(!sameFace(d, dPrev)) - { - embedNewCell(FACE, d); - copyCell(FACE, d, dPrev) ; - } - else - { - embedOrbit(FACE, d, getEmbedding(FACE, d)) ; - } - } -} +//void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) +//{ +// Map2::insertEdgeInVertex(d, e); +// +// if (isOrbitEmbedded(VERTEX)) +// { +// copyDartEmbedding(VERTEX, e, d) ; +// } +// +// if (isOrbitEmbedded(FACE)) +// { +// if(!sameFace(d,e)) +// { +// embedNewCell(FACE, e); +// copyCell(FACE, e, d) ; +// } +// else +// { +// embedOrbit(FACE, d, getEmbedding(FACE, d)) ; +// } +// } +//} +// +//void EmbeddedMap2::removeEdgeFromVertex(Dart d) +//{ +// Dart dPrev = alpha_1(d); +// +// Map2::removeEdgeFromVertex(d); +// +// if (isOrbitEmbedded(VERTEX)) +// { +// embedNewCell(VERTEX, d); +// copyCell(VERTEX, d, dPrev); +// } +// +// if (isOrbitEmbedded(FACE)) +// { +// if(!sameFace(d, dPrev)) +// { +// embedNewCell(FACE, d); +// copyCell(FACE, d, dPrev) ; +// } +// else +// { +// embedOrbit(FACE, d, getEmbedding(FACE, d)) ; +// } +// } +//} void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) { @@ -352,7 +334,7 @@ bool EmbeddedMap2::collapseDegeneratedFace(Dart d) { Dart e = phi2(d) ; - if(Map2::collapseDegeneratedFace(d)) + if(phi1(d) != d && Map2::collapseDegeneratedFace(d)) { if (isOrbitEmbedded(EDGE)) { @@ -438,7 +420,7 @@ bool EmbeddedMap2::mergeVolumes(Dart d, Dart e) unsigned int EmbeddedMap2::closeHole(Dart d, bool forboundary) { - unsigned int nbE = Map2::closeHole(d,forboundary) ; + unsigned int nbE = Map2::closeHole(d, forboundary) ; Dart dd = phi2(d) ; Dart f = dd ; do diff --git a/src/Topology/map/map1.cpp b/src/Topology/map/map1.cpp index 0828a8ef17645bd5111d77eead708a541f5a3418..3d374a7e94474e20a228f1f8db5477ea0d378eb6 100644 --- a/src/Topology/map/map1.cpp +++ b/src/Topology/map/map1.cpp @@ -31,7 +31,7 @@ namespace CGoGN * To generate or delete faces in a 1-map *************************************************************************/ -Dart Map1::newCycle(unsigned nbEdges) +Dart Map1::newCycle(unsigned int nbEdges) { assert(nbEdges > 0 || !"Cannot create a face with no edge") ; Dart d = newDart() ; // Create the first edge @@ -40,7 +40,7 @@ Dart Map1::newCycle(unsigned nbEdges) return d ; } -Dart Map1::newBoundaryCycle(unsigned nbEdges) +Dart Map1::newBoundaryCycle(unsigned int nbEdges) { assert(nbEdges > 0 || !"Cannot create a face with no edge") ; Dart d = newDart() ; // Create the first edge @@ -66,7 +66,7 @@ void Map1::deleteCycle(Dart d) * Topological operations on 1-maps *************************************************************************/ -void Map1::reverseFace(Dart d) +void Map1::reverseCycle(Dart d) { Dart e = phi1(d) ; // Dart e is the first edge of the new face if (e == d) return ; // Only one edge: nothing to do @@ -78,59 +78,10 @@ void Map1::reverseFace(Dart d) while (dNext != d) { phi1unsew(d) ; // Unsew the edge after d - phi1sew(e,dNext) ; // Sew it after e (thus in reverse order) + phi1sew(e, dNext) ; // Sew it after e (thus in reverse order) dNext = phi1(d) ; } - phi1sew(e,d) ; // Sew the last edge -} - -/*! @name Topological Queries - * Return or set various topological information - *************************************************************************/ - -bool Map1::sameOrientedFace(Dart d, Dart e) -{ - Dart dNext = d ; - do - { - if (dNext == e) - return true ; - dNext = phi1(dNext) ; - } while (dNext != d) ; - return false ; -} - -unsigned int Map1::faceDegree(Dart d) -{ - unsigned int count = 0 ; - Dart dNext = d ; - do - { - ++count ; - dNext = phi1(dNext) ; - } while (dNext != d) ; - return count ; -} - -bool Map1::isFaceTriangle(Dart d) -{ - return (phi1(d) != d) && (phi1(phi1(phi1(d))) == d) ; -} - -/*! @name Cell Functors - * Apply functors to all darts of a cell - *************************************************************************/ - -bool Map1::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread) -{ - Dart dNext = d ; - do - { - if (f(dNext)) - return true ; - dNext = phi1(dNext) ; - } while (dNext != d) ; - return false ; + phi1sew(e, d) ; // Sew the last edge } } // namespace CGoGN diff --git a/src/Topology/map/map2.cpp b/src/Topology/map/map2.cpp index f28c2fba7b70e864de2aa26510b172c882fba043..1a8525245af10fffb5d3028039d8cebb37802dd8 100644 --- a/src/Topology/map/map2.cpp +++ b/src/Topology/map/map2.cpp @@ -23,6 +23,7 @@ *******************************************************************************/ #include "Topology/map/map2.h" +#include "Topology/generic/traversorCell.h" namespace CGoGN { @@ -31,92 +32,104 @@ namespace CGoGN * Function used to merge boundary faces properly *************************************************************************/ -void Map2::mergeBoundaryFaces(Dart dd, Dart ee) -{ - if (ee != phi_1(dd)) - phi1sew(ee, phi_1(dd)) ; - if (dd != phi_1(ee)) - phi1sew(dd, phi_1(ee)) ; - deleteCycle(dd); -} - - - -void Map2::mergeFaceWithBoundary(Dart d) -{ - std::vector storeForLinkVertex; - std::vector storeForLinkFace; - - Dart it = d ; - do // foreach vertex/edge of face - { - Dart e = phi2(it) ; - if(isBoundaryMarked(e)) // check if connection by edge - { - storeForLinkFace.push_back(it); - storeForLinkFace.push_back(e); - } - else - { - Dart f = findBoundaryVertex(alpha1(it)); // check if connection by vertex - if (f != it) - { - storeForLinkVertex.push_back(phi_1(it)); - storeForLinkVertex.push_back(phi_1(f)); - } - } - it = phi1(it) ; - } while (it != d) ; +//void Map2::mergeBoundaryFaces(Dart dd, Dart ee) +//{ +// if (ee != phi_1(dd)) +// phi1sew(ee, phi_1(dd)) ; +// if (dd != phi_1(ee)) +// phi1sew(dd, phi_1(ee)) ; +// deleteCycle(dd); +//} - // merge by vertices - while (!storeForLinkVertex.empty()) - { - Dart a = storeForLinkVertex.back() ; - storeForLinkVertex.pop_back() ; - Dart b = storeForLinkVertex.back() ; - storeForLinkVertex.pop_back() ; - phi1sew(a, b); - } - //merge by faces - while (!storeForLinkFace.empty()) - { - Dart a = storeForLinkVertex.back() ; - storeForLinkVertex.pop_back() ; - Dart b = storeForLinkVertex.back() ; - storeForLinkVertex.pop_back() ; - mergeBoundaryFaces(a, b); - } -} +//void Map2::mergeFaceWithBoundary(Dart d) +//{ +// std::vector storeForLinkVertex; +// std::vector storeForLinkFace; +// +// Dart it = d ; +// do // foreach vertex/edge of face +// { +// Dart e = phi2(it) ; +// if(isBoundaryMarked(e)) // check if connection by edge +// { +// storeForLinkFace.push_back(it); +// storeForLinkFace.push_back(e); +// } +// else +// { +// Dart f = findBoundaryVertex(alpha1(it)); // check if connection by vertex +// if (f != it) +// { +// storeForLinkVertex.push_back(phi_1(it)); +// storeForLinkVertex.push_back(phi_1(f)); +// } +// } +// it = phi1(it) ; +// } while (it != d) ; +// +// // merge by vertices +// while (!storeForLinkVertex.empty()) +// { +// Dart a = storeForLinkVertex.back() ; +// storeForLinkVertex.pop_back() ; +// Dart b = storeForLinkVertex.back() ; +// storeForLinkVertex.pop_back() ; +// phi1sew(a, b); +// } +// //merge by faces +// while (!storeForLinkFace.empty()) +// { +// Dart a = storeForLinkVertex.back() ; +// storeForLinkVertex.pop_back() ; +// Dart b = storeForLinkVertex.back() ; +// storeForLinkVertex.pop_back() ; +// mergeBoundaryFaces(a, b); +// } +//} /*! @name Generator and Deletor * To generate or delete faces in a 2-map *************************************************************************/ -void Map2::deleteFace(Dart d) -{ - // tag face in boundary - boundaryMarkOrbit(FACE, d); - mergeFaceWithBoundary(d); -} - Dart Map2::newFace(unsigned int nbEdges, bool withBoundary) { - Dart d = newCycle(nbEdges); + Dart d = Map1::newCycle(nbEdges); if (withBoundary) { Dart e = Map1::newBoundaryCycle(nbEdges); - Dart x = d; + Dart it = d; do { - phi2sew(x,e); - x = phi1(x); + phi2sew(it, e); + it = phi1(it); e = phi_1(e); - } while (x != d); + } while (it != d); } return d; } +void Map2::deleteFace(Dart d) +{ + assert(!isBoundaryMarked(d)) ; + Dart it = d ; + do + { + if(!isBoundaryEdge(it)) + unsewFaces(it) ; + it = phi1(it) ; + } while(it != d) ; + Dart dd = phi2(d) ; + Map1::deleteCycle(d) ; + Map1::deleteCycle(dd) ; +} + +void Map2::fillHole(Dart d) +{ + assert(isBoundaryMarked(d)) ; + boundaryUnmarkOrbit(FACE, d) ; +} + /*! @name Topological Operators * Topological operations on 2-maps *************************************************************************/ @@ -147,12 +160,6 @@ bool Map2::deleteVertex(Dart d) return true ; } -void Map2::linkVertices(Dart d, Dart e) -{ - Map1::linkVertices(d, e); // Split the face - phi2sew(phi_1(d), phi_1(e)); // Sew the two resulting faces along the new edge -} - void Map2::cutEdge(Dart d) { Map1::cutEdge(d); // Cut the 1-edge of d @@ -185,7 +192,6 @@ bool Map2::uncutEdge(Dart d) return false ; } - Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces) { // Dart resV ; @@ -308,40 +314,47 @@ bool Map2::flipBackEdge(Dart d) return false ; // cannot flip a border edge } -void Map2::insertEdgeInVertex(Dart d, Dart e) -{ - assert(!sameVertex(d,e) && phi2(e) == phi_1(e)); - phi1sew(phi_1(d), phi_1(e)); -} - -void Map2::removeEdgeFromVertex(Dart d) -{ - assert(phi2(d) != d); - phi1sew(phi_1(d), phi2(d)); -} +//void Map2::insertEdgeInVertex(Dart d, Dart e) +//{ +// assert(!sameVertex(d,e) && phi2(e) == phi_1(e)); +// phi1sew(phi_1(d), phi_1(e)); +//} +// +//bool Map2::removeEdgeFromVertex(Dart d) +//{ +// if (!isBoundaryEdge(d)) +// { +// phi1sew(phi_1(d), phi2(d)) ; +// return true ; +// } +// return false ; +//} void Map2::sewFaces(Dart d, Dart e, bool withBoundary) { // if sewing with fixed points if (!withBoundary) { - assert(phi2(d) == d && phi2(e) == e); - // sewing the faces - phi2sew(d, e); - return; + assert(phi2(d) == d && phi2(e) == e) ; + phi2sew(d, e) ; + return ; } assert(isBoundaryFace(d) && isBoundaryFace(e)) ; - Dart dd = phi2(d); - Dart ee = phi2(e); + Dart dd = phi2(d) ; + Dart ee = phi2(e) ; phi2unsew(d); // unsew faces from boundary phi2unsew(e); - mergeBoundaryFaces(dd, ee); // remove boundary edge (could be a Map1::mergeFaces without assert ?) + if (ee != phi_1(dd)) + phi1sew(ee, phi_1(dd)) ; // remove the boundary edge + if (dd != phi_1(ee)) + phi1sew(dd, phi_1(ee)) ; // and properly close incident boundaries + Map1::deleteCycle(dd) ; - phi2sew(d, e); // sew the faces + phi2sew(d, e) ; // sew the faces } void Map2::unsewFaces(Dart d) @@ -349,6 +362,7 @@ void Map2::unsewFaces(Dart d) Dart dd = phi2(d); Dart e = newBoundaryCycle(2); + Dart ee = phi1(e) ; if (isBoundaryVertex(d)) { @@ -359,27 +373,34 @@ void Map2::unsewFaces(Dart d) if (isBoundaryVertex(dd)) { Dart f = findBoundaryVertex(dd); - phi1sew(phi_1(e), phi_1(f)); + phi1sew(ee, phi_1(f)); } phi2unsew(d); - // sew faces to the boundary - phi2sew(d, e); - phi2sew(dd, phi1(e)); + + phi2sew(d, e); // sew faces + phi2sew(dd, ee); // to the boundary } bool Map2::collapseDegeneratedFace(Dart d) { - Dart e = phi1(d); // Check if the face is degenerated + Dart e = phi1(d) ; // Check if the face is degenerated if (phi1(e) == d) // Yes: it contains one or two edge(s) { - Dart d2 = phi2(d); // Check opposite edges - Dart e2 = phi2(e); - if (d2 != d) phi2unsew(d); // Update phi2-links if needed - if (e2 != e) phi2unsew(e); - if (d2 != d && e2 != e) - phi2sew(d2, e2); - deleteCycle(d); // Delete the single edge or two edges of the loop + Dart d2 = phi2(d) ; // Check opposite edges + Dart e2 = phi2(e) ; + phi2unsew(d) ; + if(d != e) + { + phi2unsew(e) ; + phi2sew(d2, e2) ; + } + else + { + phi1sew(d2, phi_1(d2)) ; + Map1::deleteCycle(d2) ; + } + Map1::deleteCycle(d) ; return true ; } return false ; @@ -387,8 +408,11 @@ bool Map2::collapseDegeneratedFace(Dart d) void Map2::splitFace(Dart d, Dart e) { - Map1::splitFace(d, e); // Split the face - phi2sew(phi_1(d), phi_1(e)); // Sew the two resulting faces along the new edge + assert(d != e && sameFace(d, e)) ; + Map1::cutEdge(phi_1(d)) ; + Map1::cutEdge(phi_1(e)) ; + Map1::splitCycle(phi_1(d), phi_1(e)) ; + phi2sew(phi_1(d), phi_1(e)); } bool Map2::mergeFaces(Dart d) @@ -396,8 +420,10 @@ bool Map2::mergeFaces(Dart d) if (!isBoundaryEdge(d)) { Dart e = phi2(d) ; - phi2unsew(d); // unsew the face of d - Map1::mergeFaces(d, e); // merge the two faces along edges of d and e + phi2unsew(d) ; + Map1::mergeCycles(d, phi_1(e)) ; + Map1::mergeCycles(e, phi_1(d)) ; + Map1::deleteCycle(d) ; return true ; } return false ; @@ -405,165 +431,70 @@ bool Map2::mergeFaces(Dart d) void Map2::extractTrianglePair(Dart d) { -// assert(isFaceTriangle(d)) ; -// Dart e = phi2(d) ; -// if(e != d) -// { -// assert(isFaceTriangle(e)) ; -// Dart e1 = phi2(phi1(e)) ; -// Dart e2 = phi2(phi_1(e)) ; -// phi2unsew(e1) ; -// phi2unsew(e2) ; -// phi2sew(e1, e2) ; -// } -// Dart d1 = phi2(phi1(d)) ; -// Dart d2 = phi2(phi_1(d)) ; -// phi2unsew(d1) ; -// phi2unsew(d2) ; -// phi2sew(d1, d2) ; - - if (!isBoundaryMarked(d)) - { - assert(isFaceTriangle(d)) ; - Dart d1 = phi2(phi1(d)) ; - Dart d2 = phi2(phi_1(d)) ; - phi2unsew(d1) ; - phi2unsew(d2) ; - phi2sew(d1, d2) ; - } - Dart e = phi2(d) ; - if (!isBoundaryMarked(e)) - { - assert(isFaceTriangle(e)) ; - Dart e1 = phi2(phi1(e)) ; - Dart e2 = phi2(phi_1(e)) ; - phi2unsew(e1) ; - phi2unsew(e2) ; - phi2sew(e1, e2) ; - } + assert(!isBoundaryFace(d) && !isBoundaryFace(e)) ; + assert(faceDegree(d) == 3 && faceDegree(e) == 3) ; + + Dart d1 = phi2(phi1(d)) ; + Dart d2 = phi2(phi_1(d)) ; + phi2unsew(d1) ; + phi2unsew(d2) ; + phi2sew(d1, d2) ; + + Dart e1 = phi2(phi1(e)) ; + Dart e2 = phi2(phi_1(e)) ; + phi2unsew(e1) ; + phi2unsew(e2) ; + phi2sew(e1, e2) ; } void Map2::insertTrianglePair(Dart d, Dart v1, Dart v2) { -// assert(sameOrientedVertex(v1, v2)) ; -// assert((v1 != v2 && phi2(d) != d) || (v1 == v2 && phi2(d) == d)) ; -// assert(isFaceTriangle(d) && phi2(phi1(d)) == phi1(d) && phi2(phi_1(d)) == phi_1(d)) ; -// Dart e = phi2(d) ; -// if(e != d && v1 != v2) -// { -// assert(isFaceTriangle(e) && phi2(phi1(e)) == phi1(e) && phi2(phi_1(e)) == phi_1(e)) ; -// Dart vv2 = phi2(v2) ; -// phi2unsew(v2) ; -// phi2sew(phi_1(e), v2) ; -// phi2sew(phi1(e), vv2) ; -// } -// Dart vv1 = phi2(v1) ; -// phi2unsew(v1) ; -// phi2sew(phi_1(d), v1) ; -// phi2sew(phi1(d), vv1) ; + Dart e = phi2(d) ; + assert(v1 != v2 && sameOrientedVertex(v1, v2)) ; + assert(faceDegree(d) == 3 && faceDegree(phi2(d)) == 3) ; - assert(sameOrientedVertex(v1, v2)) ; - assert((v1 != v2 && !isBoundaryMarked(d)) || (v1 == v2 && isBoundaryMarked(d))) ; - assert(isFaceTriangle(d) && isBoundaryMarked(phi1(d)) && isBoundaryMarked(phi_1(d)) ) ; - Dart e = phi2(d) ; - if (!isBoundaryEdge(d) && v1 != v2) - { - assert( isFaceTriangle(e) && isBoundaryMarked(phi1(e)) && isBoundaryMarked(phi_1(e)) ) ; - Dart vv2 = phi2(v2) ; - phi2unsew(v2) ; - phi2sew(phi_1(e), v2) ; - phi2sew(phi1(e), vv2) ; - } Dart vv1 = phi2(v1) ; phi2unsew(v1) ; phi2sew(phi_1(d), v1) ; phi2sew(phi1(d), vv1) ; + + Dart vv2 = phi2(v2) ; + phi2unsew(v2) ; + phi2sew(phi_1(e), v2) ; + phi2sew(phi1(e), vv2) ; } void Map2::unsewAroundVertex(Dart d) { - Dart e = d; - + Dart it = d ; do { - Dart temp = phi1(e); - Dart e_1 = phi_1(e); + Dart temp = phi1(it) ; + Dart e_1 = phi_1(it) ; do { - unsewFaces(temp); - temp = phi1(temp); - }while(temp != e_1); + unsewFaces(temp) ; + temp = phi1(temp) ; + } while(temp != e_1); - e = alpha1(e); + it = alpha1(it); } - while(e != d); + while(it != d); } -//void Map2::explodPolyhedron(Dart d) -//{ -// unsewAroundVertex(d); -//// closeHole(phi1(d)); -// -// //Recherche du (ou un des) sommet oppose -// //tourner autour du sommet -// //si quad alors sommet oppose -// // -// //si pas de quad alors un sommet du trian -// -// // -//} - bool Map2::mergeVolumes(Dart d, Dart e) { -// // First traversal of both faces to check the face sizes -// // and stored their edges to efficiently access them further -// std::vector dDarts; -// std::vector eDarts; -// dDarts.reserve(16); // usual faces have less than 16 edges -// eDarts.reserve(16); -// -// Dart dFit = d ; -// Dart eFit = phi1(e) ; // must take phi1 because of the use -// do // of reverse iterator for sewing loop -// { -// dDarts.push_back(dFit) ; -// dFit = phi1(dFit) ; -// } while(dFit != d) ; -// do -// { -// eDarts.push_back(eFit) ; -// eFit = phi1(eFit) ; -// } while(eFit != phi1(e)) ; -// -// if(dDarts.size() != eDarts.size()) -// return false ; -// -// // Make the sewing: take darts in initial order (clockwise) in first face -// // and take darts in reverse order (counter-clockwise) in the second face -// std::vector::iterator dIt; -// std::vector::reverse_iterator eIt; -// for (dIt = dDarts.begin(), eIt = eDarts.rbegin(); dIt != dDarts.end(); ++dIt, ++eIt) -// { -// Dart d2 = phi2(*dIt); // Search the faces adjacent to dNext and eNext -// Dart e2 = phi2(*eIt); -// if (d2 != *dIt) phi2unsew(d2); // Unlink the two adjacent faces from dNext and eNext -// if (e2 != *eIt) phi2unsew(e2); -// if (d2 != *dIt && e2 != *eIt) phi2sew(d2,e2); // Link the two adjacent faces together if they exists -// } -// Map1::deleteOrientedFace(d); // Delete the two alone faces -// Map1::deleteOrientedFace(e); -// -// return true ; + assert(!isBoundaryMarked(d) && !isBoundaryMarked(e)) ; - if (isBoundaryMarked(d) || isBoundaryMarked(e)) + if (isBoundaryFace(d) || isBoundaryFace(e)) return false; // First traversal of both faces to check the face sizes - // and stored their edges to efficiently access them further + // and store their edges to efficiently access them further std::vector dDarts; std::vector eDarts; @@ -594,13 +525,11 @@ bool Map2::mergeVolumes(Dart d, Dart e) { Dart d2 = phi2(*dIt); // Search the faces adjacent to dNext and eNext Dart e2 = phi2(*eIt); - phi2unsew(d2); // Unlink the two adjacent faces from dNext and eNext + phi2unsew(d2); // Unlink the two adjacent faces from dNext and eNext phi2unsew(e2); - phi2sew(d2,e2); // Link the two adjacent faces together - if (isBoundaryMarked(d2) && isBoundaryMarked(e2)) - mergeBoundaryFaces(d2,e2); + phi2sew(d2, e2); // Link the two adjacent faces together } - deleteCycle(d); // Delete the two alone faces + deleteCycle(d); // Delete the two alone faces deleteCycle(e); return true ; @@ -612,74 +541,30 @@ bool Map2::mergeVolumes(Dart d, Dart e) bool Map2::sameOrientedVertex(Dart d, Dart e) { - Dart dNext = d; // Foreach dart dNext in the vertex of d + Dart it = d; // Foreach dart dNext in the vertex of d do { - if (dNext == e) // Test equality with e + if (it == e) // Test equality with e return true; - dNext = alpha1(dNext); - } while (dNext != d); + it = alpha1(it); + } while (it != d); return false; // None is equal to e => vertices are distinct } -bool Map2::sameOrientedFace(Dart d, Dart e) -{ - Dart dNext = d; - do // Foreach dart dNext in the face of d - { - if(dNext == e) // Test equality with e - return true; - dNext = phi1(dNext); - } while(dNext != d); - return false; // None is equal to e => faces are distinct -} - unsigned int Map2::vertexDegree(Dart d) { unsigned int count = 0 ; - Dart dNext = d ; + Dart it = d ; do { ++count ; - if(phi2(dNext) == dNext) - ++count ; - dNext = alpha1(dNext) ; - } while (dNext != d) ; + it = alpha1(it) ; + } while (it != d) ; return count ; } unsigned int Map2::volumeDegree(Dart d) { -// unsigned int count = 0; -// DartMarkerStore mark(*this); // Lock a marker -// -// std::vector visitedFaces; // Faces that are traversed -// visitedFaces.reserve(16); -// visitedFaces.push_back(d); // Start with the face of d -// std::vector::iterator face; -// -// // For every face added to the list -// for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face) -// { -// if (!mark.isMarked(*face)) // Face has not been visited yet -// { -// ++count; -// -// Dart dNext = *face ; -// do -// { -// mark.mark(dNext); // Mark -// Dart adj = phi2(dNext); // Get adjacent face -// if (adj != dNext && !mark.isMarked(adj)) -// visitedFaces.push_back(adj); // Add it -// dNext = phi1(dNext); -// } while(dNext != *face); -// } -// } -// -// return count; - - unsigned int count = 0; DartMarkerStore mark(*this); // Lock a marker @@ -689,27 +574,25 @@ unsigned int Map2::volumeDegree(Dart d) std::vector::iterator face; // For every face added to the list - for (unsigned int i=0; i != visitedFaces.size(); ++i) + for (unsigned int i = 0; i != visitedFaces.size(); ++i) { Dart df = visitedFaces[i]; if (!isBoundaryMarked(df) && !mark.isMarked(df)) // Face has not been visited yet { ++count; - - Dart dNext = df ; + Dart it = df ; do { - mark.mark(dNext); // Mark - Dart adj = phi2(dNext); // Get adjacent face + mark.mark(it); // Mark + Dart adj = phi2(it); // Get adjacent face if ( !isBoundaryMarked(adj) && !mark.isMarked(adj) ) - visitedFaces.push_back(adj); // Add it - dNext = phi1(dNext); - } while(dNext != df); + visitedFaces.push_back(adj);// Add it + it = phi1(it); + } while(it != df); } } return count; - } bool Map2::isBoundaryVertex(Dart d) @@ -756,18 +639,11 @@ bool Map2::isBoundaryFace(Dart d) bool Map2::isTriangular() { - DartMarker m(*this) ; - for(Dart d = begin(); d != end(); next(d)) + TraversorF t(*this) ; + for(Dart d = t.begin(); d != t.end(); d = t.next()) { - if(!m.isMarked(d)) - { - m.markOrbit(FACE, d) ; - if (!isBoundaryMarked(d)) - { - if(!isFaceTriangle(d)) - return false ; - } - } + if(faceDegree(d) != 3) + return false ; } return true ; } @@ -943,7 +819,7 @@ bool Map2::foreach_dart_of_link(Dart d, unsigned int orbit, FunctorType& f, unsi } /*! @name Close map after import or creation - * These functions must be used with care, generally only by import algorithms + * These functions must be used with care, generally only by import/creation algorithms *************************************************************************/ unsigned int Map2::closeHole(Dart d, bool forboundary) @@ -994,9 +870,7 @@ void Map2::closeMap() for (Dart d = begin(); d != end(); next(d)) { if (phi2(d) == d) - { closeHole(d); - } } } diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index 864ed1e39c1bd17e2029fb8e15bf9c2936874bec..2ee6839fd3ca98ccbf98de1a9ee63ee313358e7d 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -1263,10 +1263,10 @@ void Map3::closeMap(DartMarker& marker) bool Map3::sameFace(Dart d, Dart e) { if(phi3(d) != d) - if(Map2::sameOrientedFace(phi3(d), e)) + if(Map2::sameFace(phi3(d), e)) return true; - return Map2::sameOrientedFace(d,e); + return Map2::sameFace(d,e); } bool Map3::check()