Commit e9e9949c authored by Pierre Kraemer's avatar Pierre Kraemer

d.index -> dartIndex(d) !!!

parent b73e64da
...@@ -198,6 +198,11 @@ public: ...@@ -198,6 +198,11 @@ public:
*/ */
void addLevel() ; void addLevel() ;
/**
* add a resolution level and duplicate all darts (use only in MRMaps)
*/
void addLevelDuplicate() ;
/** /**
* get the insertion level of a dart (use only in MRMaps) * get the insertion level of a dart (use only in MRMaps)
*/ */
......
...@@ -46,7 +46,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l) ...@@ -46,7 +46,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l)
if(l < m_mrDarts.size()) if(l < m_mrDarts.size())
m_mrCurrentLevel = l ; m_mrCurrentLevel = l ;
else else
CGoGNout << "setCurrentLevel : try to access inexisting resolution level" << CGoGNendl ; CGoGNout << "setCurrentLevel : try to access nonexistent resolution level" << CGoGNendl ;
} }
inline void GenericMap::pushLevel() inline void GenericMap::pushLevel()
...@@ -284,7 +284,7 @@ inline void GenericMap::next(Dart& d) ...@@ -284,7 +284,7 @@ inline void GenericMap::next(Dart& d)
do do
{ {
m_mrattribs.next(d.index) ; m_mrattribs.next(d.index) ;
} while ((d.index != m_mrattribs.end() ) && (getDartLevel(d.index) > m_mrCurrentLevel)) ; } while (d.index != m_mrattribs.end() && getDartLevel(d) > m_mrCurrentLevel) ;
} }
else else
m_attribs[DART].next(d.index) ; m_attribs[DART].next(d.index) ;
......
...@@ -31,189 +31,6 @@ ...@@ -31,189 +31,6 @@
namespace CGoGN namespace CGoGN
{ {
//
//template <typename MAP>
//class TraversorCell
//{
//private:
// MAP& m ;
// unsigned int m_orbit ;
// DartMarker* dmark ;
// CellMarker* cmark ;
// Dart current ;
// bool firstTraversal ;
// const FunctorSelect& m_good ;
//
//public:
// TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good = allDarts, bool forceDartMarker = false, unsigned int thread = 0) :
// m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
// {
// if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
// cmark = new CellMarker(map, m_orbit, thread) ;
// else
// dmark = new DartMarker(map, thread) ;
// }
//
// ~TraversorCell()
// {
// if(dmark)
// delete dmark ;
// else
// delete cmark ;
// }
//
// Dart begin()
// {
// if(!firstTraversal)
// {
// if(dmark)
// dmark->unmarkAll() ;
// else
// cmark->unmarkAll() ;
// }
//
// current = m.begin() ;
// while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
// m.next(current) ;
//
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
//
// firstTraversal = false ;
// return current ;
// }
//
// Dart end() { return NIL ; }
//
// Dart next()
// {
// if(current != NIL)
// {
// bool ismarked ;
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
//
// while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
// {
// m.next(current) ;
// if(current == m.end())
// current = NIL ;
// else
// {
// if(dmark)
// ismarked = dmark->isMarked(current) ;
// else
// ismarked = cmark->isMarked(current) ;
// }
// }
//
// if(current != NIL)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, current) ;
// else
// cmark->mark(current) ;
// }
// }
// return current ;
// }
//
// void mark(Dart d)
// {
// if(dmark)
// dmark->markOrbit(m_orbit, d) ;
// else
// cmark->mark(d) ;
// }
//} ;
//
//template <typename MAP>
//class TraversorV : public TraversorCell<MAP>
//{
//public:
// TraversorV(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VERTEX, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorE : public TraversorCell<MAP>
//{
//public:
// TraversorE(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, EDGE, good, thread)
// {}
//};
//
////template <typename MAP>
////class TraversorOF : public TraversorCell<MAP>
////{
////public:
//// TraversorOF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, ORIENTED_FACE, good, thread)
//// {}
////};
//
//
//template <typename MAP>
//class TraversorF : public TraversorCell<MAP>
//{
//public:
// TraversorF(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, FACE, good, thread)
// {}
//};
//
//template <typename MAP>
//class TraversorW : public TraversorCell<MAP>
//{
//public:
// TraversorW(MAP& m, const FunctorSelect& good = allDarts, unsigned int thread = 0) : TraversorCell<MAP>(m, VOLUME, good, thread)
// {}
//};
//
//
//
//template <typename MAP>
//class TraversorDartsOfOrbit
//{
//private:
// std::vector<Dart>::iterator m_current;
// std::vector<Dart> m_vd;
//
//public:
// TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0)
// {
// m_vd.reserve(16);
// FunctorStoreNotBoundary<MAP> fs(map,m_vd);
// map.foreach_dart_of_orbit(orbit, d, fs, thread);
// m_vd.push_back(NIL);
// m_current=m_vd.begin();
// }
//
// Dart begin()
// {
// m_current=m_vd.begin();
// return *m_current;
// }
//
// Dart end(){ return NIL;}
//
// Dart next()
// {
// if (*m_current != NIL)
// m_current++;
// return *m_current;
// }
//} ;
template <typename MAP> template <typename MAP>
class TraversorCell class TraversorCell
...@@ -275,13 +92,12 @@ public: ...@@ -275,13 +92,12 @@ public:
}; };
template <typename MAP> template <typename MAP>
class TraversorDartsOfOrbit class TraversorDartsOfOrbit
{ {
private: private:
std::vector<Dart>::iterator m_current; std::vector<Dart>::iterator m_current ;
std::vector<Dart> m_vd; std::vector<Dart> m_vd ;
public: public:
TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0) ; TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread = 0) ;
......
...@@ -27,7 +27,7 @@ namespace CGoGN ...@@ -27,7 +27,7 @@ namespace CGoGN
template <typename MAP> template <typename MAP>
TraversorCell<MAP>::TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : TraversorCell<MAP>::TraversorCell(MAP& map, unsigned int orbit, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good) m(map), m_orbit(orbit), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
{ {
if(!forceDartMarker && map.isOrbitEmbedded(m_orbit)) if(!forceDartMarker && map.isOrbitEmbedded(m_orbit))
cmark = new CellMarker(map, m_orbit, thread) ; cmark = new CellMarker(map, m_orbit, thread) ;
...@@ -73,10 +73,11 @@ Dart TraversorCell<MAP>::begin() ...@@ -73,10 +73,11 @@ Dart TraversorCell<MAP>::begin()
return current ; return current ;
} }
template <typename MAP> template <typename MAP>
Dart TraversorCell<MAP>::end() { return NIL ; } Dart TraversorCell<MAP>::end()
{
return NIL ;
}
template <typename MAP> template <typename MAP>
Dart TraversorCell<MAP>::next() Dart TraversorCell<MAP>::next()
...@@ -124,12 +125,11 @@ void TraversorCell<MAP>::mark(Dart d) ...@@ -124,12 +125,11 @@ void TraversorCell<MAP>::mark(Dart d)
} }
template <typename MAP> template <typename MAP>
TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread) TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit, Dart d, unsigned int thread)
{ {
m_vd.reserve(16); m_vd.reserve(16);
FunctorStoreNotBoundary<MAP> fs(map,m_vd); FunctorStoreNotBoundary<MAP> fs(map, m_vd);
map.foreach_dart_of_orbit(orbit, d, fs, thread); map.foreach_dart_of_orbit(orbit, d, fs, thread);
m_vd.push_back(NIL); m_vd.push_back(NIL);
} }
...@@ -137,7 +137,7 @@ TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit, ...@@ -137,7 +137,7 @@ TraversorDartsOfOrbit<MAP>::TraversorDartsOfOrbit(MAP& map, unsigned int orbit,
template <typename MAP> template <typename MAP>
Dart TraversorDartsOfOrbit<MAP>::begin() Dart TraversorDartsOfOrbit<MAP>::begin()
{ {
m_current=m_vd.begin(); m_current = m_vd.begin();
return *m_current; return *m_current;
} }
...@@ -155,5 +155,4 @@ Dart TraversorDartsOfOrbit<MAP>::next() ...@@ -155,5 +155,4 @@ Dart TraversorDartsOfOrbit<MAP>::next()
return *m_current; return *m_current;
} }
} } // namespace CGoGN
...@@ -67,14 +67,12 @@ inline void Map2::update_topo_shortcuts() ...@@ -67,14 +67,12 @@ inline void Map2::update_topo_shortcuts()
inline Dart Map2::newDart() inline Dart Map2::newDart()
{ {
Dart d = Map1::newDart() ; Dart d = Map1::newDart() ;
// unsigned int d_index = dartIndex(d);
(*m_phi2)[dartIndex(d)] = d ; (*m_phi2)[dartIndex(d)] = d ;
return d ; return d ;
} }
inline Dart Map2::phi2(Dart d) inline Dart Map2::phi2(Dart d)
{ {
// unsigned int d_index = dartIndex(d);
return (*m_phi2)[dartIndex(d)] ; return (*m_phi2)[dartIndex(d)] ;
} }
...@@ -139,8 +137,7 @@ inline void Map2::phi2unsew(Dart d) ...@@ -139,8 +137,7 @@ inline void Map2::phi2unsew(Dart d)
unsigned int d_index = dartIndex(d); unsigned int d_index = dartIndex(d);
Dart e = (*m_phi2)[d_index] ; Dart e = (*m_phi2)[d_index] ;
(*m_phi2)[d_index] = d ; (*m_phi2)[d_index] = d ;
unsigned int e_index = dartIndex(e); (*m_phi2)[dartIndex(e)] = e ;
(*m_phi2)[e_index] = e ;
} }
/*! @name Topological Queries /*! @name Topological Queries
......
...@@ -168,17 +168,43 @@ void GenericMap::clear(bool removeAttrib) ...@@ -168,17 +168,43 @@ void GenericMap::clear(bool removeAttrib)
void GenericMap::addLevel() void GenericMap::addLevel()
{ {
unsigned int level = m_mrDarts.size() ; unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ; std::stringstream ss ;
ss << "MRdart_"<< level ; ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ; AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ; m_mrDarts.push_back(amvMR) ;
// copy the darts pointers of the previous level // copy the darts pointers of the previous level
if(m_mrDarts.size() > 1) if(m_mrDarts.size() > 1)
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ; m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ;
} }
void GenericMap::addLevelDuplicate()
{
unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ;
// copy the darts pointers of the previous level
if(m_mrDarts.size() > 1)
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[newLevel - 1]->getIndex()) ;
// duplicate all the darts in the new level
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int oldi = amvMR->operator[](i) ;
unsigned int newi = m_attribs[DART].insertLine() ;
m_attribs[DART].copyLine(newi, oldi) ;
amvMR->operator[](i) = newi ;
for(unsigned int t = 0; t < m_nbThreads; ++t)
m_markTables[DART][t]->operator[](newi).clear() ;
}
}
/**************************************** /****************************************
* EMBEDDING MANAGEMENT * * EMBEDDING MANAGEMENT *
****************************************/ ****************************************/
...@@ -204,7 +230,7 @@ void GenericMap::setDartEmbedding(unsigned int orbit, Dart d, unsigned int emb) ...@@ -204,7 +230,7 @@ void GenericMap::setDartEmbedding(unsigned int orbit, Dart d, unsigned int emb)
if (emb != EMBNULL) if (emb != EMBNULL)
m_attribs[orbit].refLine(emb); m_attribs[orbit].refLine(emb);
// affect the embedding to the dart // affect the embedding to the dart
(*m_embeddings[orbit])[d.index] = emb ; (*m_embeddings[orbit])[dartIndex(d)] = emb ;
} }
/**************************************** /****************************************
...@@ -783,17 +809,17 @@ void GenericMap::viewAttributesTables() ...@@ -783,17 +809,17 @@ void GenericMap::viewAttributesTables()
void GenericMap::boundaryMark(Dart d) void GenericMap::boundaryMark(Dart d)
{ {
m_markTables[DART][0]->operator[](d.index).setMark(m_boundaryMarker); m_markTables[DART][0]->operator[](dartIndex(d)).setMark(m_boundaryMarker);
} }
void GenericMap::boundaryUnmark(Dart d) void GenericMap::boundaryUnmark(Dart d)
{ {
m_markTables[DART][0]->operator[](d.index).unsetMark(m_boundaryMarker); m_markTables[DART][0]->operator[](dartIndex(d)).unsetMark(m_boundaryMarker);
} }
bool GenericMap::isBoundaryMarked(Dart d) bool GenericMap::isBoundaryMarked(Dart d)
{ {
return m_markTables[DART][0]->operator[](d.index).testMark(m_boundaryMarker); return m_markTables[DART][0]->operator[](dartIndex(d)).testMark(m_boundaryMarker);
} }
void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d) void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d)
......
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