Commit 056f432f authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

add cell traversors

parent cb6cd448
...@@ -34,6 +34,47 @@ namespace CGoGN ...@@ -34,6 +34,47 @@ namespace CGoGN
VERTEX CENTERED TRAVERSALS VERTEX CENTERED TRAVERSALS
*******************************************************************************/ *******************************************************************************/
// Traverse all the vertices of the map
template <typename MAP>
class TraversorV
{
private:
MAP& m ;
DartMarker mark ;
Dart current ;
public:
TraversorV(MAP& map, Dart dart) : m(map), mark(map)
{}
Dart begin()
{
mark.unmarkAll() ;
current = m.begin() ;
if(current == m.end())
current = NIL ;
else
mark.markOrbit(VERTEX, current) ;
return current ;
}
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
while(current != NIL && mark.isMarked(current))
{
m.next(current) ;
if(current == m.end())
current = NIL ;
}
if(current != NIL)
mark.markOrbit(VERTEX, current) ;
}
return current ;
}
} ;
// Traverse the edges incident to a given vertex // Traverse the edges incident to a given vertex
template <typename MAP> template <typename MAP>
class Traversor1VE class Traversor1VE
...@@ -111,6 +152,47 @@ public: ...@@ -111,6 +152,47 @@ public:
EDGE CENTERED TRAVERSALS EDGE CENTERED TRAVERSALS
*******************************************************************************/ *******************************************************************************/
// Traverse all the vertices of the map
template <typename MAP>
class TraversorE
{
private:
MAP& m ;
DartMarker mark ;
Dart current ;
public:
TraversorE(MAP& map, Dart dart) : m(map), mark(map)
{}
Dart begin()
{
mark.unmarkAll() ;
current = m.begin() ;
if(current == m.end())
current = NIL ;
else
mark.markOrbit(EDGE, current) ;
return current ;
}
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
while(current != NIL && mark.isMarked(current))
{
m.next(current) ;
if(current == m.end())
current = NIL ;
}
if(current != NIL)
mark.markOrbit(EDGE, current) ;
}
return current ;
}
} ;
// Traverse the vertices incident to a given edge // Traverse the vertices incident to a given edge
template <typename MAP> template <typename MAP>
class Traversor1EV class Traversor1EV
......
...@@ -34,6 +34,47 @@ namespace CGoGN ...@@ -34,6 +34,47 @@ namespace CGoGN
VERTEX CENTERED TRAVERSALS VERTEX CENTERED TRAVERSALS
*******************************************************************************/ *******************************************************************************/
// Traverse all the vertices of the map
template <typename MAP>
class TraversorV
{
private:
MAP& m ;
DartMarker mark ;
Dart current ;
public:
TraversorV(MAP& map, Dart dart) : m(map), mark(map)
{}
Dart begin()
{
mark.unmarkAll() ;
current = m.begin() ;
if(current == m.end())
current = NIL ;
else
mark.markOrbit(VERTEX, current) ;
return current ;
}
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
while(current != NIL && mark.isMarked(current))
{
m.next(current) ;
if(current == m.end())
current = NIL ;
}
if(current != NIL)
mark.markOrbit(VERTEX, current) ;
}
return current ;
}
} ;
// Traverse the edges incident to a given vertex // Traverse the edges incident to a given vertex
template <typename MAP> template <typename MAP>
class Traversor2VE class Traversor2VE
...@@ -169,6 +210,47 @@ public: ...@@ -169,6 +210,47 @@ public:
EDGE CENTERED TRAVERSALS EDGE CENTERED TRAVERSALS
*******************************************************************************/ *******************************************************************************/
// Traverse all the edges of the map
template <typename MAP>
class TraversorE
{
private:
MAP& m ;
DartMarker mark ;
Dart current ;
public:
TraversorE(MAP& map, Dart dart) : m(map), mark(map)
{}
Dart begin()
{
mark.unmarkAll() ;
current = m.begin() ;
if(current == m.end())
current = NIL ;
else
mark.markOrbit(EDGE, current) ;
return current ;
}
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
while(current != NIL && mark.isMarked(current))
{
m.next(current) ;
if(current == m.end())
current = NIL ;
}
if(current != NIL)
mark.markOrbit(EDGE, current) ;
}
return current ;
}
} ;
// Traverse the vertices incident to a given edge // Traverse the vertices incident to a given edge
template <typename MAP> template <typename MAP>
class Traversor2EV class Traversor2EV
...@@ -297,6 +379,47 @@ public: ...@@ -297,6 +379,47 @@ public:
FACE CENTERED TRAVERSALS FACE CENTERED TRAVERSALS
*******************************************************************************/ *******************************************************************************/
// Traverse all the faces of the map
template <typename MAP>
class TraversorF
{
private:
MAP& m ;
DartMarker mark ;
Dart current ;
public:
TraversorF(MAP& map, Dart dart) : m(map), mark(map)
{}
Dart begin()
{
mark.unmarkAll() ;
current = m.begin() ;
if(current == m.end())
current = NIL ;
else
mark.markOrbit(FACE, current) ;
return current ;
}
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
while(current != NIL && mark.isMarked(current))
{
m.next(current) ;
if(current == m.end())
current = NIL ;
}
if(current != NIL)
mark.markOrbit(FACE, current) ;
}
return current ;
}
} ;
// Traverse the vertices incident to a given face // Traverse the vertices incident to a given face
template <typename MAP> template <typename MAP>
class Traversor2FV class Traversor2FV
......
Supports Markdown
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