Commit ddb659ea authored by untereiner's avatar untereiner

begin migration of adaptive subdivision for Map3MR

parent f243d02b
......@@ -551,9 +551,9 @@ public:
} ;
} // namespace Multiresolution
} // namespace MR
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -160,48 +160,26 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
if(!me.isMarked(d))
{
//me.mark le 1 voisinage
//Mark le 1 voisinage
Dart dt = d;
do
{
Dart dit = dt;
do
Traversor2VF<typename PFP::MAP> tf(m_map, dt) ;
for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{
me.mark(m_map.phi1(dit));
me.mark(m_map.phi1(m_map.phi1(dit)));
dit = m_map.phi2(m_map.phi_1(dit));
me.markOrbit<FACE>(it);
}
while(dit != dt);
dt = m_map.phi1(dt);
}while(dt != d);
dt = m_map.phi2(d);
do
Traversor2VF<typename PFP::MAP> tf(m_map, m_map.phi_1(m_map.phi2(d))) ;
for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{
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));
me.markOrbit<FACE>(it);
}
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 ;
Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
......@@ -222,145 +200,37 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ;
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>
void Map2MR_PM<PFP>::collapseEdge(Dart d)
{
//duplication :
m_map.duplicateDart(m_map.phi2(m_map.phi1(d)));
m_map.duplicateDart(m_map.phi2(m_map.phi_1(d)));
m_map.duplicateDart(m_map.phi2(m_map.phi1(m_map.phi2(d))));
m_map.duplicateDart(m_map.phi2(m_map.phi_1(m_map.phi2(d))));
//incremente le dartLevel des brins des faces a supprimer
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)));
// //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:
/**
* 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) ;
......
......@@ -335,7 +335,7 @@ void Map2MR<PFP>::coarsenEdge(Dart d)
}
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(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
......@@ -354,9 +354,14 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad)
do
{
++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
// subdivideFace(nf) ;
if(OneLevelDifference)
{
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))
subdivideEdge(it) ; // and cut the edges (if they are not already)
it = m_map.phi1(it) ;
......@@ -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
if(degree == 3 && triQuad) // if subdividing a triangle
if(triQuad & degree == 3) // if subdividing a triangle
{
Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(dd) ;
......
......@@ -59,17 +59,19 @@ protected:
MAP& m_map;
bool shareVertexEmbeddings ;
std::vector<CGoGN::Algo::MR::Filter*> synthesisFilters ;
std::vector<CGoGN::Algo::MR::Filter*> analysisFilters ;
std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ;
public:
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 addAnalysisFilter(CGoGN::Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void addNewLevelSqrt3(bool embedNewVertices = true);
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 clearAnalysisFilters() { analysisFilters.clear() ; }
......
......@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
}
template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
void Map2MR<PFP>::addNewLevel(bool triQuad = true, bool embedNewVertices = true)
{
m_map.pushLevel() ;
......@@ -94,7 +94,7 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
unsigned int degree = m_map.faceDegree(old) ;
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 e = m_map.phi1(m_map.phi1(dd)) ;
......@@ -141,6 +141,62 @@ void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
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>
void Map2MR<PFP>::analysis()
{
......
......@@ -35,14 +35,14 @@ namespace CGoGN
namespace Algo
{
namespace Multiresolution
namespace MR
{
class MRFilter
class Filter
{
public:
MRFilter() {}
virtual ~MRFilter() {}
Filter() {}
virtual ~Filter() {}
virtual void operator() () = 0 ;
} ;
......@@ -162,7 +162,7 @@ typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute<typ
/* Loop
*********************************************************************************/
template <typename PFP>
class LoopEvenAnalysisFilter : public MRFilter
class LoopEvenAnalysisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -188,7 +188,7 @@ public:
} ;
template <typename PFP>
class LoopNormalisationAnalysisFilter : public MRFilter
class LoopNormalisationAnalysisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -218,7 +218,7 @@ public:
} ;
template <typename PFP>
class LoopOddAnalysisFilter : public MRFilter
class LoopOddAnalysisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -267,7 +267,7 @@ public:
/* Linear Interpolation
*********************************************************************************/
template <typename PFP>
class LerpEdgeSynthesisFilter : public MRFilter
class LerpEdgeSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -295,7 +295,7 @@ public:
} ;
template <typename PFP>
class LerpFaceSynthesisFilter : public MRFilter
class LerpFaceSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -325,7 +325,7 @@ public:
} ;
template <typename PFP>
class LerpVolumeSynthesisFilter : public MRFilter
class LerpVolumeSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -361,7 +361,7 @@ public:
//w-lift(a)
template <typename PFP>
class Ber02OddSynthesisFilter : public MRFilter
class Ber02OddSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -450,7 +450,7 @@ public:
// s-lift(a)
template <typename PFP>
class Ber02EvenSynthesisFilter : public MRFilter
class Ber02EvenSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -639,7 +639,7 @@ public:
// s-scale(a)
template <typename PFP>
class Ber02ScaleSynthesisFilter : public MRFilter
class Ber02ScaleSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -705,7 +705,7 @@ public:
/* Loop on Boundary Vertices and SHW04 on Insides Vertices
*********************************************************************************/
template <typename PFP>
class LoopOddSynthesisFilter : public MRFilter
class LoopOddSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -748,7 +748,7 @@ public:
} ;
template <typename PFP>
class LoopNormalisationSynthesisFilter : public MRFilter
class LoopNormalisationSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -778,7 +778,7 @@ public:
} ;
template <typename PFP>
class LoopEvenSynthesisFilter : public MRFilter
class LoopEvenSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -804,7 +804,7 @@ public:
} ;
template <typename PFP>
class LoopVolumeSynthesisFilter : public MRFilter
class LoopVolumeSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -835,7 +835,7 @@ public:
} ;
template <typename PFP>
class SHW04VolumeNormalisationSynthesisFilter : public MRFilter
class SHW04VolumeNormalisationSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -875,7 +875,7 @@ public:
/* Catmull-clark on Boundary Vertices and MJ96 on Insides Vertices
*********************************************************************************/
template <typename PFP>
class MJ96VertexSubdivision : public MRFilter
class MJ96VertexSubdivision : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -980,7 +980,7 @@ public:
};
template <typename PFP>
class MJ96EdgeSubdivision : public MRFilter
class MJ96EdgeSubdivision : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -1070,7 +1070,7 @@ public:
};
template <typename PFP>
class MJ96FaceSubdivision : public MRFilter
class MJ96FaceSubdivision : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -1130,7 +1130,7 @@ public:
};
template <typename PFP>
class MJ96VolumeSubdivision : public MRFilter
class MJ96VolumeSubdivision : public Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -1165,7 +1165,7 @@ public:
} // namespace Multiresolution
} // namespace MR
} // namespace Algo
......
......@@ -33,18 +33,37 @@
namespace CGoGN
{
namespace Algo
{
namespace MR
{
namespace Primal
{
namespace Adaptive
{
/*! \brief The class of adaptive 3-map MR
*/
class Map3MR_PrimalAdapt : public EmbeddedMap3
template <typename PFP>
class Map3MR
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
enum SubdivideType
{
S_TRI,
S_QUAD
} ;
MAP& m_map;
bool shareVertexEmbeddings;
FunctorType* vertexVertexFunctor ;
......@@ -53,10 +72,9 @@ protected:
FunctorType* volumeVertexFunctor ;
public:
Map3MR_PrimalAdapt();
virtual std::string mapTypeName() const { return "Map3MR_PrimalAdapt"; }
Map3MR(MAP& map);
private:
/*! @name Topological helping functions
*
*************************************************************************/
......@@ -66,32 +84,23 @@ public:
*/
void swapEdges(Dart d, Dart e);
//!
/*!
*