diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index ec94d52bd1f61d9d97c5a05f5787c8c4e27f914b..c3f0cf4741190ee51a04da13a0cd4a2e5991553a 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 7410eecd9adccd0719e899635bf7d7a0e65684db..6976bfa60eef5755167faa5abeb157178bd35c86 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 bfcd88c73a897db8e4feef11ad220a9cb316b3c5..76f6fbf8ffb719dda0957e09dfb8bebd06272442 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 ffebee9a7fb1d8c779166ccc06368652098d4214..bc0f3b70b7f47eff25099112ab83ad68c589ee2a 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