Commit db57adec authored by Thery Sylvain's avatar Thery Sylvain

specialization of TravesorCell for GenericMap

parent aaf269c0
......@@ -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:
/**
......
......@@ -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);
......
......@@ -64,6 +64,39 @@ public:
void skip(Dart d);
} ;
template <unsigned int ORBIT>
class TraversorCell<GenericMap,ORBIT> : public Traversor<GenericMap>
{
private:
GenericMap& m ;
AttributeContainer* cont ;
unsigned int qCurrent ;
DartMarker* dmark ;
CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* 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 <typename MAP>
class TraversorV : public TraversorCell<MAP, VERTEX>
{
......
......@@ -155,4 +155,140 @@ void TraversorCell<MAP, ORBIT>::skip(Dart d)
cmark->mark(d) ;
}
//special version (partial specialization) for Genric Map
template <unsigned int ORBIT>
TraversorCell<GenericMap, ORBIT>::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<ORBIT>() ;
if(quickTraversal != NULL)
{
cont = &(m.template getAttributeContainer<ORBIT>()) ;
}
else
{
if(map.template isOrbitEmbedded<ORBIT>())
cmark = new CellMarker<ORBIT>(map, thread) ;
else
dmark = new DartMarker(map, thread) ;
}
}
}
template <unsigned int ORBIT>
TraversorCell<GenericMap, ORBIT>::~TraversorCell()
{
if(dmark)
delete dmark ;
else if(cmark)
delete cmark ;
}
template <unsigned int ORBIT>
Dart TraversorCell<GenericMap, ORBIT>::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<ORBIT>(current) ;
else
cmark->mark(current) ;
}
firstTraversal = false ;
}
return current ;
}
template <unsigned int ORBIT>
Dart TraversorCell<GenericMap, ORBIT>::end()
{
return NIL ;
}
template <unsigned int ORBIT>
Dart TraversorCell<GenericMap, ORBIT>::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<ORBIT>(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 <unsigned int ORBIT>
void TraversorCell<GenericMap, ORBIT>::skip(Dart d)
{
if(dmark)
dmark->markOrbit<ORBIT>(d) ;
else
cmark->mark(d) ;
}
} // namespace CGoGN
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