Commit cccae9c1 authored by Sylvain Thery's avatar Sylvain Thery

quick local traversal 2/3

parent 929fb4d9
...@@ -516,15 +516,29 @@ inline void GenericMap::updateQuickLocalIncidentTraversal(MAP& map) ...@@ -516,15 +516,29 @@ inline void GenericMap::updateQuickLocalIncidentTraversal(MAP& map)
for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next()) for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
{ {
buffer.clear(); buffer.clear();
Traversor3XY<MAP,ORBIT,INCI> tra_loc(map,d); Traversor<MAP>* tra_loc = TraversorFactory<MAP>::createIncident(map, d, map.dimension(), ORBIT, INCI);
for (Dart e = tra_loc.begin(); e != tra_loc.end(); e = tra_loc.next()) for (Dart e = tra_loc->begin(); e != tra_loc->end(); e = tra_loc->next())
buffer.push_back(e); buffer.push_back(e);
delete tra_loc;
buffer.push_back(NIL); buffer.push_back(NIL);
std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)]; std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)];
vd.reserve(buffer.size()); vd.reserve(buffer.size());
vd.assign(buffer.begin(),buffer.end()); vd.assign(buffer.begin(),buffer.end());
} }
// TraversorCell<MAP,ORBIT> tra_glob(map);
// for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
// {
// buffer.clear();
// Traversor3XY<MAP,ORBIT,INCI> tra_loc(map,d);
// for (Dart e = tra_loc.begin(); e != tra_loc.end(); e = tra_loc.next())
// buffer.push_back(e);
// buffer.push_back(NIL);
// std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)];
// vd.reserve(buffer.size());
// vd.assign(buffer.begin(),buffer.end());
// }
m_quickLocalIncidentTraversal[ORBIT][INCI] = ptrVD; m_quickLocalIncidentTraversal[ORBIT][INCI] = ptrVD;
} }
...@@ -575,8 +589,8 @@ inline void GenericMap::updateQuickLocalAdjacentTraversal(MAP& map) ...@@ -575,8 +589,8 @@ inline void GenericMap::updateQuickLocalAdjacentTraversal(MAP& map)
for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next()) for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
{ {
buffer.clear(); buffer.clear();
Traversor3XXaY<MAP,ORBIT,ADJ> tra_loc(map,d); Traversor<MAP>* tra_loc = TraversorFactory<MAP>::createAdjacent(map, d, map.dimension(), ORBIT, ADJ);
for (Dart e = tra_loc.begin(); e != tra_loc.end(); e = tra_loc.next()) for (Dart e = tra_loc->begin(); e != tra_loc->end(); e = tra_loc->next())
buffer.push_back(e); buffer.push_back(e);
buffer.push_back(NIL); buffer.push_back(NIL);
...@@ -584,6 +598,19 @@ inline void GenericMap::updateQuickLocalAdjacentTraversal(MAP& map) ...@@ -584,6 +598,19 @@ inline void GenericMap::updateQuickLocalAdjacentTraversal(MAP& map)
vd.reserve(buffer.size()); vd.reserve(buffer.size());
vd.assign(buffer.begin(),buffer.end()); vd.assign(buffer.begin(),buffer.end());
} }
// TraversorCell<MAP,ORBIT> tra_glob(map);
// for (Dart d = tra_glob.begin(); d != tra_glob.end(); d = tra_glob.next())
// {
// buffer.clear();
// Traversor3XXaY<MAP,ORBIT,ADJ> tra_loc(map,d);
// for (Dart e = tra_loc.begin(); e != tra_loc.end(); e = tra_loc.next())
// buffer.push_back(e);
// buffer.push_back(NIL);
// std::vector<Dart>& vd = (*ptrVD)[getEmbedding<ORBIT>(d)];
// vd.reserve(buffer.size());
// vd.assign(buffer.begin(),buffer.end());
// }
m_quickLocalAdjacentTraversal[ORBIT][ADJ] = ptrVD; m_quickLocalAdjacentTraversal[ORBIT][ADJ] = ptrVD;
} }
......
...@@ -43,7 +43,8 @@ private: ...@@ -43,7 +43,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2VE(MAP& map, Dart dart) ; Traversor2VE(MAP& map, Dart dart) ;
...@@ -60,7 +61,8 @@ private: ...@@ -60,7 +61,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2VF(MAP& map, Dart dart) ; Traversor2VF(MAP& map, Dart dart) ;
...@@ -77,7 +79,8 @@ private: ...@@ -77,7 +79,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2VVaE(MAP& map, Dart dart) ; Traversor2VVaE(MAP& map, Dart dart) ;
...@@ -96,7 +99,8 @@ private: ...@@ -96,7 +99,8 @@ private:
Dart current ; Dart current ;
Dart stop ; Dart stop ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2VVaF(MAP& map, Dart dart) ; Traversor2VVaF(MAP& map, Dart dart) ;
...@@ -117,7 +121,8 @@ private: ...@@ -117,7 +121,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2EV(MAP& map, Dart dart) ; Traversor2EV(MAP& map, Dart dart) ;
...@@ -134,7 +139,8 @@ private: ...@@ -134,7 +139,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2EF(MAP& map, Dart dart) ; Traversor2EF(MAP& map, Dart dart) ;
...@@ -153,7 +159,8 @@ private: ...@@ -153,7 +159,8 @@ private:
Dart current ; Dart current ;
Dart stop1, stop2 ; Dart stop1, stop2 ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2EEaV(MAP& map, Dart dart) ; Traversor2EEaV(MAP& map, Dart dart) ;
...@@ -172,7 +179,8 @@ private: ...@@ -172,7 +179,8 @@ private:
Dart current ; Dart current ;
Dart stop1, stop2 ; Dart stop1, stop2 ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2EEaF(MAP& map, Dart dart) ; Traversor2EEaF(MAP& map, Dart dart) ;
...@@ -193,7 +201,8 @@ private: ...@@ -193,7 +201,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2FV(MAP& map, Dart dart) ; Traversor2FV(MAP& map, Dart dart) ;
...@@ -221,7 +230,8 @@ private: ...@@ -221,7 +230,8 @@ private:
Dart current ; Dart current ;
Dart stop ; Dart stop ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2FFaV(MAP& map, Dart dart) ; Traversor2FFaV(MAP& map, Dart dart) ;
...@@ -238,7 +248,8 @@ private: ...@@ -238,7 +248,8 @@ private:
MAP& m ; MAP& m ;
Dart start ; Dart start ;
Dart current ; Dart current ;
std::vector<Dart>* m_QLT;
std::vector<Dart>::iterator m_ItDarts;
public: public:
Traversor2FFaE(MAP& map, Dart dart) ; Traversor2FFaE(MAP& map, Dart dart) ;
......
...@@ -32,12 +32,24 @@ namespace CGoGN ...@@ -32,12 +32,24 @@ namespace CGoGN
// Traversor2VE // Traversor2VE
template <typename MAP> template <typename MAP>
Traversor2VE<MAP>::Traversor2VE(MAP& map, Dart dart) : m(map), start(dart) Traversor2VE<MAP>::Traversor2VE(MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
{} {
AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalIncidentTraversal<VERTEX,EDGE>() ;
if (quickTraversal != NULL)
{
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
}
}
template <typename MAP> template <typename MAP>
Dart Traversor2VE<MAP>::begin() Dart Traversor2VE<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -51,6 +63,11 @@ Dart Traversor2VE<MAP>::end() ...@@ -51,6 +63,11 @@ Dart Traversor2VE<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2VE<MAP>::next() Dart Traversor2VE<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
// current = m.alpha1(current) ; // current = m.alpha1(current) ;
...@@ -64,15 +81,29 @@ Dart Traversor2VE<MAP>::next() ...@@ -64,15 +81,29 @@ Dart Traversor2VE<MAP>::next()
// Traversor2VF // Traversor2VF
template <typename MAP> template <typename MAP>
Traversor2VF<MAP>::Traversor2VF(MAP& map, Dart dart) : m(map), start(dart) Traversor2VF<MAP>::Traversor2VF(MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
{ {
if(m.isBoundaryMarked2(start)) // jump over a boundary face AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalIncidentTraversal<VERTEX,FACE>() ;
start = m.phi2(m.phi_1(start)) ; if (quickTraversal != NULL)
{
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
}
else
{
if(m.isBoundaryMarked2(start)) // jump over a boundary face
start = m.phi2(m.phi_1(start)) ;
}
} }
template <typename MAP> template <typename MAP>
Dart Traversor2VF<MAP>::begin() Dart Traversor2VF<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -86,6 +117,10 @@ Dart Traversor2VF<MAP>::end() ...@@ -86,6 +117,10 @@ Dart Traversor2VF<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2VF<MAP>::next() Dart Traversor2VF<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi2(m.phi_1(current)) ; current = m.phi2(m.phi_1(current)) ;
...@@ -100,14 +135,28 @@ Dart Traversor2VF<MAP>::next() ...@@ -100,14 +135,28 @@ Dart Traversor2VF<MAP>::next()
// Traversor2VVaE // Traversor2VVaE
template <typename MAP> template <typename MAP>
Traversor2VVaE<MAP>::Traversor2VVaE(MAP& map, Dart dart) : m(map) Traversor2VVaE<MAP>::Traversor2VVaE(MAP& map, Dart dart) : m(map),m_QLT(NULL)
{ {
start = m.phi2(dart) ; AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalAdjacentTraversal<VERTEX,EDGE>() ;
if (quickTraversal != NULL)
{
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
}
else
{
start = m.phi2(dart) ;
}
} }
template <typename MAP> template <typename MAP>
Dart Traversor2VVaE<MAP>::begin() Dart Traversor2VVaE<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -121,6 +170,10 @@ Dart Traversor2VVaE<MAP>::end() ...@@ -121,6 +170,10 @@ Dart Traversor2VVaE<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2VVaE<MAP>::next() Dart Traversor2VVaE<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi_1(m.phi2(current)) ; current = m.phi_1(m.phi2(current)) ;
...@@ -133,19 +186,33 @@ Dart Traversor2VVaE<MAP>::next() ...@@ -133,19 +186,33 @@ Dart Traversor2VVaE<MAP>::next()
// Traversor2VVaF // Traversor2VVaF
template <typename MAP> template <typename MAP>
Traversor2VVaF<MAP>::Traversor2VVaF(MAP& map, Dart dart) : m(map) Traversor2VVaF<MAP>::Traversor2VVaF(MAP& map, Dart dart) : m(map),m_QLT(NULL)
{ {
if(m.isBoundaryMarked2(dart)) AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalAdjacentTraversal<VERTEX,FACE>() ;
dart = m.phi2(m.phi_1(dart)) ; if (quickTraversal != NULL)
start = m.phi1(m.phi1(dart)) ; {
if(start == dart) m_QLT = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
start = m.phi1(dart) ; }
stop = dart ; else
{
if(m.isBoundaryMarked2(dart))
dart = m.phi2(m.phi_1(dart)) ;
start = m.phi1(m.phi1(dart)) ;
if(start == dart)
start = m.phi1(dart) ;
stop = dart ;
}
} }
template <typename MAP> template <typename MAP>
Dart Traversor2VVaF<MAP>::begin() Dart Traversor2VVaF<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -159,6 +226,10 @@ Dart Traversor2VVaF<MAP>::end() ...@@ -159,6 +226,10 @@ Dart Traversor2VVaF<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2VVaF<MAP>::next() Dart Traversor2VVaF<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi1(current) ; current = m.phi1(current) ;
...@@ -189,12 +260,23 @@ Dart Traversor2VVaF<MAP>::next() ...@@ -189,12 +260,23 @@ Dart Traversor2VVaF<MAP>::next()
// Traversor2EV // Traversor2EV
template <typename MAP> template <typename MAP>
Traversor2EV<MAP>::Traversor2EV(MAP& map, Dart dart) : m(map), start(dart) Traversor2EV<MAP>::Traversor2EV(MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
{} { AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalIncidentTraversal<EDGE,VERTEX>() ;
if (quickTraversal != NULL)
{
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
}
}
template <typename MAP> template <typename MAP>
Dart Traversor2EV<MAP>::begin() Dart Traversor2EV<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -208,6 +290,10 @@ Dart Traversor2EV<MAP>::end() ...@@ -208,6 +290,10 @@ Dart Traversor2EV<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2EV<MAP>::next() Dart Traversor2EV<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi2(current) ; current = m.phi2(current) ;
...@@ -220,15 +306,29 @@ Dart Traversor2EV<MAP>::next() ...@@ -220,15 +306,29 @@ Dart Traversor2EV<MAP>::next()
// Traversor2EF // Traversor2EF
template <typename MAP> template <typename MAP>
Traversor2EF<MAP>::Traversor2EF(MAP& map, Dart dart) : m(map), start(dart) Traversor2EF<MAP>::Traversor2EF(MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
{ {
if(m.isBoundaryMarked2(start)) AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalIncidentTraversal<EDGE,FACE>() ;
start = m.phi2(current) ; if (quickTraversal != NULL)
{
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
}
else
{
if(m.isBoundaryMarked2(start))
start = m.phi2(current) ;
}
} }
template <typename MAP> template <typename MAP>
Dart Traversor2EF<MAP>::begin() Dart Traversor2EF<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -242,6 +342,10 @@ Dart Traversor2EF<MAP>::end() ...@@ -242,6 +342,10 @@ Dart Traversor2EF<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2EF<MAP>::next() Dart Traversor2EF<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi2(current) ; current = m.phi2(current) ;
...@@ -254,16 +358,30 @@ Dart Traversor2EF<MAP>::next() ...@@ -254,16 +358,30 @@ Dart Traversor2EF<MAP>::next()
// Traversor2EEaV // Traversor2EEaV
template <typename MAP> template <typename MAP>
Traversor2EEaV<MAP>::Traversor2EEaV(MAP& map, Dart dart) : m(map) Traversor2EEaV<MAP>::Traversor2EEaV(MAP& map, Dart dart) : m(map),m_QLT(NULL)
{ {
start = m.phi2(m.phi_1(dart)) ; AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickLocalAdjacentTraversal<EDGE,VERTEX>() ;
stop1 = dart ; if (quickTraversal != NULL)
stop2 = m.phi2(dart) ; {
m_QLT = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
}
else
{
start = m.phi2(m.phi_1(dart)) ;
stop1 = dart ;
stop2 = m.phi2(dart) ;
}
} }
template <typename MAP> template <typename MAP>
Dart Traversor2EEaV<MAP>::begin() Dart Traversor2EEaV<MAP>::begin()
{ {
if(m_QLT != NULL)
{
m_ItDarts = m_QLT->begin();
return *m_ItDarts++;
}
current = start ; current = start ;
return current ; return current ;
} }
...@@ -277,6 +395,10 @@ Dart Traversor2EEaV<MAP>::end() ...@@ -277,6 +395,10 @@ Dart Traversor2EEaV<MAP>::end()
template <typename MAP> template <typename MAP>
Dart Traversor2EEaV<MAP>::next() Dart Traversor2EEaV<MAP>::next()
{ {
if(m_QLT != NULL)
{
return *m_ItDarts++;
}
if(current != NIL) if(current != NIL)
{ {
current = m.phi2(m.phi_1(current)) ; current = m.phi2(m.phi_1(current)) ;
...@@ -291,16 +413,30 @@ Dart Traversor2EEaV<MAP>::next() ...@@ -291,16 +413,30 @@ Dart Traversor2EEaV<MAP>::next()
// Traversor2EEaF // Traversor2EEaF