Commit a91ee675 authored by untereiner's avatar untereiner
Browse files

moving primal adaptive map2mr to algorithms

parent 7d1ab606
...@@ -31,14 +31,17 @@ ...@@ -31,14 +31,17 @@
namespace CGoGN namespace CGoGN
{ {
namespace Multiresolution namespace Algo
{ {
class MRFilter namespace MR
{
class Filter
{ {
public: public:
MRFilter() {} Filter() {}
virtual ~MRFilter() {} virtual ~Filter() {}
virtual void operator() () = 0 ; virtual void operator() () = 0 ;
} ; } ;
...@@ -94,7 +97,7 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute< ...@@ -94,7 +97,7 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute<
*********************************************************************************/ *********************************************************************************/
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 ;
...@@ -122,7 +125,7 @@ public: ...@@ -122,7 +125,7 @@ public:
} ; } ;
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 ;
...@@ -144,7 +147,7 @@ public: ...@@ -144,7 +147,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 ;
...@@ -173,7 +176,7 @@ public: ...@@ -173,7 +176,7 @@ public:
*********************************************************************************/ *********************************************************************************/
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 ;
...@@ -201,7 +204,7 @@ public: ...@@ -201,7 +204,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LoopEvenSynthesisFilter : public MRFilter class LoopEvenSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -223,7 +226,7 @@ public: ...@@ -223,7 +226,7 @@ public:
} ; } ;
template <typename PFP> template <typename PFP>
class LoopNormalisationSynthesisFilter : public MRFilter class LoopNormalisationSynthesisFilter : public Filter
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
...@@ -550,6 +553,8 @@ public: ...@@ -550,6 +553,8 @@ public:
} // namespace Multiresolution } // namespace Multiresolution
}
} // namespace CGoGN } // namespace CGoGN
#endif #endif
......
...@@ -34,9 +34,30 @@ ...@@ -34,9 +34,30 @@
namespace CGoGN namespace CGoGN
{ {
class Map2MR_PrimalAdapt : public EmbeddedMap2 }
namespace Algo
{ {
namespace MR
{
namespace Primal
{
namespace Adaptive
{
template <typename PFP>
class Map2MR
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected: protected:
MAP& m_map;
bool shareVertexEmbeddings ; bool shareVertexEmbeddings ;
FunctorType* vertexVertexFunctor ; FunctorType* vertexVertexFunctor ;
...@@ -44,9 +65,8 @@ protected: ...@@ -44,9 +65,8 @@ protected:
FunctorType* faceVertexFunctor ; FunctorType* faceVertexFunctor ;
public: public:
Map2MR_PrimalAdapt() ; Map2MR(MAP& map) ;
virtual std::string mapTypeName() const { return "Map2MR_PrimalAdapt" ; }
/*************************************************** /***************************************************
* CELLS INFORMATION * * CELLS INFORMATION *
...@@ -150,6 +170,16 @@ public: ...@@ -150,6 +170,16 @@ public:
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
} ; } ;
} // namespace Adaptive
} // namespace Primal
} // namespace MR
} // namespace Algo
} // namespace CGoGN } // namespace CGoGN
#include "Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp"
#endif #endif
...@@ -22,25 +22,39 @@ ...@@ -22,25 +22,39 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Topology/map/map2MR/map2MR_PrimalAdapt.h" #include "Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.h"
namespace CGoGN namespace CGoGN
{ {
Map2MR_PrimalAdapt::Map2MR_PrimalAdapt() : namespace Algo
{
namespace MR
{
namespace Primal
{
namespace Adaptive
{
template <typename PFP>
Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(true), shareVertexEmbeddings(true),
vertexVertexFunctor(NULL), vertexVertexFunctor(NULL),
edgeVertexFunctor(NULL), edgeVertexFunctor(NULL),
faceVertexFunctor(NULL) faceVertexFunctor(NULL)
{ {
initMR() ;
} }
/*************************************************** /***************************************************
* CELLS INFORMATION * * CELLS INFORMATION *
***************************************************/ ***************************************************/
template <typename PFP>
unsigned int Map2MR_PrimalAdapt::edgeLevel(Dart d) unsigned int Map2MR<PFP>::edgeLevel(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeLevel : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"edgeLevel : called with a dart inserted after current level") ;
...@@ -49,7 +63,8 @@ unsigned int Map2MR_PrimalAdapt::edgeLevel(Dart d) ...@@ -49,7 +63,8 @@ unsigned int Map2MR_PrimalAdapt::edgeLevel(Dart d)
return ld > ldd ? ld : ldd ; // insertion levels of its two darts return ld > ldd ? ld : ldd ; // insertion levels of its two darts
} }
unsigned int Map2MR_PrimalAdapt::faceLevel(Dart d) template <typename PFP>
unsigned int Map2MR<PFP>::faceLevel(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"faceLevel : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"faceLevel : called with a dart inserted after current level") ;
...@@ -88,7 +103,8 @@ unsigned int Map2MR_PrimalAdapt::faceLevel(Dart d) ...@@ -88,7 +103,8 @@ unsigned int Map2MR_PrimalAdapt::faceLevel(Dart d)
return min2 ; return min2 ;
} }
Dart Map2MR_PrimalAdapt::faceOrigin(Dart d) template <typename PFP>
Dart Map2MR<PFP>::faceOrigin(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"faceOrigin : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"faceOrigin : called with a dart inserted after current level") ;
...@@ -105,7 +121,8 @@ Dart Map2MR_PrimalAdapt::faceOrigin(Dart d) ...@@ -105,7 +121,8 @@ Dart Map2MR_PrimalAdapt::faceOrigin(Dart d)
return p ; return p ;
} }
Dart Map2MR_PrimalAdapt::faceOldestDart(Dart d) template <typename PFP>
Dart Map2MR<PFP>::faceOldestDart(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"faceOldestDart : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"faceOldestDart : called with a dart inserted after current level") ;
...@@ -127,7 +144,8 @@ Dart Map2MR_PrimalAdapt::faceOldestDart(Dart d) ...@@ -127,7 +144,8 @@ Dart Map2MR_PrimalAdapt::faceOldestDart(Dart d)
return oldest ; return oldest ;
} }
bool Map2MR_PrimalAdapt::edgeIsSubdivided(Dart d) template <typename PFP>
bool Map2MR<PFP>::edgeIsSubdivided(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeIsSubdivided : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"edgeIsSubdivided : called with a dart inserted after current level") ;
...@@ -144,7 +162,8 @@ bool Map2MR_PrimalAdapt::edgeIsSubdivided(Dart d) ...@@ -144,7 +162,8 @@ bool Map2MR_PrimalAdapt::edgeIsSubdivided(Dart d)
return false ; return false ;
} }
bool Map2MR_PrimalAdapt::edgeCanBeCoarsened(Dart d) template <typename PFP>
bool Map2MR<PFP>::edgeCanBeCoarsened(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"edgeCanBeCoarsened : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"edgeCanBeCoarsened : called with a dart inserted after current level") ;
...@@ -169,7 +188,8 @@ bool Map2MR_PrimalAdapt::edgeCanBeCoarsened(Dart d) ...@@ -169,7 +188,8 @@ bool Map2MR_PrimalAdapt::edgeCanBeCoarsened(Dart d)
return false ; return false ;
} }
bool Map2MR_PrimalAdapt::faceIsSubdivided(Dart d) template <typename PFP>
bool Map2MR<PFP>::faceIsSubdivided(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdivided : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdivided : called with a dart inserted after current level") ;
...@@ -188,7 +208,8 @@ bool Map2MR_PrimalAdapt::faceIsSubdivided(Dart d) ...@@ -188,7 +208,8 @@ bool Map2MR_PrimalAdapt::faceIsSubdivided(Dart d)
return subd ; return subd ;
} }
bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) template <typename PFP>
bool Map2MR<PFP>::faceIsSubdividedOnce(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdividedOnce : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdividedOnce : called with a dart inserted after current level") ;
...@@ -250,12 +271,14 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) ...@@ -250,12 +271,14 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d)
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
void Map2MR_PrimalAdapt::addNewLevel(bool embedNewVertices) template <typename PFP>
void Map2MR<PFP>::addNewLevel(bool embedNewVertices)
{ {
addLevelBack() ; addLevelBack() ;
} }
void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector<Dart>* rel) template <typename PFP>
void Map2MR<PFP>::propagateDartRelation(Dart d, AttributeMultiVector<Dart>* rel)
{ {
Dart dd = (*rel)[dartIndex(d)] ; Dart dd = (*rel)[dartIndex(d)] ;
pushLevel() ; pushLevel() ;
...@@ -267,8 +290,9 @@ void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector<Dart ...@@ -267,8 +290,9 @@ void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector<Dart
popLevel() ; popLevel() ;
} }
template <typename PFP>
template <unsigned int ORBIT> template <unsigned int ORBIT>
void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d) void Map2MR<PFP>::propagateDartEmbedding(Dart d)
{ {
unsigned int emb = getEmbedding<ORBIT>(d) ; unsigned int emb = getEmbedding<ORBIT>(d) ;
pushLevel() ; pushLevel() ;
...@@ -280,8 +304,9 @@ void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d) ...@@ -280,8 +304,9 @@ void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d)
popLevel() ; popLevel() ;
} }
template <typename PFP>
template <unsigned int ORBIT> template <unsigned int ORBIT>
void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) void Map2MR<PFP>::propagateOrbitEmbedding(Dart d)
{ {
unsigned int emb = getEmbedding<ORBIT>(d) ; unsigned int emb = getEmbedding<ORBIT>(d) ;
pushLevel() ; pushLevel() ;
...@@ -293,7 +318,7 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) ...@@ -293,7 +318,7 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d)
popLevel() ; popLevel() ;
} }
//Dart Map2MR_PrimalAdapt::cutEdge(Dart d) //Dart Map2MR::cutEdge(Dart d)
//{ //{
// Dart dd = phi2(d) ; // Dart dd = phi2(d) ;
// //
...@@ -323,7 +348,8 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) ...@@ -323,7 +348,8 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d)
// return d1 ; // return d1 ;
//} //}
Dart Map2MR_PrimalAdapt::cutEdge(Dart d) template <typename PFP>
Dart Map2MR<PFP>::cutEdge(Dart d)
{ {
Dart dd = phi2(d) ; Dart dd = phi2(d) ;
Dart d1 = EmbeddedMap2::cutEdge(d) ; Dart d1 = EmbeddedMap2::cutEdge(d) ;
...@@ -347,7 +373,7 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d) ...@@ -347,7 +373,7 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d)
return d1 ; return d1 ;
} }
//void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) //void Map2MR::splitFace(Dart d, Dart e)
//{ //{
// Dart dprev = phi_1(d) ; // Dart dprev = phi_1(d) ;
// Dart eprev = phi_1(e) ; // Dart eprev = phi_1(e) ;
...@@ -378,7 +404,8 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d) ...@@ -378,7 +404,8 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d)
// popLevel() ; // popLevel() ;
//} //}
void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) template <typename PFP>
void Map2MR<PFP>::splitFace(Dart d, Dart e)
{ {
Dart dprev = phi_1(d) ; Dart dprev = phi_1(d) ;
Dart eprev = phi_1(e) ; Dart eprev = phi_1(e) ;
...@@ -401,7 +428,8 @@ void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) ...@@ -401,7 +428,8 @@ void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e)
propagateDartEmbedding<VERTEX>(ee) ; propagateDartEmbedding<VERTEX>(ee) ;
} }
void Map2MR_PrimalAdapt::subdivideEdge(Dart d) template <typename PFP>
void Map2MR<PFP>::subdivideEdge(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideEdge : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideEdge : called with a dart inserted after current level") ;
assert(!edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ; assert(!edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ;
...@@ -420,7 +448,8 @@ void Map2MR_PrimalAdapt::subdivideEdge(Dart d) ...@@ -420,7 +448,8 @@ void Map2MR_PrimalAdapt::subdivideEdge(Dart d)
decCurrentLevel() ; decCurrentLevel() ;
} }
void Map2MR_PrimalAdapt::coarsenEdge(Dart d) template <typename PFP>
void Map2MR<PFP>::coarsenEdge(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"coarsenEdge : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"coarsenEdge : called with a dart inserted after current level") ;
assert(edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ; assert(edgeCanBeCoarsened(d) || !"Trying to coarsen an edge that can not be coarsened") ;
...@@ -434,7 +463,8 @@ void Map2MR_PrimalAdapt::coarsenEdge(Dart d) ...@@ -434,7 +463,8 @@ void Map2MR_PrimalAdapt::coarsenEdge(Dart d)
removeLevelBack() ; removeLevelBack() ;
} }
unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) template <typename PFP>
unsigned int Map2MR<PFP>::subdivideFace(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ; assert(getDartLevel(d) <= 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") ;
...@@ -520,7 +550,8 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) ...@@ -520,7 +550,8 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
return fLevel ; return fLevel ;
} }
void Map2MR_PrimalAdapt::coarsenFace(Dart d) template <typename PFP>
void Map2MR<PFP>::coarsenFace(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"coarsenFace : called with a dart inserted after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"coarsenFace : called with a dart inserted after current level") ;
assert(faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ; assert(faceIsSubdividedOnce(d) || !"Trying to coarsen a non-subdivided face or a more than once subdivided face") ;
...@@ -568,4 +599,12 @@ void Map2MR_PrimalAdapt::coarsenFace(Dart d) ...@@ -568,4 +599,12 @@ void Map2MR_PrimalAdapt::coarsenFace(Dart d)
removeLevelBack() ; removeLevelBack() ;
} }
} // namespace Adaptive
} // namespace Primal
} // namespace MR
} // namespace Algo
} // namespace CGoGN } // namespace CGoGN
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h" #include "Topology/generic/traversor2.h"
#include "Topology/map/map2MR/filters_Primal.h" #include "Algo/Multiresolution/map2MR/filters_Primal.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -59,8 +59,8 @@ protected: ...@@ -59,8 +59,8 @@ protected:
MAP& m_map; MAP& m_map;
bool shareVertexEmbeddings ; bool shareVertexEmbeddings ;
std::vector<CGoGN::Multiresolution::MRFilter*> synthesisFilters ; std::vector<CGoGN::Algo::MR::Filter*> synthesisFilters ;
std::vector<CGoGN::Multiresolution::MRFilter*> analysisFilters ; std::vector<CGoGN::Algo::MR::Filter*> analysisFilters ;
public: public:
Map2MR(MAP& map) ; Map2MR(MAP& map) ;
...@@ -68,8 +68,8 @@ public: ...@@ -68,8 +68,8 @@ public:
void addNewLevel(bool embedNewVertices = true) ; void addNewLevel(bool embedNewVertices = true) ;
void addSynthesisFilter(CGoGN::Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; } void addSynthesisFilter(CGoGN::Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(CGoGN::Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; } void addAnalysisFilter(CGoGN::Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; } void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; } void clearAnalysisFilters() { analysisFilters.clear() ; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment