From 156f13bd4f01d4a1316b0beb9b2729f0ecdc6f5f Mon Sep 17 00:00:00 2001 From: untereiner Date: Thu, 8 Dec 2011 15:48:25 +0100 Subject: [PATCH] Map3 / GMap3 : deleteVertex + deleteEdge --- include/Topology/gmap/gmap3.h | 11 +++++++-- include/Topology/map/map3.h | 10 ++++---- src/Topology/gmap/gmap3.cpp | 45 ++++++++++++++++++++++++++++++++++- src/Topology/map/map3.cpp | 33 ++++++++++++------------- 4 files changed, 74 insertions(+), 25 deletions(-) diff --git a/include/Topology/gmap/gmap3.h b/include/Topology/gmap/gmap3.h index 0f3dfca0..91ffa147 100644 --- a/include/Topology/gmap/gmap3.h +++ b/include/Topology/gmap/gmap3.h @@ -105,9 +105,9 @@ public: //@{ //! Delete the vertex of d - /*! All the faces around the vertex are merged into one face + /*! All the volumes around the vertex are merged into one volume * @param d a dart of the vertex to delete - * @return true if the deletion has been executed, false otherwise + * @return a Dart of the resulting volume */ virtual Dart deleteVertex(Dart d); @@ -122,6 +122,13 @@ public: */ virtual bool uncutEdge(Dart d); + //! Delete the edge of d + /*! All the volumes around the edge are merged into one volume + * @param d a dart of the edge to delete + * @return a Dart of the resulting volume + */ + virtual Dart deleteEdge(Dart d); + //! Split a face inserting an edge between two vertices /*! \pre Dart d and e should belong to the same face and be distinct * @param d dart of first vertex diff --git a/include/Topology/map/map3.h b/include/Topology/map/map3.h index 638d8754..deb6727b 100644 --- a/include/Topology/map/map3.h +++ b/include/Topology/map/map3.h @@ -124,9 +124,9 @@ public: //@{ //! Delete the vertex of d - /*! All the faces around the vertex are merged into one face + /*! All the volumes around the vertex are merged into one volume * @param d a dart of the vertex to delete - * @return true if the deletion has been executed, false otherwise + * @return a Dart of the resulting volume */ virtual Dart deleteVertex(Dart d); @@ -141,8 +141,10 @@ public: */ virtual bool uncutEdge(Dart d); - //! Delete an edge and all the faces aroud this edge - /*! @param d a dart of the edge to delete + //! Delete the edge of d + /*! All the volumes around the edge are merged into one volume + * @param d a dart of the edge to delete + * @return a Dart of the resulting volume */ virtual Dart deleteEdge(Dart d); diff --git a/src/Topology/gmap/gmap3.cpp b/src/Topology/gmap/gmap3.cpp index 98d9b9ad..0e84abf2 100644 --- a/src/Topology/gmap/gmap3.cpp +++ b/src/Topology/gmap/gmap3.cpp @@ -129,12 +129,14 @@ Dart GMap3::deleteVertex(Dart d) beta2sew(beta0(d2), d32) ; beta2sew(fit, beta0(d3)) ; beta2sew(beta0(fit), d3) ; + + fit = phi1(fit) ; } } + GMap2::deleteCC(d) ; return res ; - return NIL ; } Dart GMap3::cutEdge(Dart d) @@ -182,6 +184,47 @@ bool GMap3::uncutEdge(Dart d) return false; } +Dart GMap3::deleteEdge(Dart d) +{ + if(isBoundaryEdge(d)) + return NIL ; + + Dart res = NIL ; + Dart dit = d ; + do + { + Dart fit = dit ; + Dart end = fit ; + fit = phi1(fit) ; + while(fit != end) + { + Dart d2 = phi2(fit) ; + Dart d3 = phi3(fit) ; + Dart d32 = phi2(d3) ; + + if(res == NIL) + res = d2 ; + + beta2unsew(d2) ; + beta2unsew(beta0(d2)) ; + beta2unsew(d32) ; + beta2unsew(beta0(d32)) ; + + beta2sew(d2, beta0(d32)) ; + beta2sew(beta0(d2), d32) ; + beta2sew(fit, beta0(d3)) ; + beta2sew(beta0(fit), d3) ; + + fit = phi1(fit) ; + } + dit = alpha2(dit) ; + } while(dit != d) ; + + GMap2::deleteCC(d) ; + + return res ; +} + void GMap3::splitFace(Dart d, Dart e) { assert(d != e && GMap2::sameOrientedFace(d, e)) ; diff --git a/src/Topology/map/map3.cpp b/src/Topology/map/map3.cpp index b898135e..89fe6e0d 100644 --- a/src/Topology/map/map3.cpp +++ b/src/Topology/map/map3.cpp @@ -122,8 +122,11 @@ Dart Map3::deleteVertex(Dart d) phi2unsew(d32) ; phi2sew(d2, d32) ; phi2sew(fit, d3) ; + + fit = phi1(fit) ; } } + Map2::deleteCC(d) ; return res ; @@ -185,37 +188,32 @@ Dart Map3::deleteEdge(Dart d) if(isBoundaryEdge(d)) return NIL ; - //Save the darts around the edge - //(one dart per face should be enough) - std::vector fstore; - fstore.reserve(128); - Dart dit = d; - do - { - fstore.push_back(dit); - dit = alpha2(dit); - }while(dit != d); - - Dart res = NIL ; - for(std::vector::iterator it = fstore.begin() ; it != fstore.end() ; ++it) + Dart dit = d ; + do { - Dart fit = *it ; - Dart end = phi_1(fit) ; + Dart fit = dit ; + Dart end = fit ; fit = phi1(fit) ; while(fit != end) { Dart d2 = phi2(fit) ; Dart d3 = phi3(fit) ; Dart d32 = phi2(d3) ; + if(res == NIL) res = d2 ; + phi2unsew(d2) ; phi2unsew(d32) ; phi2sew(d2, d32) ; phi2sew(fit, d3) ; + + fit = phi1(fit) ; } - } + dit = alpha2(dit) ; + } while(dit != d) ; + Map2::deleteCC(d) ; return res ; @@ -241,7 +239,7 @@ Dart Map3::collapseEdge(Dart d, bool delDegenerateVolumes) { //un brin d'une face adjacente a l'arrete contracte Dart d = phi2(phi_1(*it)); - Map2::collapseEdge(*it,false); + Map2::collapseEdge(*it, false); //test de la degeneresence //impossible d'avoir un volume de moins de 4 faces sans avoir de phi2 en points fixe donc on les vire @@ -275,7 +273,6 @@ Dart Map3::collapseEdge(Dart d, bool delDegenerateVolumes) } } - return resV; } -- GitLab