From a91ee675206786249ba154732c4c540ce2f2c017 Mon Sep 17 00:00:00 2001 From: untereiner Date: Fri, 21 Sep 2012 14:11:07 +0200 Subject: [PATCH] moving primal adaptive map2mr to algorithms --- .../Multiresolution/map2MR/filters_Primal.h | 25 +++--- .../map2MR/map2MR_PrimalAdapt.h | 36 +++++++- .../map2MR/map2MR_PrimalAdapt.hpp | 87 ++++++++++++++----- .../map2MR/map2MR_PrimalRegular.h | 10 +-- 4 files changed, 116 insertions(+), 42 deletions(-) rename include/{Topology/map => Algo/Multiresolution}/map2MR/map2MR_PrimalAdapt.h (92%) rename src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp => include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp (89%) diff --git a/include/Algo/Multiresolution/map2MR/filters_Primal.h b/include/Algo/Multiresolution/map2MR/filters_Primal.h index d761c6334..e726b278f 100644 --- a/include/Algo/Multiresolution/map2MR/filters_Primal.h +++ b/include/Algo/Multiresolution/map2MR/filters_Primal.h @@ -31,14 +31,17 @@ namespace CGoGN { -namespace Multiresolution +namespace Algo { -class MRFilter +namespace MR +{ + +class Filter { public: - MRFilter() {} - virtual ~MRFilter() {} + Filter() {} + virtual ~Filter() {} virtual void operator() () = 0 ; } ; @@ -94,7 +97,7 @@ typename PFP::VEC3 loopEvenVertex(typename PFP::MAP& map, const VertexAttribute< *********************************************************************************/ template -class LoopOddAnalysisFilter : public MRFilter +class LoopOddAnalysisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -122,7 +125,7 @@ public: } ; template -class LoopEvenAnalysisFilter : public MRFilter +class LoopEvenAnalysisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -144,7 +147,7 @@ public: } ; template -class LoopNormalisationAnalysisFilter : public MRFilter +class LoopNormalisationAnalysisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -173,7 +176,7 @@ public: *********************************************************************************/ template -class LoopOddSynthesisFilter : public MRFilter +class LoopOddSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -201,7 +204,7 @@ public: } ; template -class LoopEvenSynthesisFilter : public MRFilter +class LoopEvenSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -223,7 +226,7 @@ public: } ; template -class LoopNormalisationSynthesisFilter : public MRFilter +class LoopNormalisationSynthesisFilter : public Filter { protected: typename PFP::MAP& m_map ; @@ -550,6 +553,8 @@ public: } // namespace Multiresolution +} + } // namespace CGoGN #endif diff --git a/include/Topology/map/map2MR/map2MR_PrimalAdapt.h b/include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.h similarity index 92% rename from include/Topology/map/map2MR/map2MR_PrimalAdapt.h rename to include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.h index f1962493e..67ae5060c 100644 --- a/include/Topology/map/map2MR/map2MR_PrimalAdapt.h +++ b/include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.h @@ -34,9 +34,30 @@ namespace CGoGN { -class Map2MR_PrimalAdapt : public EmbeddedMap2 +} +namespace Algo { + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +template +class Map2MR +{ + +public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + protected: + MAP& m_map; bool shareVertexEmbeddings ; FunctorType* vertexVertexFunctor ; @@ -44,9 +65,8 @@ protected: FunctorType* faceVertexFunctor ; public: - Map2MR_PrimalAdapt() ; + Map2MR(MAP& map) ; - virtual std::string mapTypeName() const { return "Map2MR_PrimalAdapt" ; } /*************************************************** * CELLS INFORMATION * @@ -150,6 +170,16 @@ public: void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } } ; +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + } // namespace CGoGN +#include "Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp" + #endif diff --git a/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp b/include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp similarity index 89% rename from src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp rename to include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp index 285fc2b48..e8a3470d9 100644 --- a/src/Topology/map/map2MR/map2MR_PrimalAdapt.cpp +++ b/include/Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.hpp @@ -22,25 +22,39 @@ * * *******************************************************************************/ -#include "Topology/map/map2MR/map2MR_PrimalAdapt.h" +#include "Algo/Multiresolution/map2MR/map2MR_PrimalAdapt.h" namespace CGoGN { -Map2MR_PrimalAdapt::Map2MR_PrimalAdapt() : +namespace Algo +{ + +namespace MR +{ + +namespace Primal +{ + +namespace Adaptive +{ + +template +Map2MR::Map2MR(typename PFP::MAP& map) : + m_map(map), shareVertexEmbeddings(true), vertexVertexFunctor(NULL), edgeVertexFunctor(NULL), faceVertexFunctor(NULL) { - initMR() ; + } /*************************************************** * CELLS INFORMATION * ***************************************************/ - -unsigned int Map2MR_PrimalAdapt::edgeLevel(Dart d) +template +unsigned int Map2MR::edgeLevel(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"edgeLevel : called with a dart inserted after current level") ; @@ -49,7 +63,8 @@ unsigned int Map2MR_PrimalAdapt::edgeLevel(Dart d) return ld > ldd ? ld : ldd ; // insertion levels of its two darts } -unsigned int Map2MR_PrimalAdapt::faceLevel(Dart d) +template +unsigned int Map2MR::faceLevel(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"faceLevel : called with a dart inserted after current level") ; @@ -88,7 +103,8 @@ unsigned int Map2MR_PrimalAdapt::faceLevel(Dart d) return min2 ; } -Dart Map2MR_PrimalAdapt::faceOrigin(Dart d) +template +Dart Map2MR::faceOrigin(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"faceOrigin : called with a dart inserted after current level") ; @@ -105,7 +121,8 @@ Dart Map2MR_PrimalAdapt::faceOrigin(Dart d) return p ; } -Dart Map2MR_PrimalAdapt::faceOldestDart(Dart d) +template +Dart Map2MR::faceOldestDart(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"faceOldestDart : called with a dart inserted after current level") ; @@ -127,7 +144,8 @@ Dart Map2MR_PrimalAdapt::faceOldestDart(Dart d) return oldest ; } -bool Map2MR_PrimalAdapt::edgeIsSubdivided(Dart d) +template +bool Map2MR::edgeIsSubdivided(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"edgeIsSubdivided : called with a dart inserted after current level") ; @@ -144,7 +162,8 @@ bool Map2MR_PrimalAdapt::edgeIsSubdivided(Dart d) return false ; } -bool Map2MR_PrimalAdapt::edgeCanBeCoarsened(Dart d) +template +bool Map2MR::edgeCanBeCoarsened(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"edgeCanBeCoarsened : called with a dart inserted after current level") ; @@ -169,7 +188,8 @@ bool Map2MR_PrimalAdapt::edgeCanBeCoarsened(Dart d) return false ; } -bool Map2MR_PrimalAdapt::faceIsSubdivided(Dart d) +template +bool Map2MR::faceIsSubdivided(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdivided : called with a dart inserted after current level") ; @@ -188,7 +208,8 @@ bool Map2MR_PrimalAdapt::faceIsSubdivided(Dart d) return subd ; } -bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) +template +bool Map2MR::faceIsSubdividedOnce(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"faceIsSubdividedOnce : called with a dart inserted after current level") ; @@ -250,12 +271,14 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) * SUBDIVISION * ***************************************************/ -void Map2MR_PrimalAdapt::addNewLevel(bool embedNewVertices) +template +void Map2MR::addNewLevel(bool embedNewVertices) { addLevelBack() ; } -void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector* rel) +template +void Map2MR::propagateDartRelation(Dart d, AttributeMultiVector* rel) { Dart dd = (*rel)[dartIndex(d)] ; pushLevel() ; @@ -267,8 +290,9 @@ void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector template -void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d) +void Map2MR::propagateDartEmbedding(Dart d) { unsigned int emb = getEmbedding(d) ; pushLevel() ; @@ -280,8 +304,9 @@ void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d) popLevel() ; } +template template -void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) +void Map2MR::propagateOrbitEmbedding(Dart d) { unsigned int emb = getEmbedding(d) ; pushLevel() ; @@ -293,7 +318,7 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) popLevel() ; } -//Dart Map2MR_PrimalAdapt::cutEdge(Dart d) +//Dart Map2MR::cutEdge(Dart d) //{ // Dart dd = phi2(d) ; // @@ -323,7 +348,8 @@ void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d) // return d1 ; //} -Dart Map2MR_PrimalAdapt::cutEdge(Dart d) +template +Dart Map2MR::cutEdge(Dart d) { Dart dd = phi2(d) ; Dart d1 = EmbeddedMap2::cutEdge(d) ; @@ -347,7 +373,7 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d) return d1 ; } -//void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) +//void Map2MR::splitFace(Dart d, Dart e) //{ // Dart dprev = phi_1(d) ; // Dart eprev = phi_1(e) ; @@ -378,7 +404,8 @@ Dart Map2MR_PrimalAdapt::cutEdge(Dart d) // popLevel() ; //} -void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) +template +void Map2MR::splitFace(Dart d, Dart e) { Dart dprev = phi_1(d) ; Dart eprev = phi_1(e) ; @@ -401,7 +428,8 @@ void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e) propagateDartEmbedding(ee) ; } -void Map2MR_PrimalAdapt::subdivideEdge(Dart d) +template +void Map2MR::subdivideEdge(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideEdge : called with a dart inserted after current level") ; assert(!edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ; @@ -420,7 +448,8 @@ void Map2MR_PrimalAdapt::subdivideEdge(Dart d) decCurrentLevel() ; } -void Map2MR_PrimalAdapt::coarsenEdge(Dart d) +template +void Map2MR::coarsenEdge(Dart d) { 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") ; @@ -434,7 +463,8 @@ void Map2MR_PrimalAdapt::coarsenEdge(Dart d) removeLevelBack() ; } -unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) +template +unsigned int Map2MR::subdivideFace(Dart d) { assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ; assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ; @@ -520,7 +550,8 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) return fLevel ; } -void Map2MR_PrimalAdapt::coarsenFace(Dart d) +template +void Map2MR::coarsenFace(Dart d) { 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") ; @@ -568,4 +599,12 @@ void Map2MR_PrimalAdapt::coarsenFace(Dart d) removeLevelBack() ; } +} // namespace Adaptive + +} // namespace Primal + +} // namespace MR + +} // namespace Algo + } // namespace CGoGN diff --git a/include/Algo/Multiresolution/map2MR/map2MR_PrimalRegular.h b/include/Algo/Multiresolution/map2MR/map2MR_PrimalRegular.h index 760860dfd..fa0743aa4 100644 --- a/include/Algo/Multiresolution/map2MR/map2MR_PrimalRegular.h +++ b/include/Algo/Multiresolution/map2MR/map2MR_PrimalRegular.h @@ -29,7 +29,7 @@ #include "Topology/generic/traversorCell.h" #include "Topology/generic/traversor2.h" -#include "Topology/map/map2MR/filters_Primal.h" +#include "Algo/Multiresolution/map2MR/filters_Primal.h" namespace CGoGN { @@ -59,8 +59,8 @@ protected: MAP& m_map; bool shareVertexEmbeddings ; - std::vector synthesisFilters ; - std::vector analysisFilters ; + std::vector synthesisFilters ; + std::vector analysisFilters ; public: Map2MR(MAP& map) ; @@ -68,8 +68,8 @@ public: void addNewLevel(bool embedNewVertices = true) ; - void addSynthesisFilter(CGoGN::Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; } - void addAnalysisFilter(CGoGN::Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; } + void addSynthesisFilter(CGoGN::Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; } + void addAnalysisFilter(CGoGN::Algo::MR::Filter* f) { analysisFilters.push_back(f) ; } void clearSynthesisFilters() { synthesisFilters.clear() ; } void clearAnalysisFilters() { analysisFilters.clear() ; } -- GitLab