Commit 21595e5a authored by Sylvain Thery's avatar Sylvain Thery

finalize Traversor3 (incident & adjacent)

fully operational & tested on map3 & gmap3
parent b6e9d3d2
...@@ -42,20 +42,6 @@ ...@@ -42,20 +42,6 @@
namespace CGoGN namespace CGoGN
{ {
/*
const unsigned int EMBNULL = 0xffffffff;
const unsigned int NB_ORBITS = 6;
const unsigned int NB_THREAD = 16;
const unsigned int VERTEX = 0;
const unsigned int EDGE = 1;
const unsigned int ORIENTED_FACE= 2;
const unsigned int FACE = 3;
const unsigned int VOLUME = 4;
const unsigned int DART = 5;
*/
/** /**
* Class that allows to browse a map * Class that allows to browse a map
* This is a pure virtual class that can be overloaded in: * This is a pure virtual class that can be overloaded in:
...@@ -129,8 +115,8 @@ protected: ...@@ -129,8 +115,8 @@ protected:
AttributeContainer m_mrattribs ; AttributeContainer m_mrattribs ;
std::vector< AttributeMultiVector<unsigned int> > m_mrDarts; std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts;
AttributeMultiVector<unsigned char> m_mrLevels; AttributeMultiVector<unsigned char>* m_mrLevels;
unsigned int m_mrCurrentLevel; unsigned int m_mrCurrentLevel;
......
...@@ -201,23 +201,16 @@ public: ...@@ -201,23 +201,16 @@ public:
Dart next() ; Dart next() ;
} ; } ;
// Traverse the edges incident to a given face
// Traverse the edges incident to a given face (equivalent to vertices)
template <typename MAP> template <typename MAP>
class Traversor2FE class Traversor2FE : public Traversor2FV<MAP>
{ {
private:
MAP& m ;
Dart start ;
Dart current ;
public: public:
Traversor2FE(MAP& map, Dart dart) ; Traversor2FE(MAP& map, Dart dart):Traversor2FV<MAP>(map,dart){}
Dart begin() ;
Dart end() ;
Dart next() ;
} ; } ;
// Traverse the faces adjacent to a given face through sharing a common vertex // Traverse the faces adjacent to a given face through sharing a common vertex
template <typename MAP> template <typename MAP>
class Traversor2FFaV class Traversor2FFaV
......
...@@ -355,37 +355,6 @@ Dart Traversor2FV<MAP>::next() ...@@ -355,37 +355,6 @@ Dart Traversor2FV<MAP>::next()
return current ; return current ;
} }
// Traversor2FE
template <typename MAP>
Traversor2FE<MAP>::Traversor2FE(MAP& map, Dart dart) : m(map), start(dart)
{}
template <typename MAP>
Dart Traversor2FE<MAP>::begin()
{
current = start ;
return current ;
}
template <typename MAP>
Dart Traversor2FE<MAP>::end()
{
return NIL ;
}
template <typename MAP>
Dart Traversor2FE<MAP>::next()
{
if(current != NIL)
{
current = m.phi1(current) ;
if(current == start)
current = NIL ;
}
return current ;
}
// Traversor2FFaV // Traversor2FFaV
template <typename MAP> template <typename MAP>
......
...@@ -26,121 +26,326 @@ ...@@ -26,121 +26,326 @@
#define __TRAVERSOR3_H__ #define __TRAVERSOR3_H__
#include "Topology/generic/dart.h" #include "Topology/generic/dart.h"
#include "Topology/generic/traversorCell.h"
namespace CGoGN namespace CGoGN
{ {
/**
/******************************************************************************* * class Marker for Traversor usefull to combine
VERTEX CENTERED TRAVERSALS * several TraversorXY
*******************************************************************************/ */
template <typename MAP, unsigned int ORBIT>
// Traverse the edges incident to a given vertex class MarkerForTraversor
template <typename MAP>
class Traversor3VE
{ {
private: private:
MAP& m ; MAP& m_map ;
Dart start ; DartMarkerStore* m_dmark ;
Dart current ; CellMarkerStore* m_cmark ;
public: public:
Traversor3VE(MAP& map, Dart dart) ; MarkerForTraversor(MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
~MarkerForTraversor();
DartMarkerStore* dmark();
CellMarkerStore* cmark();
void mark(Dart d);
void unmark(Dart d);
bool isMarked(Dart d);
} ;
/**
* Generic class Traversor (do not use directly)
* Traverse all Y incident to X
*/
template <typename MAP, unsigned int ORBIT_X, unsigned int ORBIT_Y>
class Traversor3XY
{
private:
MAP& m_map ;
DartMarkerStore* m_dmark ;
CellMarkerStore* m_cmark ;
Dart m_current ;
TraversorDartsOfOrbit<MAP> m_tradoo;
bool m_allocated;
public:
Traversor3XY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ;
Traversor3XY(MAP& map, Dart dart, MarkerForTraversor<MAP,ORBIT_Y>& tmo, bool forceDartMarker = false, unsigned int thread = 0) ;
~Traversor3XY();
Dart begin() ; Dart begin() ;
Dart end() ; Dart end() ;
Dart next() ; Dart next() ;
} ; } ;
// Traverse the faces incident to a given vertex
template <typename MAP> /**
class Traversor3VF * Generic class Traversor (do not use directly)
* Traverse all X adjacent to X by an Y
*/
template <typename MAP, unsigned int ORB_X, unsigned int ORB_Y>
class Traversor3XXaY
{ {
private: private:
MAP& m ; MAP& m_map ;
Dart start ; std::vector<Dart> m_vecDarts;
Dart current ; std::vector<Dart>::iterator m_iter;
public:
Traversor3XXaY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0);
Dart begin();
Dart end();
Dart next();
};
/**
* Traverse vertices incident to volume
*/
template <typename MAP>
class Traversor3WV: public Traversor3XY<MAP,VOLUME,VERTEX>
{
public: public:
Traversor3VF(MAP& map, Dart dart) ; Traversor3WV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,VERTEX>(m, dart, forceDartMarker, thread) {}
};
Dart begin() ; /**
Dart end() ; * Traverse edges incident to volume
Dart next() ; */
} ; template <typename MAP>
class Traversor3WE: public Traversor3XY<MAP,VOLUME,EDGE>
{
public:
Traversor3WE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,EDGE>(m, dart, forceDartMarker, thread) {}
};
// Traverse the volumes incident to a given vertex /**
* Traverse faces incident to volume
*/
template <typename MAP> template <typename MAP>
class Traversor3VW class Traversor3WF: public Traversor3XY<MAP,VOLUME,FACE>
{ {
private: public:
MAP& m ; Traversor3WF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,FACE>(m, dart, forceDartMarker, thread) {}
Dart start ; };
Dart current ;
/**
* Traverse vertices incident to face
*/
template <typename MAP>
class Traversor3FV: public Traversor3XY<MAP,FACE,VERTEX>
{
public: public:
Traversor3VW(MAP& map, Dart dart) ; Traversor3FV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VERTEX>(m, dart, forceDartMarker, thread) {}
};
Dart begin() ; /**
Dart end() ; * Traverse edges incident to face
Dart next() ; */
} ; template <typename MAP>
class Traversor3FE: public Traversor3XY<MAP,FACE,EDGE>
{
public:
Traversor3FE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,EDGE>(m, dart, forceDartMarker, thread) {}
};
/******************************************************************************* /**
EDGE CENTERED TRAVERSALS * Traverse volumes incident to face
*******************************************************************************/ */
template <typename MAP>
class Traversor3FW: public Traversor3XY<MAP,FACE,VOLUME>
{
public:
Traversor3FW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VOLUME>(m, dart, forceDartMarker, thread) {}
};
/**
* Traverse vertices incident to edge
*/
template <typename MAP>
class Traversor3EV: public Traversor3XY<MAP,EDGE,VERTEX>
{
public:
Traversor3EV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VERTEX>(m, dart, forceDartMarker, thread) {}
};
/******************************************************************************* /**
FACE CENTERED TRAVERSALS * Traverse faces incident to edge
*******************************************************************************/ */
template <typename MAP>
class Traversor3EF: public Traversor3XY<MAP,EDGE,FACE>
{
public:
Traversor3EF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,FACE>(m, dart, forceDartMarker, thread) {}
};
/**
* Traverse volumes incident to edge
*/
template <typename MAP>
class Traversor3EW: public Traversor3XY<MAP,EDGE,VOLUME>
{
public:
Traversor3EW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VOLUME>(m, dart, forceDartMarker, thread) {}
};
/*******************************************************************************
VOLUME CENTERED TRAVERSALS /**
*******************************************************************************/ * Traverse edges incident to vertex
// Traverse the vertices incident to a given volume */
template <typename MAP, unsigned int ORBIT> template <typename MAP>
class Traversor3WX class Traversor3VE: public Traversor3XY<MAP,VERTEX,EDGE>
{ {
private: public:
MAP& m ; Traversor3VE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,EDGE>(m, dart, forceDartMarker, thread) {}
Dart start ; };
Dart current ;
DartMarkerStore* dmark ;
CellMarkerStore* cmark ;
TraversorDartsOfOrbit<MAP> m_tradoo;
/**
* Traverse faces incident to vertex
*/
template <typename MAP>
class Traversor3VF: public Traversor3XY<MAP,VERTEX,FACE>
{
public: public:
Traversor3WX(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ; Traversor3VF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,FACE>(m, dart, forceDartMarker, thread) {}
~Traversor3WX(); };
Dart begin() ; /**
Dart end() ; * Traverse volumes incident to vertex
Dart next() ; */
} ; template <typename MAP>
class Traversor3VW: public Traversor3XY<MAP,VERTEX,VOLUME>
{
public:
Traversor3VW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,VOLUME>(m, dart, forceDartMarker, thread) {}
};
/**
* Traverse vertices adjacent to a vertex by an edge
*/
template <typename MAP>
class Traversor3VVaE: public Traversor3XXaY<MAP,VERTEX,EDGE>
{
public:
Traversor3VVaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,EDGE>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse vertices adjacent to a vertex by a face
*/
template <typename MAP>
class Traversor3VVaF: public Traversor3XXaY<MAP,VERTEX,FACE>
{
public:
Traversor3VVaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,FACE>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse vertices adjacent to a vertex by a volume
*/
template <typename MAP>
class Traversor3VVaW: public Traversor3XXaY<MAP,VERTEX,VOLUME>
{
public:
Traversor3VVaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,VOLUME>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse edges adjacent to an egde by a vertex
*/
template <typename MAP>
class Traversor3EEaV: public Traversor3XXaY<MAP,EDGE,VERTEX>
{
public:
Traversor3EEaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VERTEX>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse edges adjacent to an egde by a face
*/
template <typename MAP>
class Traversor3EEaF: public Traversor3XXaY<MAP,EDGE,FACE>
{
public:
Traversor3EEaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,FACE>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse edges adjacent to an egde by a volume
*/
template <typename MAP>
class Traversor3EEaW: public Traversor3XXaY<MAP,EDGE,VOLUME>
{
public:
Traversor3EEaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VOLUME>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse faces adjacent to a face by a vertex
*/
template <typename MAP>
class Traversor3FFaV: public Traversor3XXaY<MAP,FACE,VERTEX>
{
public:
Traversor3FFaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VERTEX>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse faces adjacent to a face by an edge
*/
template <typename MAP>
class Traversor3FFaE: public Traversor3XXaY<MAP,FACE,EDGE>
{
public:
Traversor3FFaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,EDGE>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse faces adjacent to a face by a volume
*/
template <typename MAP>
class Traversor3FFaW: public Traversor3XXaY<MAP,FACE,VOLUME>
{
public:
Traversor3FFaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VOLUME>(m, d, forceDartMarker, thread) {}
};
/**
* Traverse volumes adjacent to a volumee by a vertex
*/
template <typename MAP> template <typename MAP>
class Traversor3WV: public Traversor3WX<MAP,VERTEX> class Traversor3WWaV: public Traversor3XXaY<MAP,VOLUME,VERTEX>
{ {
public: public:
Traversor3WV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3WX<MAP,VERTEX>(m, dart, forceDartMarker, thread) {} Traversor3WWaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,VERTEX>(m, d, forceDartMarker, thread) {}
}; };
/**
* Traverse volumes adjacent to a volumee by an edge
*/
template <typename MAP> template <typename MAP>
class Traversor3WE: public Traversor3WX<MAP,EDGE> class Traversor3WWaE: public Traversor3XXaY<MAP,VOLUME,EDGE>
{ {
public: public:
Traversor3WE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3WX<MAP,EDGE>(m, dart, forceDartMarker, thread) {} Traversor3WWaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,EDGE>(m, d, forceDartMarker, thread) {}
}; };
/**
* Traverse volumes adjacent to a volumee by a face
*/
template <typename MAP> template <typename MAP>
class Traversor3WF: public Traversor3WX<MAP,FACE> class Traversor3WWaF: public Traversor3XXaY<MAP,VOLUME,FACE>
{ {
public: public:
Traversor3WF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3WX<MAP,FACE>(m, dart, forceDartMarker, thread) {} Traversor3WWaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,FACE>(m, d, forceDartMarker, thread) {}
}; };
......
...@@ -21,102 +21,222 @@ ...@@ -21,102 +21,222 @@
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#include "Utils/static_assert.h"
namespace CGoGN namespace CGoGN
{ {
/******************************************************************************* //**********************
VERTEX CENTERED TRAVERSALS // Marker for traversor
*******************************************************************************/ //**********************
// Traversor3VE
template <typename MAP>
Traversor3VE<MAP>::Traversor3VE(MAP& map, Dart dart) : m(map), start(dart)
{}
template <typename MAP> template <typename MAP, unsigned int ORBIT>
Dart Traversor3VE<MAP>::begin() MarkerForTraversor<MAP,ORBIT>::MarkerForTraversor(MAP& map, bool forceDartMarker, unsigned int thread) :
m_map(map),
m_dmark(NULL),
m_cmark(NULL)
{ {
current = start ; if(!forceDartMarker && map.isOrbitEmbedded(ORBIT))
return current ; m_cmark = new CellMarkerStore(map, ORBIT, thread) ;
else
m_dmark = new DartMarkerStore(map, thread) ;
} }
template <typename MAP>
Dart Traversor3VE<MAP>::end() template <typename MAP, unsigned int ORBIT>
MarkerForTraversor<MAP,ORBIT>::~MarkerForTraversor()
{ {
return NIL ; if (m_cmark)
delete m_cmark;
if (m_dmark)
delete m_dmark;
} }
template <typename MAP> template <typename MAP, unsigned int ORBIT>
Dart Traversor3VE<MAP>::next() void MarkerForTraversor<MAP,ORBIT>::mark(Dart d)
{ {
if(current != NIL) if (m_cmark)
{ m_cmark->mark(d);
current = m.alpha1(current) ; else
if(current == start) m_dmark->markOrbit(ORBIT,d);
current = NIL ;