diff --git a/Apps/Examples/simpleGMap3.cpp b/Apps/Examples/simpleGMap3.cpp index 86e7ad520c132c47b1992bfc703b4bdcd01b222c..63eb21ff309f19e857b7b76ff56cf088543eb497 100644 --- a/Apps/Examples/simpleGMap3.cpp +++ b/Apps/Examples/simpleGMap3.cpp @@ -32,6 +32,7 @@ SimpleGMap3::SimpleGMap3() { position = myMap.addAttribute(VERTEX, "position"); + normal = myMap.addAttribute(VERTEX, "position"); Algo::Modelisation::Primitive3D primCat(myMap,position); Dart d = primCat.hexaGrid_topo(2,1,1); @@ -39,43 +40,41 @@ SimpleGMap3::SimpleGMap3() myMap.check(); -// DartMarker markOrient(myMap); -// std::vector orient; -// FunctorStore fs(orient); -// 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); + DartMarker markOrient(myMap); + std::vector orient; + FunctorStore fs(orient); + myMap.foreach_dart_of_oriented_volume(d,fs); - Algo::Modelisation::catmullClarkVol(myMap,position); + for(std::vector::iterator it = orient.begin() ; it != orient.end() ; ++it) + markOrient.mark(*it); + + SelectorMarked sm(markOrient); + + 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); -// 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); + Algo::Modelisation::Primitive3D prim(myMap,position); + d = prim.hexaGrid_topo(2,2,1); + prim.embedHexaGrid(1,1,1); - myMap.check(); + 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); Algo::Modelisation::Primitive3D prim2(myMap,position); d = prim2.hexaGrid_topo(2,1,1); @@ -110,6 +109,12 @@ void SimpleGMap3::cb_redraw() glDisable(GL_LIGHTING); glLineWidth(1.0f); Algo::Render::GL1::renderTopoGMD3(myMap, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f); + + glDisable(GL_LIGHTING); + glColor3f(1.0f, 1.0f, 1.0f); + glLineWidth(1.0f); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + Algo::Render::GL1::renderTriQuadPoly(myMap, Algo::Render::GL1::LINE, 1.0,position, normal); } diff --git a/Apps/Examples/simpleGMap3.h b/Apps/Examples/simpleGMap3.h index a55595a44cda827e148409c69e4de1f67ea7e4fd..54d7fa1aed0c431b42227b6ee00f2400534feaf9 100644 --- a/Apps/Examples/simpleGMap3.h +++ b/Apps/Examples/simpleGMap3.h @@ -31,6 +31,7 @@ #include "Geometry/vector_gen.h" +#include "Algo/Render/GL1/map_glRender.h" #include "Algo/Render/GL1/topo_render.h" using namespace CGoGN ; @@ -53,6 +54,7 @@ public: SelectorTrue allDarts ; PFP::TVEC3 position ; + PFP::TVEC3 normal ; SimpleGMap3() ; diff --git a/include/Algo/Modelisation/subdivision3map.hpp b/include/Algo/Modelisation/subdivision3map.hpp index e8d5e9990bd6d8be84cb4f23204e9d60ecc8b13c..660c02549e1e19875d197b5d77f80c62e79b1c36 100644 --- a/include/Algo/Modelisation/subdivision3map.hpp +++ b/include/Algo/Modelisation/subdivision3map.hpp @@ -224,22 +224,22 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec d= dN; } while (*it!=d); -// //close the generated hole and create the central vertex -// unsigned int degree = map.closeHole(map.phi1(d)); -// -// Dart dd = map.phi1(map.phi2(map.phi1(d))); -// map.splitFace(map.phi_1(dd),map.phi1(dd)); -// Dart dS = map.phi1(dd); -// map.cutEdge(dS); -// -// attributs[map.phi1(dS)] = attBary[d]; -// -// //TODO : test with vertices with degree higher than 3 -// for(unsigned int i=0; i < (degree/2)-2; ++i) -// { -// map.splitFace(map.phi2(dS),map.template phi<111>(map.phi2(dS))); -// dS = map.template phi<111>(map.phi2(dS)); -// } + //close the generated hole and create the central vertex + unsigned int degree = map.closeHole(map.phi1(d)); + + Dart dd = map.phi1(map.phi2(map.phi1(d))); + map.splitFace(map.phi_1(dd),map.phi1(dd)); + Dart dS = map.phi1(dd); + map.cutEdge(dS); + + attributs[map.phi1(dS)] = attBary[d]; + + //TODO : test with vertices with degree higher than 3 + for(unsigned int i=0; i < (degree/2)-2; ++i) + { + map.splitFace(map.phi2(dS),map.template phi<111>(map.phi2(dS))); + dS = map.template phi<111>(map.phi2(dS)); + } } nb_=0; @@ -248,15 +248,17 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec std::cout << "then " << nb_ << std::endl; -// //sew all faces leading to the central vertex -// for (std::map::iterator it = toSew.begin(); it != toSew.end(); ++it) -// { -// Dart dT = map.phi2(it->first); -// if(dT==map.phi3(dT)) -// { -// map.sewVolumes(dT,map.phi2(it->second)); -// } -// } + map.check(); + + //sew all faces leading to the central vertex + for (std::map::iterator it = toSew.begin(); it != toSew.end(); ++it) + { + Dart dT = map.phi2(it->first); + if(dT==map.phi3(dT)) + { + map.sewVolumes(dT,map.phi2(it->second)); + } + } } } //namespace Modelisation diff --git a/include/Algo/Render/GL1/topo_render.hpp b/include/Algo/Render/GL1/topo_render.hpp index ed8b30df7a63bb10a81225d6000283fb0b1de3d4..ab7dda3c623784f6a95d4817c17b239fb327ced0 100644 --- a/include/Algo/Render/GL1/topo_render.hpp +++ b/include/Algo/Render/GL1/topo_render.hpp @@ -436,12 +436,17 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh DartMarker mark(map); // marker for darts - CellMarker mVol(map, VOLUME); +// CellMarker mVol(map, VOLUME); + DartMarker mVol(map); + + //compute barycenter and get a dart by face for (Dart d = map.begin(); d != map.end(); map.next(d)) { if(!mVol.isMarked(d)) { - mVol.mark(d); +// mVol.mark(d); + mVol.markOrbit(VOLUME,d); + CellMarkerStore markVert(map, VERTEX); //marker for vertices VEC3 center(0); unsigned int nbVertices = 0; @@ -461,7 +466,6 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions do { mark.mark(dNext); // Mark -// mark.mark(map.beta0(dNext)); if (!markVert.isMarked(dNext)) { diff --git a/include/Topology/gmap/embeddedGMap3.h b/include/Topology/gmap/embeddedGMap3.h index 40fe64762aa29de934fe866be783ee59d86da51b..bc20aa8d364f49717f7b1272d262d9d5261c38fa 100644 --- a/include/Topology/gmap/embeddedGMap3.h +++ b/include/Topology/gmap/embeddedGMap3.h @@ -39,6 +39,12 @@ class EmbeddedGMap3 : public GMap3 public: typedef GMap3 TOPO_MAP; + //! + /*! + * + */ + virtual void unsewFaces(Dart d); + //! /*! * diff --git a/src/Topology/gmap/embeddedGMap3.cpp b/src/Topology/gmap/embeddedGMap3.cpp index 75214fca5333e1a49b3c91d33a3388f8db55147b..81e7df54b20d1980f14ffd03d25655379cfb98ec 100644 --- a/src/Topology/gmap/embeddedGMap3.cpp +++ b/src/Topology/gmap/embeddedGMap3.cpp @@ -30,6 +30,36 @@ namespace CGoGN { +void EmbeddedGMap3::unsewFaces(Dart d) +{ + Dart e = beta2(d); + GMap3::unsewFaces(d); + + if (isOrbitEmbedded(VERTEX)) + { + if(!sameVertex(d,e)) + { + embedNewCell(VERTEX, e); + copyCell(VERTEX, e, d); + } + + d = beta0(d); + e = beta0(e); + + if(!sameVertex(d,e)) + { + embedNewCell(VERTEX, e); + copyCell(VERTEX, e, d); + } + } + + if (isOrbitEmbedded(EDGE)) + { + embedNewCell(EDGE, e); + copyCell(EDGE, e, d); + } +} + void EmbeddedGMap3::sewVolumes(Dart d, Dart e) { //topological sewing @@ -41,7 +71,8 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) { unsigned int vEmb1 = EMBNULL ; Dart dd = d ; - do { + do + { vEmb1 = getEmbedding(VERTEX, dd); embedOrbit(VERTEX, dd, vEmb1) ; dd = phi1(dd) ; @@ -54,9 +85,10 @@ void EmbeddedGMap3::sewVolumes(Dart d, Dart e) { unsigned int vEmb1 = EMBNULL ; Dart dd = d ; - do { - vEmb1 = getEmbedding(EDGE, d); - embedOrbit(EDGE, d, vEmb1) ; + do + { + vEmb1 = getEmbedding(EDGE, dd); + embedOrbit(EDGE, dd, vEmb1) ; dd = phi1(dd) ; } while(dd != d) ; }