diff --git a/Apps/Examples/simpleGMap3.cpp b/Apps/Examples/simpleGMap3.cpp index b5383791ae1798d9e7ebfdb88cd749a42a027a47..f57802c2e50e0495b2ab4793785bdc7d91b8cff2 100644 --- a/Apps/Examples/simpleGMap3.cpp +++ b/Apps/Examples/simpleGMap3.cpp @@ -26,39 +26,55 @@ #include "Utils/GLSLShader.h" #include "Algo/Geometry/boundingbox.h" #include "Algo/Modelisation/primitives3d.h" +#include "Algo/Modelisation/subdivision3map.h" SimpleGMap3::SimpleGMap3() { position = myMap.addAttribute(VERTEX, "position"); - Algo::Modelisation::Primitive3D prim(myMap,position); - Dart d = prim.hexaGrid_topo(2,2,1); - prim.embedHexaGrid(1,1,1); + Algo::Modelisation::Primitive3D primCat(myMap,position); + Dart d = primCat.hexaGrid_topo(2,2,2); + primCat.embedHexaGrid(1,1,1); - Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); - VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f; - myMap.cutEdge(d1); - position[myMap.phi1(d1)] = mid0; + myMap.check(); - VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f; - myMap.cutEdge(d); - position[myMap.phi1(d)] = mid1; - - d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); - VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f; - myMap.cutEdge(d); - position[myMap.phi1(d)] = mid; + Algo::Modelisation::catmullClarkVol(myMap,position); for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) position[i] += VEC3(2,0,0); - Algo::Modelisation::Primitive3D prim2(myMap,position); - d = prim2.hexaGrid_topo(2,1,1); - prim2.embedHexaGrid(1,1,1); - - d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d)))); - myMap.unsewVolumes(d); +// Algo::Modelisation::Primitive3D prim(myMap,position); +// d = prim.hexaGrid_topo(2,2,1); +// prim.embedHexaGrid(1,1,1); +// +// Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); +// VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f; +// myMap.cutEdge(d1); +// position[myMap.phi1(d1)] = mid0; +// +// VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f; +// myMap.cutEdge(d); +// position[myMap.phi1(d)] = mid1; +// +// d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); +// VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f; +// myMap.cutEdge(d); +// position[myMap.phi1(d)] = mid; +// +// for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) +// position[i] += VEC3(0,2,0); + + myMap.check(); + +// Algo::Modelisation::Primitive3D prim2(myMap,position); +// d = prim2.hexaGrid_topo(2,1,1); +// prim2.embedHexaGrid(1,1,1); +// +// d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d)))); +// myMap.unsewVolumes(d); +// +// myMap.check(); } void SimpleGMap3::initGUI() diff --git a/include/Algo/Modelisation/subdivision3map.hpp b/include/Algo/Modelisation/subdivision3map.hpp index d9ec1268472e9a86adf91b6b57448aa206fe2686..dfbd7e4aa71472b4dbe12f3806b074f015a4fb98 100644 --- a/include/Algo/Modelisation/subdivision3map.hpp +++ b/include/Algo/Modelisation/subdivision3map.hpp @@ -119,8 +119,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec } } -// mv.unmarkAll(); - // first pass: cut edges for (Dart d = map.begin(); d != map.end(); map.next(d)) { @@ -128,23 +126,15 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec if(selected(d) && !mv.isMarked(d)) { l_vertices.push_back(d); - Dart dd = d; - do { - mv.mark(dd); - dd = map.phi1(map.phi2(dd)); - } while(dd!=d); + mv.markOrbitInParent(VERTEX,d); } //cut edges if (selected(d) && !me.isMarked(d)) { - std::cout << "edge to cut " << d << std::endl; - std::cout << "edge degree " << map.edgeDegree(d) << std::endl; - Dart f = map.phi1(d); map.cutEdge(d); Dart e = map.phi1(d) ; - std::cout << "cut cut cut " << std::endl; attributs[e] = attributs[d]; attributs[e] += attributs[f]; @@ -166,8 +156,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec } } - std::cout << "edge cut" << std::endl; - // second pass: quandrangule faces std::map toSew; for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -200,8 +188,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec } } - std::cout << "nb vertices " << l_vertices.size() << std::endl; - //third pass : create the inner faces for (std::vector::iterator it = l_vertices.begin(); it != l_vertices.end(); ++it) { diff --git a/include/Topology/generic/embeddedMap3.hpp b/include/Topology/generic/embeddedMap3.hpp index 590623ee515a2df7087fffb8660cdab7c147879f..fc1d64fd337fc2dd81fb84432093c94ac9007a01 100644 --- a/include/Topology/generic/embeddedMap3.hpp +++ b/include/Topology/generic/embeddedMap3.hpp @@ -104,8 +104,6 @@ void EmbeddedMap3::unsewVolumes(Dart d) if (MAP3::isOrbitEmbedded(FACE)) { - std::cout << "newCell f" << std::endl; - MAP3::embedNewCell(FACE, dd); MAP3::copyCell(FACE, dd, d); } diff --git a/include/Topology/gmap/gmap1.h b/include/Topology/gmap/gmap1.h index 7457934e075947898ea5c54ca0d8e95f8c01d88b..2792ff5061986ba452a4565db208eac814dd1843 100644 --- a/include/Topology/gmap/gmap1.h +++ b/include/Topology/gmap/gmap1.h @@ -41,6 +41,8 @@ protected: void init() ; public: + typedef GMap0 ParentMap; + GMap1(); virtual std::string mapTypeName(); diff --git a/include/Topology/gmap/gmap1.hpp b/include/Topology/gmap/gmap1.hpp index 46757c7023bf0468494c35c94ff1fa871365e9d9..8196675477837d3069fe7c0bd7e9541b86152e4a 100644 --- a/include/Topology/gmap/gmap1.hpp +++ b/include/Topology/gmap/gmap1.hpp @@ -204,7 +204,7 @@ inline void GMap1::collapseEdge(Dart d) inline void GMap1::splitFace(Dart d, Dart e) { - assert(d != e && sameOrientedFace(d, e)) ; + assert(d != e && sameFace(d, e)) ; Dart d1 = beta1(d) ; Dart e1 = beta1(e) ; Dart dd = newEdge() ; diff --git a/include/Topology/gmap/gmap2.h b/include/Topology/gmap/gmap2.h index 9c50af7c266b86313c68cb53745f90884d4558ad..81157ac1f1d9035c911d3fa0c6304acccf530fb4 100644 --- a/include/Topology/gmap/gmap2.h +++ b/include/Topology/gmap/gmap2.h @@ -41,6 +41,8 @@ protected: void init() ; public: + typedef GMap1 ParentMap; + GMap2(); virtual std::string mapTypeName(); diff --git a/include/Topology/gmap/gmap3.h b/include/Topology/gmap/gmap3.h index e3615284f21928100795c4409dc059ccd49236cc..5f15dcc96371a4384884ff3c727a67ee5b6a3a6d 100644 --- a/include/Topology/gmap/gmap3.h +++ b/include/Topology/gmap/gmap3.h @@ -41,6 +41,8 @@ protected: void init() ; public: + typedef GMap2 ParentMap; + GMap3(); virtual std::string mapTypeName(); @@ -201,11 +203,18 @@ public: */ unsigned int vertexDegree(Dart d) ; + /** + * compute the number of volumes around the edge of d + */ + virtual unsigned int edgeDegree(Dart d); + /** * compute the number of faces in the volume of d */ unsigned int volumeDegree(Dart d); + virtual bool check(); + /*! @name Cell Functors * Apply functors to all darts of a cell *************************************************************************/ diff --git a/src/Topology/gmap/embeddedGMap2.cpp b/src/Topology/gmap/embeddedGMap2.cpp index ffcf992816ea7b0c72e291877ec4cc81c9904598..d161c9566bab5a3626b6ec523ba4340212a23023 100644 --- a/src/Topology/gmap/embeddedGMap2.cpp +++ b/src/Topology/gmap/embeddedGMap2.cpp @@ -40,7 +40,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e) if (isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, phi1(dd), d) ; + copyDartEmbedding(VERTEX, beta2(phi1(dd)), beta2(d)) ; copyDartEmbedding(VERTEX, phi1(ee), e) ; + copyDartEmbedding(VERTEX, beta2(phi1(ee)), beta2(e)) ; embedNewCell(VERTEX, e) ; copyCell(VERTEX, e, d) ; } @@ -48,7 +50,9 @@ void EmbeddedGMap2::splitVertex(Dart d, Dart e) if(isOrbitEmbedded(FACE)) { copyDartEmbedding(FACE, phi1(dd), dd) ; + copyDartEmbedding(FACE, beta0(phi1(dd)), beta0(dd)) ; copyDartEmbedding(FACE, phi1(ee), ee) ; + copyDartEmbedding(FACE, beta0(phi1(ee)), beta0(ee)) ; } } @@ -93,15 +97,19 @@ void EmbeddedGMap2::cutEdge(Dart d) if (isOrbitEmbedded(EDGE)) { embedNewCell(EDGE, nd) ; - copyDartEmbedding(EDGE, phi2(d), d) ; copyCell(EDGE, nd, d) ; } + if(isOrbitEmbedded(FACE)) { copyDartEmbedding(FACE, phi1(d), d) ; + copyDartEmbedding(FACE, beta0(phi1(d)), beta0(d)) ; Dart e = phi2(nd) ; if(e != nd) + { copyDartEmbedding(FACE, phi1(e), e) ; + copyDartEmbedding(FACE, beta0(phi1(e)), beta0(e)) ; + } } } @@ -197,12 +205,16 @@ bool EmbeddedGMap2::flipEdge(Dart d) if (isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, d, phi1(e)) ; + copyDartEmbedding(VERTEX, beta2(d), beta2(phi1(e))) ; copyDartEmbedding(VERTEX, e, phi1(d)) ; + copyDartEmbedding(VERTEX, beta2(e), beta2(phi1(d))) ; } if (isOrbitEmbedded(FACE)) { copyDartEmbedding(FACE, phi_1(d), d) ; + copyDartEmbedding(FACE, beta0(phi_1(d)), beta0(d)) ; copyDartEmbedding(FACE, phi_1(e), e) ; + copyDartEmbedding(FACE, beta0(phi_1(e)), beta0(e)) ; } return true ; } @@ -218,12 +230,17 @@ bool EmbeddedGMap2::flipBackEdge(Dart d) if (isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, d, phi1(e)) ; + copyDartEmbedding(VERTEX, beta2(d), beta2(phi1(e))) ; copyDartEmbedding(VERTEX, e, phi1(d)) ; + copyDartEmbedding(VERTEX, beta2(e), beta2(phi1(d))) ; } + if (isOrbitEmbedded(FACE)) { copyDartEmbedding(FACE, phi1(d), d) ; + copyDartEmbedding(FACE, beta0(phi1(d)), beta0(d)) ; copyDartEmbedding(FACE, phi1(e), e) ; + copyDartEmbedding(FACE, beta0(phi1(e)), beta0(e)) ; } return true ; } @@ -299,7 +316,8 @@ void EmbeddedGMap2::sewFaces(Dart d, Dart e) if (isOrbitEmbedded(EDGE)) { - copyDartEmbedding(EDGE, e, d) ; + vEmb1 = getEmbedding(EDGE, d) ; + embedOrbit(EDGE, e, vEmb1) ; } } @@ -355,6 +373,7 @@ bool EmbeddedGMap2::collapseDegeneratedFace(Dart d) if (isOrbitEmbedded(EDGE)) { copyDartEmbedding(EDGE, phi2(e), e) ; + copyDartEmbedding(EDGE, beta0(phi2(e)), beta0(e)) ; } return true ; } @@ -368,7 +387,9 @@ void EmbeddedGMap2::splitFace(Dart d, Dart e) if (isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, phi_1(e), d) ; + copyDartEmbedding(VERTEX, beta2(phi_1(e)), beta2(d)) ; copyDartEmbedding(VERTEX, phi_1(d), e) ; + copyDartEmbedding(VERTEX, beta2(phi_1(d)), beta2(e)) ; } if (isOrbitEmbedded(FACE)) { @@ -444,10 +465,12 @@ unsigned int EmbeddedGMap2::closeHole(Dart d) if (isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, f, alpha1(f)) ; + copyDartEmbedding(VERTEX, beta2(f), beta2(alpha1(f))) ; } if (isOrbitEmbedded(EDGE)) { copyDartEmbedding(EDGE, f, phi2(f)) ; + copyDartEmbedding(EDGE, beta0(f), beta0(phi2(f))) ; } f = phi1(f) ; } while(dd != f) ; diff --git a/src/Topology/gmap/embeddedGMap3.cpp b/src/Topology/gmap/embeddedGMap3.cpp index a920f82bb531753a843d7cb566c81b23dc4b7870..6aee8ae2a775b08b5d3aa4fffb558a68861572ee 100644 --- a/src/Topology/gmap/embeddedGMap3.cpp +++ b/src/Topology/gmap/embeddedGMap3.cpp @@ -63,42 +63,53 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) //embed the face orbit from the volume sewn if (isOrbitEmbedded(FACE)) - copyDartEmbedding(FACE, e, d) ; + { + unsigned int vEmb = getEmbedding(FACE, d); + embedOrbit(FACE, e, vEmb) ; + } } void EmbeddedGMap3::unsewVolumes(Dart d) { -// Dart d3 = phi3(d); -// -// bool boundaryD = false; -// bool boundaryE = false; -// -// if(isOrbitEmbedded(VERTEX)) -// { -// if(isBoundaryVertex(d)) -// boundaryD = true; -// if(isBoundaryVertex(phi1(d))) -// boundaryE = true; -// } -// - GMap3::unsewVolumes(d); -// -// Dart dd = d; -// Dart dd3 = d3; -// -// do -// { -// if(isOrbitEmbedded(VERTEX)) -// copyCell(VERTEX, dd3, phi1(dd)); -// -// if(isOrbitEmbedded(EDGE)) -// -// -// if(isOrbitEmbedded(FACE)) -// -// -// dd = phi1(dd) ; -// }while( dd != d ); + Dart dd = phi1(phi3(d)); + + if(phi3(d)!=d) + { + GMap3::unsewVolumes(d); + + Dart ddd = d; + do + { + if(isOrbitEmbedded(VERTEX)) + { + if(!sameVertex(ddd,dd)) + { + embedNewCell(VERTEX, ddd); + copyCell(VERTEX, ddd, dd); + } + } + + dd = phi_1(dd); + + if(isOrbitEmbedded(EDGE)) + { + if(!sameEdge(ddd,dd)) + { + embedNewCell(EDGE, dd); + copyCell(VERTEX, dd, ddd); + } + } + + ddd = phi1(ddd); + } while(ddd!=d); + + + if (isOrbitEmbedded(FACE)) + { + embedNewCell(FACE, dd); + copyCell(FACE, dd, d); + } + } } bool EmbeddedGMap3::mergeVolumes(Dart d) @@ -124,36 +135,40 @@ void EmbeddedGMap3::splitFace(Dart d, Dart e) if(isOrbitEmbedded(VERTEX)) { - copyDartEmbedding(VERTEX, phi2(phi_1(d)), d); - copyDartEmbedding(VERTEX, phi2(phi_1(e)), e); - - if(phi3(d) != d) - { - Dart d3 = phi3(d); - Dart e3 = phi3(e); + unsigned int vEmb = getEmbedding(VERTEX, d); + embedOrbit(VERTEX,phi2(phi_1(d)),vEmb); - copyDartEmbedding(VERTEX, phi1(d3), phi1(phi2(phi1(d3)))); - copyDartEmbedding(VERTEX, phi1(e3), phi1(phi2(phi1(e3)))); - } + vEmb = getEmbedding(VERTEX, e); + embedOrbit(VERTEX,phi2(phi_1(e)),vEmb); } if(isOrbitEmbedded(FACE)) { embedNewCell(FACE, phi2(phi_1(d))); copyCell(FACE, phi2(phi_1(d)), d); + + copyDartEmbedding(FACE, phi_1(d), d); + copyDartEmbedding(FACE, beta0(phi_1(d)), beta0(d)); + + copyDartEmbedding(FACE, beta3(phi_1(d)), beta3(d)); + copyDartEmbedding(FACE, beta3(beta0(phi_1(d))), beta3(beta0(d))); } if(isOrbitEmbedded(VOLUME)) { copyDartEmbedding(VOLUME, phi_1(d), d); + copyDartEmbedding(VOLUME, beta0(phi_1(d)), beta0(d)); copyDartEmbedding(VOLUME, phi2(phi_1(d)), d); + copyDartEmbedding(VOLUME, beta0(phi2(phi_1(d))), beta0(d)); if(phi3(d) != d) { Dart d3 = phi3(d); copyDartEmbedding(VOLUME, phi1(d3), d3); + copyDartEmbedding(VOLUME, beta0(phi1(d3)), beta0(d3)); copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3); + copyDartEmbedding(VOLUME, beta0(phi2(phi1(d3))), beta0(d3)); } } } @@ -164,13 +179,13 @@ void EmbeddedGMap3::cutEdge(Dart d) if(isOrbitEmbedded(EDGE)) { - Dart nd = phi1(d) ; + Dart nd = phi1(d); - embedNewCell(EDGE, nd) ; - copyCell(EDGE, nd, d) ; + embedNewCell(EDGE, nd); + copyCell(EDGE, nd, d); unsigned int vEmb = getEmbedding(EDGE, d); - embedOrbit(EDGE, d, vEmb) ; + embedOrbit(EDGE, d, vEmb); } if(isOrbitEmbedded(FACE)) @@ -178,14 +193,16 @@ void EmbeddedGMap3::cutEdge(Dart d) Dart f = d; do { - Dart nd = phi1(f) ; - copyDartEmbedding(FACE, nd, f); + Dart nd = phi1(f); + unsigned int fEmb = getEmbedding(FACE, f); + embedOrbit(FACE, nd, fEmb); Dart f2 = phi2(nd); if(f2!=nd) { Dart nd2 = phi2(f); - copyDartEmbedding(FACE, nd2, f2); + unsigned int fEmb2 = getEmbedding(FACE, f2); + embedOrbit(FACE, nd2, fEmb2); } f = alpha2(f); @@ -194,15 +211,29 @@ void EmbeddedGMap3::cutEdge(Dart d) if(isOrbitEmbedded(VOLUME)) { +// Dart f = d; +// do +// { +// unsigned int fEmb2 = getEmbedding(VOLUME, d); +// embedOrbit(VOLUME, d, fEmb2); +// f = alpha2(f); +// } while(f != d); + Dart f = d; do { - Dart nd = phi1(f) ; + Dart nd = phi1(f); copyDartEmbedding(VOLUME, nd, f); + copyDartEmbedding(VOLUME, beta0(nd), f); + copyDartEmbedding(VOLUME, beta2(nd), f); + copyDartEmbedding(VOLUME, beta3(nd), f); - Dart nd2 = phi2(f); - if(f!=nd2) - copyDartEmbedding(VOLUME, nd2, f); +// Dart nd2 = beta2(nd); +// if(f!=nd2) +// { +// copyDartEmbedding(VOLUME, nd2, f); +// copyDartEmbedding(VOLUME, beta0(nd2), f); +// } f = alpha2(f); } while(f != d); @@ -212,14 +243,6 @@ void EmbeddedGMap3::cutEdge(Dart d) //int EmbeddedGMap3::collapseEdge(Dart d, bool delDegenerateFaces, // bool delDegenerateVolumes) //{ -// unsigned int vEmb = EMBNULL ; -// if(isOrbitEmbedded(VERTEX)) -// { -// vEmb = getEmbedding(VERTEX, d) ; -// embedOrbit(VERTEX,d,vEmb); -// embedOrbit(VERTEX,phi2(d),vEmb); -// } -// // int nbCol = GMap3::collapseEdge(d,delDegenerateFaces,delDegenerateVolumes); // // return nbCol; @@ -228,31 +251,6 @@ void EmbeddedGMap3::cutEdge(Dart d) //void EmbeddedGMap3::collapseFace(Dart d, bool delDegenerateFaces, // bool delDegenerateVolumes) //{ -// //unsigned int degree = faceDegree(d); -// //Dart dsave; -// -//// //si degree face = 3 -//// if(degree == 3) -//// { -//// dsave = phi3(phi2(phi1(d))); -//// dsave = phi3(phi2(phi1(dsave))); -//// //ATTENTION : il faut trouver un brin de l'orbite sommet de d non modifie par l'operation !! -//// } -//// else if(degree > 3) -//// { -//// dsave = phi1(phi2(phi1(d))); -//// dsave = phi1(phi2(phi1(dsave))); -//// } -//// else -//// return; -// -// -//// unsigned int vEmb = EMBNULL ; -//// if(isOrbitEmbedded(VERTEX)) -//// { -//// vEmb = getEmbedding(d, VERTEX) ; -//// } -// // GMap3::collapseFace(d,delDegenerateFaces,delDegenerateVolumes); // //// if(isOrbitEmbedded(VERTEX)) @@ -263,12 +261,6 @@ void EmbeddedGMap3::cutEdge(Dart d) //TODO collapseVolume -//Dart EmbeddedGMap3::cutSpike(Dart d) -//{ -// Dart e = GMap3::cutSpike(d); -// return e; -//} - unsigned int EmbeddedGMap3::closeHole(Dart d) { unsigned int nbE = GMap3::closeHole(d); @@ -278,11 +270,20 @@ unsigned int EmbeddedGMap3::closeHole(Dart d) do { if(isOrbitEmbedded(VERTEX)) + { copyDartEmbedding(VERTEX,f, phi1(phi2(f))); + copyDartEmbedding(VERTEX,beta1(f), beta1(phi1(phi2(f)))); + } if(isOrbitEmbedded(EDGE)) + { copyDartEmbedding(EDGE, f, phi2(f)); + copyDartEmbedding(EDGE, beta0(f), beta0(phi2(f))); + } if(isOrbitEmbedded(VOLUME)) + { copyDartEmbedding(VOLUME, f, phi2(f)); + copyDartEmbedding(VOLUME, beta0(f), beta0(phi2(f))); + } f = phi1(f); } @@ -302,6 +303,7 @@ void EmbeddedGMap3::closeMap(DartMarker &marker) if(isOrbitEmbedded(VERTEX)) { copyDartEmbedding(VERTEX, d, phi1(phi3(d))); + copyDartEmbedding(VERTEX, beta0(d), beta0(phi1(phi3(d)))); } } } @@ -318,40 +320,81 @@ bool EmbeddedGMap3::check() { if (isOrbitEmbedded(VERTEX)) { - if (phi2(phi_1(d)) != phi_1(d) && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi2(phi_1(d)))) + if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta1(d))) { CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ; return false ; } - if(phi3(d) != d && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi1(phi3(d)))) - { - CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ; - std::cout << "Dart #" << d << std::endl; - std::cout << "Emb(d) = " << getEmbedding(VERTEX, d) << std::endl; - std::cout << "Emb(phi32(d)) = " << getEmbedding(VERTEX, phi3(phi2(d))) << std::endl; - return false ; - } + if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta2(d))) + { + CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ; + return false ; + } + if (getEmbedding(VERTEX, d) != getEmbedding(VERTEX, beta3(d))) + { + CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ; + return false ; + } } -// if (isOrbitEmbedded(EDGE)) -// { -// if (getEmbedding(EDGE, d) != getEmbedding(EDGE, phi2(d))) -// { -// CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; -// return false ; -// } -// } -// -// if (isOrbitEmbedded(FACE)) -// { -// if (getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d))) -// { -// CGoGNout << "Check: different embeddings on face" << CGoGNendl ; -// return false ; -// } -// } + if (isOrbitEmbedded(EDGE)) + { + if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta0(d))) + { + CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; + return false ; + } + + if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta2(d))) + { + CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; + return false ; + } + + if (getEmbedding(EDGE, d) != getEmbedding(EDGE, beta3(d))) + { + CGoGNout << "Check: different embeddings on edge" << CGoGNendl ; + return false ; + } + } + + if (isOrbitEmbedded(FACE)) + { + if (getEmbedding(FACE, d) != getEmbedding(FACE, beta0(d))) + { + CGoGNout << "Check: different embeddings on face" << CGoGNendl ; + return false ; + } + + if (getEmbedding(FACE, d) != getEmbedding(FACE, beta1(d))) + { + CGoGNout << "Check: different embeddings on face" << CGoGNendl ; + return false ; + } + } + + if (isOrbitEmbedded(VOLUME)) + { + if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta0(d))) + { + CGoGNout << "Check: different embeddings in volume" << CGoGNendl ; + return false ; + } + + if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta1(d))) + { + CGoGNout << "Check: different embeddings in volume" << CGoGNendl ; + return false ; + } + + if (getEmbedding(VOLUME, d) != getEmbedding(VOLUME, beta2(d))) + { + CGoGNout << "Check: different embeddings in volume" << CGoGNendl ; + return false ; + } + } } CGoGNout << "Check: embedding ok" << CGoGNendl ; return true ; diff --git a/src/Topology/gmap/gmap1.cpp b/src/Topology/gmap/gmap1.cpp index ef0b9e60406736bea329612989e4e2da559bfc36..3495d0368f8ec205e43a3b47cde28dc4319be4b3 100644 --- a/src/Topology/gmap/gmap1.cpp +++ b/src/Topology/gmap/gmap1.cpp @@ -49,16 +49,14 @@ Dart GMap1::newFace(unsigned int n) void GMap1::deleteFace(Dart d) { - Dart e = phi1(d) ; + Dart e = phi1(d); while (e != d) { - Dart f = phi1(e) ; - deleteDart(beta0(e)) ; - deleteDart(e) ; - e = f ; + Dart f = phi1(e); + deleteEdge(e); + e = f; } - deleteDart(beta0(d)) ; - deleteDart(d) ; + deleteEdge(d); } void GMap1::deleteEdge(Dart d) @@ -87,7 +85,17 @@ bool GMap1::sameOrientedFace(Dart d, Dart e) bool GMap1::sameFace(Dart d, Dart e) { - return sameOrientedFace(d, e) || sameOrientedFace(beta0(d), e) ; + Dart dNext = d ; + do + { + if (dNext == e) + return true ; + dNext = beta0(dNext); + if (dNext == e) + return true ; + dNext = beta1(dNext) ; + } while (dNext != d) ; + return false ; } unsigned int GMap1::faceDegree(Dart d) diff --git a/src/Topology/gmap/gmap3.cpp b/src/Topology/gmap/gmap3.cpp index a0a0162d074deb7e8b875464ac05c1163fda2ef1..0c7a9418b77d93e1a7456dd0f91787da9e3ecdcd 100644 --- a/src/Topology/gmap/gmap3.cpp +++ b/src/Topology/gmap/gmap3.cpp @@ -495,6 +495,98 @@ bool GMap3::sameFace(Dart d, Dart e) return false; } +unsigned int GMap3::edgeDegree(Dart d) +{ + unsigned int deg = 0; + Dart e = d; + + do + { + deg++; + e = alpha2(e); + } while(e != d); + + return deg; +} + +bool GMap3::check() +{ + CGoGNout << "Check: topology begin" << CGoGNendl; + DartMarker m(*this); + m.unmarkAll(); + for(Dart d = this->begin(); d != this->end(); this->next(d)) + { + Dart d0 = beta0(d); + if (beta0(d0) != d) // beta0 involution ? + { + CGoGNout << "Check: beta0 is not an involution" << CGoGNendl; + return false; + } + + Dart d3 = beta3(d); + if (beta3(d3) != d) // beta3 involution ? + { + CGoGNout << "Check: beta3 is not an involution" << CGoGNendl; + return false; + } + + if(d3 != d) + { + if(beta1(d3) != beta3(beta1(d))) + { + CGoGNout << "Check: beta3 , faces are not entirely sewn" << CGoGNendl; + return false; + } + } + + Dart d2 = beta2(d); + if (beta2(d2) != d) // beta2 involution ? + { + CGoGNout << "Check: beta2 is not an involution" << CGoGNendl; + return false; + } + + Dart d1 = phi1(d); + if (phi_1(d1) != d) // phi1 a une image correcte ? + { + CGoGNout << "Check: unconsistent phi_1 link" << CGoGNendl; + return false; + } + + if (m.isMarked(d1)) // phi1 a un seul antécédent ? + { + CGoGNout << "Check: dart with two phi1 predecessors" << CGoGNendl; + return false; + } + m.mark(d1); + + if (d1 == d) + CGoGNout << "Check: (warning) face loop (one edge)" << CGoGNendl; + + if (phi1(d1) == d) + CGoGNout << "Check: (warning) face with only two edges" << CGoGNendl; + + if (phi2(d1) == d) + CGoGNout << "Check: (warning) dandling edge (phi2)" << CGoGNendl; + + if (phi3(d1) == d) + CGoGNout << "Check: (warning) dandling edge (phi3)" << CGoGNendl; + } + + for(Dart d = this->begin(); d != this->end(); this->next(d)) + { + if (!m.isMarked(d)) // phi1 a au moins un antécédent ? + { + std::cout << "dart = " << d << std::endl; + CGoGNout << "Check: dart with no phi1 predecessor" << CGoGNendl; + return false; + } + } + + CGoGNout << "Check: topology ok" << CGoGNendl; + return true; +} + /*! @name Cell Functors * Apply functors to all darts of a cell *************************************************************************/ diff --git a/src/Topology/map/embeddedMap3.cpp b/src/Topology/map/embeddedMap3.cpp index f8baa257a48e956141471f2e43079b0a6aac99c8..d5fe717ff1f8d22d29a0e556f5d7a163ffcc0b4b 100644 --- a/src/Topology/map/embeddedMap3.cpp +++ b/src/Topology/map/embeddedMap3.cpp @@ -68,37 +68,45 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e) void EmbeddedMap3::unsewVolumes(Dart d) { -// Dart d3 = phi3(d); -// -// bool boundaryD = false; -// bool boundaryE = false; -// -// if(isOrbitEmbedded(VERTEX)) -// { -// if(isBoundaryVertex(d)) -// boundaryD = true; -// if(isBoundaryVertex(phi1(d))) -// boundaryE = true; -// } -// - Map3::unsewVolumes(d); -// -// Dart dd = d; -// Dart dd3 = d3; -// -// do -// { -// if(isOrbitEmbedded(VERTEX)) -// copyCell(VERTEX, dd3, phi1(dd)); -// -// if(isOrbitEmbedded(EDGE)) -// -// -// if(isOrbitEmbedded(FACE)) -// -// -// dd = phi1(dd) ; -// }while( dd != d ); + Dart dd = phi1(phi3(d)); + + if(phi3(d)!=d) + { + Map3::unsewVolumes(d); + + Dart ddd = d; + do + { + if(isOrbitEmbedded(VERTEX)) + { + if(!sameVertex(ddd,dd)) + { + embedNewCell(VERTEX, dd); + copyCell(VERTEX, dd, ddd); + } + } + + dd = phi_1(dd); + + if(isOrbitEmbedded(EDGE)) + { + if(!sameEdge(ddd,dd)) + { + embedNewCell(EDGE, dd); + copyCell(VERTEX, dd, ddd); + } + } + + ddd = phi1(ddd); + } while(ddd!=d); + + + if (isOrbitEmbedded(FACE)) + { + embedNewCell(FACE, dd); + copyCell(FACE, dd, d); + } + } } bool EmbeddedMap3::mergeVolumes(Dart d)