Commit 71e9d333 by untereiner

### regular primal sqrt(3) refinement

parent ddb659ea
 ... @@ -250,7 +250,104 @@ public: ... @@ -250,7 +250,104 @@ public: } } } ; } ; /********************************************************************************* * SYNTHESIS FILTERS *********************************************************************************/ /* Linear Interpolation *********************************************************************************/ template class LerpEdgeSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map ; VertexAttribute& m_position ; public: LerpEdgeSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) {} void operator() () { TraversorE trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) { typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5); m_map.incCurrentLevel() ; Dart midV = m_map.phi1(d) ; m_position[midV] = p ; m_map.decCurrentLevel() ; } } } ; template class LerpFaceSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map ; VertexAttribute& m_position ; public: LerpFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) {} void operator() () { TraversorF trav(m_map) ; for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) { typename PFP::VEC3 p = Algo::Geometry::faceCentroid(m_map, d, m_position); m_map.incCurrentLevel() ; if(m_map.faceDegree(d) != 3) { Dart midF = m_map.phi1(m_map.phi1(d)); m_position[midF] = p ; } m_map.decCurrentLevel() ; } } } ; /* SQRT(3) *********************************************************************************/ template class Sqrt3OddSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map; VertexAttribute& m_position; public: Sqrt3OddSynthesisFilter(typename PFP::MAP& m, VertexAttribute& p) : m_map(m), m_position(p) {} void operator() () { TraversorF trav(m_map); for(Dart d = trav.begin() ; d != trav.end() ; d = trav.next()) { typename PFP::VEC3 p(0.0); p += m_position[d]; p += m_position[m_map.phi1(d)]; p += m_position[m_map.phi_1(d)]; p /= 3.0; m_map.incCurrentLevel() ; Dart midF = m_map.phi1(d); m_position[midF] = p ; m_map.decCurrentLevel() ; } } }; /********************************************************************************* /********************************************************************************* ... ...
 ... @@ -143,14 +143,13 @@ void Map2MR_PM::addNewLevel(unsigned int percentWantedVertices) ... @@ -143,14 +143,13 @@ void Map2MR_PM::addNewLevel(unsigned int percentWantedVertices) unsigned int percentWantedPerLevel = 20; unsigned int percentWantedPerLevel = 20; unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ; unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ; //create the new level std::vector edges; m_map.addLevelFront(); edges.reserve(nbWantedPerLevel); m_map.setCurrentLevel(0); m_map.printMR(); DartMarkerStore me(m_map); //mark edges not to collapse DartMarkerStore me(m_map); //mark edges not to collapse std::cout << " nbWantedPerLevel : " << nbWantedPerLevel << std::endl; bool finished = false ; bool finished = false ; Dart d ; Dart d ; while(!finished) while(!finished) ... @@ -179,27 +178,41 @@ void Map2MR_PM::addNewLevel(unsigned int percentWantedVertices) ... @@ -179,27 +178,41 @@ void Map2MR_PM::addNewLevel(unsigned int percentWantedVertices) me.markOrbit(it); me.markOrbit(it); } } ++nbDeletedVertex ; ++nbDeletedVertex ; Dart d2 = m_map.phi2(m_map.phi_1(d)) ; edges.push_back(d); Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ; m_selector->updateBeforeCollapse(d) ; // update selector collapseEdge(d); std::cout << " nbDeletedVertex : " << nbDeletedVertex << std::endl; m_selector->updateAfterCollapse(d2, dd2) ; // update selector if(nbDeletedVertex <= nbWantedPerLevel) finished = true ; } } } if(nbDeletedVertex > nbWantedPerLevel) finished = true ; } CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ; m_map.printMR(); std::cout << " finished " << std::endl; // //create the new level // m_map.addLevelFront(); // m_map.setCurrentLevel(0); // // // // // // Dart d2 = m_map.phi2(m_map.phi_1(d)) ; // Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ; // // m_selector->updateBeforeCollapse(d) ; // update selector // // collapseEdge(d); // // m_selector->updateAfterCollapse(d2, dd2) ; // update selector // // // CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ; // // m_map.printMR(); } } ... ...
 ... @@ -119,14 +119,22 @@ public: ... @@ -119,14 +119,22 @@ public: */ */ bool faceIsSubdividedOnce(Dart d) ; bool faceIsSubdividedOnce(Dart d) ; /*************************************************** * SUBDIVISION * ***************************************************/ protected: /** * */ Dart cutEdge(Dart d) ; Dart cutEdge(Dart d) ; /** * */ void splitFace(Dart d, Dart e) ; void splitFace(Dart d, Dart e) ; protected: /*************************************************** * SUBDIVISION * ***************************************************/ /** /** * subdivide the edge of d to the next level * subdivide the edge of d to the next level */ */ ... @@ -143,8 +151,6 @@ public: ... @@ -143,8 +151,6 @@ public: */ */ unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); unsigned int subdivideFace2(Dart d) ; /** /** * coarsen the face of d from the next level * coarsen the face of d from the next level */ */ ... ...
 ... @@ -419,58 +419,6 @@ unsigned int Map2MR::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe ... @@ -419,58 +419,6 @@ unsigned int Map2MR::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe return fLevel ; return fLevel ; } } template unsigned int Map2MR::subdivideFace2(Dart d) { assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ; assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ; unsigned int fLevel = faceLevel(d) ; Dart old = faceOldestDart(d) ; std::cout << "face level " << fLevel << std::endl; std::cout << "oldestDart " << old << std::endl; m_map.pushLevel() ; m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges if(m_map.getCurrentLevel() == m_map.getMaxLevel()) { std::cout << "addLevelBack" << std::endl; m_map.addLevelBack(); } unsigned int degree = 3 ; Dart it = old ; if(!edgeIsSubdivided(it)) { std::cout << "1" << std::endl; subdivideEdge(it) ; } it = m_map.phi1(it) ; if(!edgeIsSubdivided(it)) { std::cout << "2" << std::endl; subdivideEdge(it) ; } it = m_map.phi1(it) ; if(!edgeIsSubdivided(it)) { std::cout << "3" << std::endl; subdivideEdge(it) ; } it = m_map.phi1(it) ; std::cout << "degree = " << degree << std::endl; m_map.popLevel() ; return fLevel ; } template template void Map2MR::coarsenFace(Dart d) void Map2MR::coarsenFace(Dart d) { { ... ...
 ... @@ -46,7 +46,7 @@ Map2MR::Map2MR(typename PFP::MAP& map) : ... @@ -46,7 +46,7 @@ Map2MR::Map2MR(typename PFP::MAP& map) : } } template template void Map2MR::addNewLevel(bool triQuad = true, bool embedNewVertices = true) void Map2MR::addNewLevel(bool triQuad, bool embedNewVertices) { { m_map.pushLevel() ; m_map.pushLevel() ; ... @@ -150,22 +150,19 @@ void Map2MR::addNewLevelSqrt3(bool embedNewVertices) ... @@ -150,22 +150,19 @@ void Map2MR::addNewLevelSqrt3(bool embedNewVertices) m_map.duplicateDarts(m_map.getMaxLevel()); m_map.duplicateDarts(m_map.getMaxLevel()); m_map.setCurrentLevel(m_map.getMaxLevel()) ; m_map.setCurrentLevel(m_map.getMaxLevel()) ; DartMarkerStore m(map) ; //split faces //split faces TraversorF t(map) ; TraversorF t(m_map) ; for (Dart dit = t.begin(); dit != t.end(); dit = t.next()) for (Dart dit = t.begin(); dit != t.end(); dit = t.next()) { { Dart d1 = m_map.phi1(dit); Dart d1 = m_map.phi1(dit); splitFace(dit, d1) ; m_map.splitFace(dit, d1) ; cutEdge(m_map.phi_1(dit)) ; m_map.cutEdge(m_map.phi_1(dit)) ; Dart x = m_map.phi2(m_map.phi_1(dit)) ; Dart x = m_map.phi2(m_map.phi_1(dit)) ; Dart dd = map.template phi<111>(x) ; Dart dd = m_map.phi1(m_map.phi1(m_map.phi1((x)))); while(dd != x) while(dd != x) { { Dart next = m_map.phi1(dd) ; Dart next = m_map.phi1(dd) ; splitFace(dd, m_map.phi1(x)) ; m_map.splitFace(dd, m_map.phi1(x)) ; dd = next ; dd = next ; } } ... @@ -177,21 +174,17 @@ void Map2MR::addNewLevelSqrt3(bool embedNewVertices) ... @@ -177,21 +174,17 @@ void Map2MR::addNewLevelSqrt3(bool embedNewVertices) Dart fit = cd ; Dart fit = cd ; do do { { m.markOrbit(fit); t.skip(fit); t.skip(fit); fit = map.phi2(map.phi_1(fit)); fit = m_map.phi2(m_map.phi_1(fit)); } while(fit != cd); } while(fit != cd); } } //swap edges //swap edges TraversorE te(map) ; TraversorE te(m_map) ; for (Dart dit = te.begin(); dit != te.end(); dit = te.next()) for (Dart dit = te.begin(); dit != te.end(); dit = te.next()) { { if(m.isMarked(dit)) if(m_map.getDartLevel(dit) < m_map.getCurrentLevel()) { m_map.flipEdge(dit); m.unmarkOrbit(dit); } } } m_map.popLevel() ; m_map.popLevel() ; ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!