From eeb7e0dec2840a58e55a48362bdc3f963e5417c4 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Thu, 8 Dec 2011 00:08:11 +0100 Subject: [PATCH] bug closeMap GMap2 + correction cylinder polyhedron --- Apps/Examples/simpleGMap2.cpp | 10 +++---- Apps/Examples/simpleGMap3.cpp | 14 ++++----- include/Algo/Modelisation/polyhedron.hpp | 33 ++-------------------- include/Algo/Modelisation/primitives3d.hpp | 16 ++++++----- include/Algo/Modelisation/subdivision3.hpp | 6 ++-- src/Topology/gmap/gmap2.cpp | 10 ++++--- 6 files changed, 33 insertions(+), 56 deletions(-) diff --git a/Apps/Examples/simpleGMap2.cpp b/Apps/Examples/simpleGMap2.cpp index 37454c2a9..adb28790a 100644 --- a/Apps/Examples/simpleGMap2.cpp +++ b/Apps/Examples/simpleGMap2.cpp @@ -37,20 +37,20 @@ SimpleGMap2::SimpleGMap2() position[myMap.phi_1(d)] = VEC3(10,20,15); position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30); - VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f; + VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f; myMap.cutEdge(d); position[myMap.phi1(d)] = mid; - Algo::Modelisation::Polyhedron poly(myMap,position); + Algo::Modelisation::Polyhedron poly(myMap, position); - d = poly.cylinder_topo(5,1,false,false); + d = poly.cylinder_topo(5, 1, false, false); - poly.embedCylinder(10,10,5); + poly.embedCylinder(10, 10, 5); d = myMap.phi1(d); Dart dd = myMap.beta2(d); myMap.unsewFaces(d); - myMap.sewFaces(d,dd); + myMap.sewFaces(d, dd); position[d][1] += 3.0f; } diff --git a/Apps/Examples/simpleGMap3.cpp b/Apps/Examples/simpleGMap3.cpp index d41f54c64..e7f7f63aa 100644 --- a/Apps/Examples/simpleGMap3.cpp +++ b/Apps/Examples/simpleGMap3.cpp @@ -32,7 +32,7 @@ SimpleGMap3::SimpleGMap3() { position = myMap.addAttribute(VERTEX, "position"); - normal = myMap.addAttribute(VERTEX, "position"); + normal = myMap.addAttribute(VERTEX, "normal"); Algo::Modelisation::Primitive3D primCat(myMap,position); Dart d = primCat.hexaGrid_topo(2,1,1); @@ -43,33 +43,33 @@ SimpleGMap3::SimpleGMap3() DartMarker markOrient(myMap); std::vector orient; FunctorStore fs(orient); - myMap.foreach_dart_of_oriented_volume(d,fs); + myMap.foreach_dart_of_oriented_volume(d, fs); for(std::vector::iterator it = orient.begin() ; it != orient.end() ; ++it) markOrient.mark(*it); SelectorMarked sm(markOrient); - Algo::Modelisation::catmullClarkVol(myMap,position,sm); + Algo::Modelisation::catmullClarkVol(myMap, position, sm); for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) position[i] += VEC3(2,0,0); - Algo::Modelisation::Primitive3D prim(myMap,position); + 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; + 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; + 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; + VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f; myMap.cutEdge(d); position[myMap.phi1(d)] = mid; diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index 455ec3f0d..d3ce043b2 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -415,28 +415,15 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo if (bottom_closed) { Dart d = m_tableVertDarts[0]; - if(m_map.closeHole(d,false)) + if(m_map.closeHole(d, false)) { d = m_map.phi2(d); if(m_map.faceDegree(d) > 3) { - Algo::Modelisation::trianguleFace(m_map,d); - + Algo::Modelisation::trianguleFace(m_map, d); m_tableVertDarts.push_back(m_map.phi_1(d)); } } -// // create bottom -// Dart d = triangleFan_topo(m_map,n); -// // store center vertex dart -// m_tableVertDarts.push_back(m_map.phi_1(d)); -// -// // sew it -// for (int i=0; i::cylinder_topo(unsigned int n, unsigned int z, bool top_clo d = m_map.phi2(d); if(m_map.faceDegree(d) > 3) { - Algo::Modelisation::trianguleFace(m_map,d); - + Algo::Modelisation::trianguleFace(m_map, d); m_tableVertDarts.push_back(m_map.phi_1(d)); } } -// // create bottom -// Dart d = triangleFan_topo(m_map,n); -// // store center vertex dart -// m_tableVertDarts.push_back(m_map.phi_1(d)); -// -// // sew it -// for (int i=0; i::HexaGrid1Topo(unsigned int nx) { Dart d2 = createHexa(); m_tableVertDarts.push_back(d2); - m_map.sewVolumes(d1, d2); + m_map.sewVolumes(d1, d2, false); d1 = m_map.template phi<2112>(d2); } @@ -102,7 +102,7 @@ Dart Primitive3D::HexaGrid2Topo(unsigned int nx, unsigned int ny) // couture des deux lignes de cubes for (unsigned int i = 0; i < nx; ++i) { - m_map.sewVolumes(d1,d3); + m_map.sewVolumes(d1, d3, false); d1 = m_map.template phi<11232>(d1); d3 = m_map.template phi<11232>(d3); } @@ -116,12 +116,12 @@ Dart Primitive3D::HexaGrid2Topo(unsigned int nx, unsigned int ny) for (unsigned int i = 0; i < nx; ++i) { Dart dd = m_tableVertDarts[index++]; - dd =m_map.template phi<112>(dd); + dd = m_map.template phi<112>(dd); m_tableVertDarts.push_back(dd); } // warning last vertex of row has not same dart Dart dd = m_tableVertDarts[index++]; - dd =m_map.template phi<211>(dd); + dd = m_map.template phi<211>(dd); m_tableVertDarts.push_back(dd); return d0; @@ -137,13 +137,13 @@ Dart Primitive3D::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned m_tableVertDarts.clear(); m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1)); - Dart d0 = HexaGrid2Topo(nx,ny); + Dart d0 = HexaGrid2Topo(nx, ny); Dart d1 = m_map.template phi<12>(d0); for (unsigned int i = 1; i < nz; ++i) { // creation grille suivante - Dart d2 = HexaGrid2Topo(nx,ny); + Dart d2 = HexaGrid2Topo(nx, ny); Dart d3 = m_map.phi2(m_map.phi_1(d2)); // couture des deux grilles 2D de cubes @@ -153,7 +153,7 @@ Dart Primitive3D::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned Dart db = d3; for (unsigned int k = 0; k < nx; ++k) { - m_map.sewVolumes(da,db); + m_map.sewVolumes(da, db, false); da = m_map.template phi<11232>(da); db = m_map.template phi<11232>(db); } @@ -176,6 +176,8 @@ Dart Primitive3D::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned m_tableVertDarts.push_back(dd); } + m_map.closeMap() ; + return d0; } diff --git a/include/Algo/Modelisation/subdivision3.hpp b/include/Algo/Modelisation/subdivision3.hpp index 89b2e5ba6..cfc275dcc 100644 --- a/include/Algo/Modelisation/subdivision3.hpp +++ b/include/Algo/Modelisation/subdivision3.hpp @@ -94,8 +94,8 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec CellMarkerNoUnmark me(map, EDGE); CellMarker mf(map, FACE); - AutoAttributeHandler< EMB > attBary(map,VOLUME); - CellMarker vol(map,VOLUME); + AutoAttributeHandler< EMB > attBary(map, VOLUME); + CellMarker vol(map, VOLUME); //pre-computation : compute the centroid of all volume for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -103,7 +103,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec if(selected(d) && !vol.isMarked(d)) { vol.mark(d); - attBary[d] = Algo::Geometry::volumeCentroidGen(map,d,attributs); + attBary[d] = Algo::Geometry::volumeCentroidGen(map, d, attributs); } } diff --git a/src/Topology/gmap/gmap2.cpp b/src/Topology/gmap/gmap2.cpp index bc11aece9..cf2cfe946 100644 --- a/src/Topology/gmap/gmap2.cpp +++ b/src/Topology/gmap/gmap2.cpp @@ -864,13 +864,14 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary) beta2sew(d, beta0(first)); // sew the new edge to the hole beta2sew(first, beta0(d)); + Dart prev = first ; Dart dNext = d; // Turn around the hole Dart dPhi1; // to complete the face do { dPhi1 = phi1(dNext) ; dNext = beta2(dPhi1) ; - while(dNext != dPhi1) + while(dNext != dPhi1 && dPhi1 != d) { dPhi1 = beta1(dNext) ; // Search and put in dNext dNext = beta2(dPhi1) ; // the next dart of the hole @@ -880,14 +881,15 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary) { Dart next = newEdge(); // Add a new edge there and link it to the face ++countEdges; - Dart tmp = phi1(first) ; - beta1sew(beta0(first), next); // the edge is linked to the face - beta1sew(beta0(next), tmp) ; + beta1sew(beta0(next), prev); // the edge is linked to the face + prev = next ; beta2sew(dNext, beta0(next)); // the face is linked to the hole beta2sew(next, beta0(dNext)); } } while (dPhi1 != d); + beta1sew(prev, beta0(first)) ; + if(forboundary) boundaryMarkOrbit(FACE, phi2(d)); -- GitLab