Commit ddb659ea authored by untereiner's avatar untereiner

begin migration of adaptive subdivision for Map3MR

parent f243d02b
...@@ -551,9 +551,9 @@ public: ...@@ -551,9 +551,9 @@ public:
} ; } ;
} // namespace Multiresolution } // namespace MR
} } // namespace Algo
} // namespace CGoGN } // namespace CGoGN
......
...@@ -160,47 +160,25 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -160,47 +160,25 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
if(!me.isMarked(d)) if(!me.isMarked(d))
{ {
//Mark le 1 voisinage
//me.mark le 1 voisinage
Dart dt = d; Dart dt = d;
do do
{ {
Dart dit = dt; Traversor2VF<typename PFP::MAP> tf(m_map, dt) ;
do for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{ {
me.mark(m_map.phi1(dit)); me.markOrbit<FACE>(it);
me.mark(m_map.phi1(m_map.phi1(dit)));
dit = m_map.phi2(m_map.phi_1(dit));
} }
while(dit != dt);
dt = m_map.phi1(dt); dt = m_map.phi1(dt);
}while(dt != d); }while(dt != d);
dt = m_map.phi2(d); Traversor2VF<typename PFP::MAP> tf(m_map, m_map.phi_1(m_map.phi2(d))) ;
do for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{ {
Dart dit = dt; me.markOrbit<FACE>(it);
do }
{
me.mark(m_map.phi1(dit));
me.mark(m_map.phi1(m_map.phi1(dit)));
dit = m_map.phi2(m_map.phi_1(dit));
}
while(dit != dt);
dt = m_map.phi1(dt);
}while(dt != m_map.phi2(d));
//incremente le dartLevel des brins des faces supprime
m_map.incDartLevel(d);
m_map.incDartLevel(m_map.phi1(d));
m_map.incDartLevel(m_map.phi_1(d));
m_map.incDartLevel(m_map.phi2(d));
m_map.incDartLevel(m_map.phi_1(m_map.phi2(d)));
m_map.incDartLevel(m_map.phi1(m_map.phi2(d)));
++nbDeletedVertex ; ++nbDeletedVertex ;
...@@ -222,145 +200,37 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -222,145 +200,37 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ; CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ;
m_map.printMR(); m_map.printMR();
// DartMarkerStore me(m_map); //mark edges not to collapse
// DartMarkerStore mc(m_map); //mark darts to collapse
// std::vector<Dart> ec; //save a dart from edge to collapse
//
// for(Dart d = m_map.begin() ; d != m_map.end() ; m_map.next(d))
// {
// if(!me.isMarked(d))
// {
// Dart dt = d;
// do
// {
// Dart dit = dt;
// do
// {
// me.mark(m_map.phi1(dit));
// me.mark(m_map.phi1(m_map.phi1(dit)));
// dit = m_map.phi2(m_map.phi_1(dit));
// }
// while(dit != dt);
//
// dt = m_map.phi1(dt);
// }while(dt != d);
//
// dt = m_map.phi2(d);
// do
// {
// Dart dit = dt;
// do
// {
// me.mark(m_map.phi1(dit));
// me.mark(m_map.phi1(m_map.phi1(dit)));
// dit = m_map.phi2(m_map.phi_1(dit));
// }
// while(dit != dt);
//
// dt = m_map.phi1(dt);
// }while(dt != m_map.phi2(d));
//
//
// ec.push_back(d);
//
// mc.mark(d);
// mc.mark(m_map.phi1(d));
// mc.mark(m_map.phi_1(d));
// mc.mark(m_map.phi2(d));
// mc.mark(m_map.phi_1(m_map.phi2(d)));
// mc.mark(m_map.phi1(m_map.phi2(d)));
// }
// }
// //create the new level
// m_map.addLevelFront();
//
// AttributeContainer& cont = m_map.getMRAttributeContainer();
// AttributeMultiVector<unsigned int>* amv = m_map.getMRDartAttributeVector(m_map.getCurrentLevel());
// for(unsigned int i = cont.begin() ; i < cont.end() ; cont.next(i))
// {
// if(mc.isMarked((*amv)[i]) || (*amv)[i] == NULL)
// {
// //mrlevel++
// }
//
//
// //(*amv)[i] = MRNULL ;
// }
//
//
// for(std::vector<Dart>::iterator it = ec.begin() ; it != ec.end() ; ++it)
// {
//
// }
// // level handling
// m_map.pushLevel() ;
// m_map.addLevelBack();
// m_map.duplicateDarts(m_map.getMaxLevel());
// m_map.setCurrentLevel(m_map.getMaxLevel());
//
// unsigned int nbVertices = m_map.template getNbOrbits<VERTEX>() ;
// unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
// CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ;
//
// bool finished = false ;
// Dart d ;
// while(!finished)
// {
// if(!m_selector->nextEdge(d))
// break ;
//
// --nbVertices ;
// Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
// Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
//
// for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
// {
// (*it)->approximate(d) ; // compute approximated attributes with its associated detail
// (*it)->saveApprox(d) ;
// }
//
// m_selector->updateBeforeCollapse(d) ; // update selector
//
// collapseEdge(d);
//
// unsigned int newV = m_map.template embedNewCell<VERTEX>(d2) ;
// unsigned int newE1 = m_map.template embedNewCell<EDGE>(d2) ;
// unsigned int newE2 = m_map.template embedNewCell<EDGE>(dd2) ;
//// vs->setApproxV(newV) ;
//// vs->setApproxE1(newE1) ;
//// vs->setApproxE2(newE2) ;
//
// for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
// (*it)->affectApprox(d2); // affect data to the resulting vertex
//
// m_selector->updateAfterCollapse(d2, dd2) ; // update selector
//
// if(nbVertices <= nbWantedVertices)
// finished = true ;
// }
//
// m_map.popLevel();
//
// CGoGNout << "..done (" << nbVertices << " vertices)" << CGoGNendl ;
} }
template <typename PFP> template <typename PFP>
void Map2MR_PM<PFP>::collapseEdge(Dart d) void Map2MR_PM<PFP>::collapseEdge(Dart d)
{ {
//duplication : //incremente le dartLevel des brins des faces a supprimer
m_map.duplicateDart(m_map.phi2(m_map.phi1(d))); m_map.incDartLevel(d);
m_map.duplicateDart(m_map.phi2(m_map.phi_1(d))); m_map.incDartLevel(m_map.phi1(d));
m_map.duplicateDart(m_map.phi2(m_map.phi1(m_map.phi2(d)))); m_map.incDartLevel(m_map.phi_1(d));
m_map.duplicateDart(m_map.phi2(m_map.phi_1(m_map.phi2(d)))); m_map.incDartLevel(m_map.phi2(d));
m_map.incDartLevel(m_map.phi_1(m_map.phi2(d)));
m_map.incDartLevel(m_map.phi1(m_map.phi2(d)));
// //duplication :
m_map.incDartLevel(m_map.phi2(m_map.phi1(d)));
m_map.incDartLevel(m_map.phi2(m_map.phi_1(d)));
m_map.incDartLevel(m_map.phi2(m_map.phi1(m_map.phi2(d))));
m_map.incDartLevel(m_map.phi2(m_map.phi_1(m_map.phi2(d))));
m_map.printMR();
m_map.duplicateDart2(m_map.phi2(m_map.phi1(d)));
m_map.duplicateDart2(m_map.phi2(m_map.phi_1(d)));
m_map.duplicateDart2(m_map.phi2(m_map.phi1(m_map.phi2(d))));
m_map.duplicateDart2(m_map.phi2(m_map.phi_1(m_map.phi2(d))));
m_map.printMR();
//m_map.collapseEdge(d);
m_map.extractTrianglePair(d); m_map.collapseEdge(d);
} }
......
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
/** /**
* subdivide the face of d to the next level * subdivide the face of d to the next level
*/ */
unsigned int subdivideFace(Dart d, bool triQuad = true) ; unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true);
unsigned int subdivideFace2(Dart d) ; unsigned int subdivideFace2(Dart d) ;
......
...@@ -335,7 +335,7 @@ void Map2MR<PFP>::coarsenEdge(Dart d) ...@@ -335,7 +335,7 @@ void Map2MR<PFP>::coarsenEdge(Dart d)
} }
template <typename PFP> template <typename PFP>
unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad) unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDifference)
{ {
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ; 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") ; assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
...@@ -354,9 +354,14 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad) ...@@ -354,9 +354,14 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad)
do do
{ {
++degree ; // compute the degree of the face ++degree ; // compute the degree of the face
// Dart nf = m_map.phi2(it) ;
// if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first if(OneLevelDifference)
// subdivideFace(nf) ; {
Dart nf = m_map.phi2(it) ;
if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first
subdivideFace(nf) ;
}
if(!edgeIsSubdivided(it)) if(!edgeIsSubdivided(it))
subdivideEdge(it) ; // and cut the edges (if they are not already) subdivideEdge(it) ; // and cut the edges (if they are not already)
it = m_map.phi1(it) ; it = m_map.phi1(it) ;
...@@ -364,7 +369,7 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad) ...@@ -364,7 +369,7 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad)
m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
if(degree == 3 && triQuad) // if subdividing a triangle if(triQuad & degree == 3) // if subdividing a triangle
{ {
Dart dd = m_map.phi1(old) ; Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(dd) ; Dart e = m_map.phi1(dd) ;
......
...@@ -59,17 +59,19 @@ protected: ...@@ -59,17 +59,19 @@ protected:
MAP& m_map; MAP& m_map;
bool shareVertexEmbeddings ; bool shareVertexEmbeddings ;
std::vector<CGoGN::Algo::MR::Filter*> synthesisFilters ; std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<CGoGN::Algo::MR::Filter*> analysisFilters ; std::vector<Algo::MR::Filter*> analysisFilters ;
public: public:
Map2MR(MAP& map) ; Map2MR(MAP& map) ;
void addNewLevel(bool embedNewVertices = true) ; void addNewLevel(bool triQuad = true, bool embedNewVertices = true) ;
void addSynthesisFilter(CGoGN::Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } void addNewLevelSqrt3(bool embedNewVertices = true);
void addAnalysisFilter(CGoGN::Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; } void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; } void clearAnalysisFilters() { analysisFilters.clear() ; }
......
...@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) : ...@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
} }
template <typename PFP> template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool embedNewVertices) void Map2MR<PFP>::addNewLevel(bool triQuad = true, bool embedNewVertices = true)
{ {
m_map.pushLevel() ; m_map.pushLevel() ;
...@@ -94,7 +94,7 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices) ...@@ -94,7 +94,7 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
unsigned int degree = m_map.faceDegree(old) ; unsigned int degree = m_map.faceDegree(old) ;
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
if(degree == 3) // if subdividing a triangle if(triQuad & degree == 3) // if subdividing a triangle
{ {
Dart dd = m_map.phi1(old) ; Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(m_map.phi1(dd)) ; Dart e = m_map.phi1(m_map.phi1(dd)) ;
...@@ -141,6 +141,62 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices) ...@@ -141,6 +141,62 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
m_map.popLevel() ; m_map.popLevel() ;
} }
template <typename PFP>
void Map2MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
{
m_map.pushLevel() ;
m_map.addLevelBack() ;
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel()) ;
DartMarkerStore m(map) ;
//split faces
TraversorF<typename PFP::MAP> t(map) ;
for (Dart dit = t.begin(); dit != t.end(); dit = t.next())
{
Dart d1 = m_map.phi1(dit);
splitFace(dit, d1) ;
cutEdge(m_map.phi_1(dit)) ;
Dart x = m_map.phi2(m_map.phi_1(dit)) ;
Dart dd = map.template phi<111>(x) ;
while(dd != x)
{
Dart next = m_map.phi1(dd) ;
splitFace(dd, m_map.phi1(x)) ;
dd = next ;
}
Dart cd = m_map.phi2(x);
if(embedNewVertices)
m_map.template embedNewCell<VERTEX>(cd) ;
Dart fit = cd ;
do
{
m.markOrbit<EDGE>(fit);
t.skip(fit);
fit = map.phi2(map.phi_1(fit));
} while(fit != cd);
}
//swap edges
TraversorE<typename PFP::MAP> te(map) ;
for (Dart dit = te.begin(); dit != te.end(); dit = te.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<EDGE>(dit);
}
}
m_map.popLevel() ;
}
template <typename PFP> template <typename PFP>
void Map2MR<PFP>::analysis() void Map2MR<PFP>::analysis()
{ {
......
...@@ -35,14 +35,14 @@ namespace CGoGN ...@@ -35,14 +35,14 @@ namespace CGoGN
namespace Algo namespace Algo
{ {
namespace Multiresolution namespace MR
{ {
class MRFilter class Filter
{ {
public: public:
MRFilter() {} Filter() {}
virtual ~MRFilter() {} virtual ~Filter() {}
virtual void operator() () = 0 ; virtual void operator() () = 0 ;
} ; } ;
...@@ -162,7 +162,7 @@ typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute<typ ...@@ -162,7 +162,7 @@ typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute<typ
/* Loop /* Loop
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
class LoopEvenAnalysisFilter : public MRFilter class LoopEvenAnalysisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -188,7 +188,7 @@ public: ...@@ -188,7 +188,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LoopNormalisationAnalysisFilter : public MRFilter class LoopNormalisationAnalysisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -218,7 +218,7 @@ public: ...@@ -218,7 +218,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LoopOddAnalysisFilter : public MRFilter class LoopOddAnalysisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -267,7 +267,7 @@ public: ...@@ -267,7 +267,7 @@ public:
/* Linear Interpolation /* Linear Interpolation
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
class LerpEdgeSynthesisFilter : public MRFilter class LerpEdgeSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -295,7 +295,7 @@ public: ...@@ -295,7 +295,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LerpFaceSynthesisFilter : public MRFilter class LerpFaceSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -325,7 +325,7 @@ public: ...@@ -325,7 +325,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LerpVolumeSynthesisFilter : public MRFilter class LerpVolumeSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -361,7 +361,7 @@ public: ...@@ -361,7 +361,7 @@ public:
//w-lift(a) //w-lift(a)
template <typename PFP> template <typename PFP>
class Ber02OddSynthesisFilter : public MRFilter class Ber02OddSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -450,7 +450,7 @@ public: ...@@ -450,7 +450,7 @@ public:
// s-lift(a) // s-lift(a)
template <typename PFP> template <typename PFP>
class Ber02EvenSynthesisFilter : public MRFilter class Ber02EvenSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -639,7 +639,7 @@ public: ...@@ -639,7 +639,7 @@ public:
// s-scale(a) // s-scale(a)
template <typename PFP> template <typename PFP>
class Ber02ScaleSynthesisFilter : public MRFilter class Ber02ScaleSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -705,7 +705,7 @@ public: ...@@ -705,7 +705,7 @@ public:
/* Loop on Boundary Vertices and SHW04 on Insides Vertices /* Loop on Boundary Vertices and SHW04 on Insides Vertices
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
class LoopOddSynthesisFilter : public MRFilter class LoopOddSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -748,7 +748,7 @@ public: ...@@ -748,7 +748,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LoopNormalisationSynthesisFilter : public MRFilter