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

finalize Traversor3 (incident & adjacent)

fully operational & tested on map3 & gmap3
parent b6e9d3d2
......@@ -42,20 +42,6 @@
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
* This is a pure virtual class that can be overloaded in:
......@@ -129,8 +115,8 @@ protected:
AttributeContainer m_mrattribs ;
std::vector< AttributeMultiVector<unsigned int> > m_mrDarts;
AttributeMultiVector<unsigned char> m_mrLevels;
std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts;
AttributeMultiVector<unsigned char>* m_mrLevels;
unsigned int m_mrCurrentLevel;
......
......@@ -201,23 +201,16 @@ public:
Dart next() ;
} ;
// Traverse the edges incident to a given face
// Traverse the edges incident to a given face (equivalent to vertices)
template <typename MAP>
class Traversor2FE
class Traversor2FE : public Traversor2FV<MAP>
{
private:
MAP& m ;
Dart start ;
Dart current ;
public:
Traversor2FE(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
Traversor2FE(MAP& map, Dart dart):Traversor2FV<MAP>(map,dart){}
} ;
// Traverse the faces adjacent to a given face through sharing a common vertex
template <typename MAP>
class Traversor2FFaV
......
......@@ -355,37 +355,6 @@ Dart Traversor2FV<MAP>::next()
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
template <typename MAP>
......
......@@ -26,121 +26,326 @@
#define __TRAVERSOR3_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorCell.h"
namespace CGoGN
{
/*******************************************************************************
VERTEX CENTERED TRAVERSALS
*******************************************************************************/
// Traverse the edges incident to a given vertex
template <typename MAP>
class Traversor3VE
/**
* class Marker for Traversor usefull to combine
* several TraversorXY
*/
template <typename MAP, unsigned int ORBIT>
class MarkerForTraversor
{
private:
MAP& m ;
Dart start ;
Dart current ;
MAP& m_map ;
DartMarkerStore* m_dmark ;
CellMarkerStore* m_cmark ;
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 end() ;
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:
MAP& m ;
Dart start ;
Dart current ;
MAP& m_map ;
std::vector<Dart> m_vecDarts;
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:
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() ;
Dart next() ;
} ;
/**
* Traverse edges incident to volume
*/
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>
class Traversor3VW
class Traversor3WF: public Traversor3XY<MAP,VOLUME,FACE>
{
private:
MAP& m ;
Dart start ;
Dart current ;
public:
Traversor3WF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,FACE>(m, dart, forceDartMarker, thread) {}
};
/**
* Traverse vertices incident to face
*/
template <typename MAP>
class Traversor3FV: public Traversor3XY<MAP,FACE,VERTEX>
{
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() ;
Dart next() ;
} ;
/**
* Traverse edges incident to face
*/
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 the vertices incident to a given volume
template <typename MAP, unsigned int ORBIT>
class Traversor3WX
/**
* Traverse edges incident to vertex
*/
template <typename MAP>
class Traversor3VE: public Traversor3XY<MAP,VERTEX,EDGE>
{
private:
MAP& m ;
Dart start ;
Dart current ;
DartMarkerStore* dmark ;
CellMarkerStore* cmark ;
TraversorDartsOfOrbit<MAP> m_tradoo;
public:
Traversor3VE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,EDGE>(m, dart, forceDartMarker, thread) {}
};
/**
* Traverse faces incident to vertex
*/
template <typename MAP>
class Traversor3VF: public Traversor3XY<MAP,VERTEX,FACE>
{
public:
Traversor3WX(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ;
~Traversor3WX();
Traversor3VF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,FACE>(m, dart, forceDartMarker, thread) {}
};
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
/**
* Traverse volumes incident to vertex
*/
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>
class Traversor3WV: public Traversor3WX<MAP,VERTEX>
class Traversor3WWaV: public Traversor3XXaY<MAP,VOLUME,VERTEX>
{
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>
class Traversor3WE: public Traversor3WX<MAP,EDGE>
class Traversor3WWaE: public Traversor3XXaY<MAP,VOLUME,EDGE>
{
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>
class Traversor3WF: public Traversor3WX<MAP,FACE>
class Traversor3WWaF: public Traversor3XXaY<MAP,VOLUME,FACE>
{
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 @@
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Utils/static_assert.h"
namespace CGoGN
{
/*******************************************************************************
VERTEX CENTERED TRAVERSALS
*******************************************************************************/
// Traversor3VE
template <typename MAP>
Traversor3VE<MAP>::Traversor3VE(MAP& map, Dart dart) : m(map), start(dart)
{}
//**********************
// Marker for traversor
//**********************
template <typename MAP>
Dart Traversor3VE<MAP>::begin()
template <typename MAP, unsigned int ORBIT>
MarkerForTraversor<MAP,ORBIT>::MarkerForTraversor(MAP& map, bool forceDartMarker, unsigned int thread) :
m_map(map),
m_dmark(NULL),
m_cmark(NULL)
{
current = start ;
return current ;
if(!forceDartMarker && map.isOrbitEmbedded(ORBIT))
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>
Dart Traversor3VE<MAP>::next()
template <typename MAP, unsigned int ORBIT>
void MarkerForTraversor<MAP,ORBIT>::mark(Dart d)
{
if(current != NIL)
{
current = m.alpha1(current) ;
if(current == start)
current = NIL ;
}
return current ;
if (m_cmark)
m_cmark->mark(d);
else
m_dmark->markOrbit(ORBIT,d);
}
template <typename MAP, unsigned int ORBIT>
Traversor3WX<MAP,ORBIT>::Traversor3WX(MAP& map, Dart dart, bool forceDartMarker, unsigned int thread) :
m(map), start(dart),dmark(NULL), cmark(NULL), m_tradoo(map,VOLUME,dart,thread)
void MarkerForTraversor<MAP,ORBIT>::unmark(Dart d)
{
if(!forceDartMarker && map.isOrbitEmbedded(ORBIT))
cmark = new CellMarkerStore(map, ORBIT, thread) ;
if (m_cmark)
m_cmark->unmark(d);
else
dmark = new DartMarkerStore(map, thread) ;
m_dmark->unmarkOrbit(ORBIT,d);
}
template <typename MAP, unsigned int ORBIT>
Traversor3WX<MAP,ORBIT>::~Traversor3WX()
bool MarkerForTraversor<MAP,ORBIT>::isMarked(Dart d)
{
if (cmark)
delete cmark;
if (dmark)
delete dmark;
if (m_cmark)