From db57adecd1593f2a3d1416a66f6de4052363dd8b Mon Sep 17 00:00:00 2001 From: Thery Sylvain Date: Fri, 11 Jan 2013 15:32:51 +0100 Subject: [PATCH] specialization of TravesorCell for GenericMap --- include/Topology/generic/genericmap.h | 3 +- include/Topology/generic/genericmap.hpp | 6 + include/Topology/generic/traversorCell.h | 33 +++++ include/Topology/generic/traversorCell.hpp | 136 +++++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index ec94d52b..c3f0cf47 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -168,7 +168,7 @@ public: virtual unsigned int dimension() const = 0 ; - static const unsigned int DIMENSION = 0 ; +// static const unsigned int DIMENSION = 0 ; /** * Clear the map * @param removeAttrib @@ -741,6 +741,7 @@ public: bool isBoundaryMarked2(Dart d) const ; bool isBoundaryMarked3(Dart d) const ; + bool isBoundaryMarkedCurrent(Dart d) const ; protected: /** diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 7410eecd..6976bfa6 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -705,6 +705,12 @@ inline bool GenericMap::isBoundaryMarked(Dart d) const } +inline bool GenericMap::isBoundaryMarkedCurrent(Dart d) const +{ + return m_markTables[DART][0]->operator[](dartIndex(d)).testMark(m_boundaryMarkers[this->dimension()-2]); +} + + inline void GenericMap::boundaryMark2(Dart d) { boundaryMark<2>(d); diff --git a/include/Topology/generic/traversorCell.h b/include/Topology/generic/traversorCell.h index bfcd88c7..76f6fbf8 100644 --- a/include/Topology/generic/traversorCell.h +++ b/include/Topology/generic/traversorCell.h @@ -64,6 +64,39 @@ public: void skip(Dart d); } ; + +template +class TraversorCell : public Traversor +{ +private: + GenericMap& m ; + + AttributeContainer* cont ; + unsigned int qCurrent ; + + DartMarker* dmark ; + CellMarker* cmark ; + AttributeMultiVector* quickTraversal ; + + Dart current ; + bool firstTraversal ; + const FunctorSelect& m_good ; + +public: + TraversorCell(GenericMap& map, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) ; + + ~TraversorCell() ; + + Dart begin() ; + + Dart end() ; + + Dart next() ; + + void skip(Dart d); +} ; + + template class TraversorV : public TraversorCell { diff --git a/include/Topology/generic/traversorCell.hpp b/include/Topology/generic/traversorCell.hpp index ffebee9a..bc0f3b70 100644 --- a/include/Topology/generic/traversorCell.hpp +++ b/include/Topology/generic/traversorCell.hpp @@ -155,4 +155,140 @@ void TraversorCell::skip(Dart d) cmark->mark(d) ; } + + +//special version (partial specialization) for Genric Map +template +TraversorCell::TraversorCell(GenericMap& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : + m(map), dmark(NULL), cmark(NULL), quickTraversal(NULL), current(NIL), firstTraversal(true), m_good(good) +{ + if(forceDartMarker) + dmark = new DartMarker(map, thread) ; + else + { + quickTraversal = map.template getQuickTraversal() ; + if(quickTraversal != NULL) + { + cont = &(m.template getAttributeContainer()) ; + } + else + { + if(map.template isOrbitEmbedded()) + cmark = new CellMarker(map, thread) ; + else + dmark = new DartMarker(map, thread) ; + } + } +} + +template +TraversorCell::~TraversorCell() +{ + if(dmark) + delete dmark ; + else if(cmark) + delete cmark ; +} + +template +Dart TraversorCell::begin() +{ + if(quickTraversal != NULL) + { + qCurrent = cont->begin() ; + current = (*quickTraversal)[qCurrent] ; + } + else + { + if(!firstTraversal) + { + if(dmark) + dmark->unmarkAll() ; + else + cmark->unmarkAll() ; + } + + current = m.begin() ; + while(current != m.end() && (m.isBoundaryMarkedCurrent(current) || !m_good(current))) + m.next(current) ; + + if(current == m.end()) + current = NIL ; + else + { + if(dmark) + dmark->markOrbit(current) ; + else + cmark->mark(current) ; + } + + firstTraversal = false ; + } + + return current ; +} + +template +Dart TraversorCell::end() +{ + return NIL ; +} + +template +Dart TraversorCell::next() +{ + if(current != NIL) + { + if(quickTraversal != NULL) + { + cont->next(qCurrent) ; + current = (*quickTraversal)[qCurrent] ; + } + else + { + if(dmark) + { + bool ismarked = dmark->isMarked(current) ; + while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) || !m_good(current))) + { + m.next(current) ; + if(current == m.end()) + current = NIL ; + else + ismarked = dmark->isMarked(current) ; + } + if(current != NIL) + dmark->markOrbit(current) ; + } + else + { + bool ismarked = cmark->isMarked(current) ; + while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) || !m_good(current))) + { + m.next(current) ; + if(current == m.end()) + current = NIL ; + else + ismarked = cmark->isMarked(current) ; + } + if(current != NIL) + cmark->mark(current) ; + } + } + } + return current ; +} + +template +void TraversorCell::skip(Dart d) +{ + if(dmark) + dmark->markOrbit(d) ; + else + cmark->mark(d) ; +} + + + + } // namespace CGoGN -- GitLab