Commit 9ea67fa3 authored by Sylvain Thery's avatar Sylvain Thery

add generic Traversor2 factory

add generic drawerCell(s)
simplification of showTraversors
parent 0421fd67
This diff is collapsed.
......@@ -90,22 +90,22 @@ class MyQT: public Utils::QT::SimpleQT
bool m_showTopo;
unsigned int m_val_combo1;
unsigned int m_val_combo2;
unsigned int m_val_combo3;
unsigned int m_val_combo4;
unsigned int m_val_combo5;
unsigned int m_val_combo6;
unsigned int m_first3;
unsigned int m_ajd_or_inci3;
unsigned int m_second3;
unsigned int m_first2;
unsigned int m_ajd_or_inci2;
unsigned int m_second2;
public:
MyQT():
m_render_topo(NULL),
m_showTopo(true),
m_val_combo1(1),
m_val_combo2(1),
m_val_combo3(2),
m_val_combo4(1),
m_val_combo5(1),
m_val_combo6(2),
m_first3(0),
m_ajd_or_inci3(0),
m_second3(1),
m_first2(0),
m_ajd_or_inci2(0),
m_second2(1),
m_selected(NIL)
{}
......
......@@ -33,6 +33,31 @@ namespace Algo
{
namespace Render
{
/**
* add a cell to a drawer
* @param the cell (VERTEX,EDGE,...)
* * @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerCells(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions);
/**
* add a set of volumes to a drawer
* @param the cell (VERTEX,EDGE,...)
* @param dr the drawer to use
* @param map the map
* @param vd the darts
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerCell(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions);
/**
* add a set of vertices to a drawer
......@@ -87,7 +112,6 @@ void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>&
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions);
......
......@@ -145,6 +145,51 @@ void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typen
drawerAddVolume<PFP>(dr,map,d,positions,k);
dr.end();
}
template<typename PFP>
void drawerCells(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions, float k)
{
switch(cell)
{
case VERTEX:
drawerVertices<PFP>(dr, map, vd, positions);
break;
case EDGE:
drawerEdges<PFP>(dr, map, vd, positions,k);
break;
case FACE:
drawerFaces<PFP>(dr, map, vd, positions,k);
break;
case VOLUME:
drawerVolumes<PFP>(dr, map, vd, positions,k);
break;
default:
break;
}
}
template<typename PFP>
void drawerCell(unsigned int cell, Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, float k)
{
switch(cell)
{
case VERTEX:
drawerVertex<PFP>(dr, map, d, positions);
break;
case EDGE:
drawerEdge<PFP>(dr, map, d, positions,k);
break;
case FACE:
drawerFace<PFP>(dr, map, d, positions,k);
break;
case VOLUME:
drawerVolume<PFP>(dr, map, d, positions,k);
break;
default:
break;
}
}
}
}
......
......@@ -29,14 +29,32 @@
namespace CGoGN
{
/*******************************************************************************
GENERIC TRAVERSALS FACTORY
*******************************************************************************/
template <typename MAP>
class Traversor2
{
public:
virtual ~Traversor2() {}
virtual Dart begin() =0;
virtual Dart end() =0;
virtual Dart next() =0;
static Traversor2<MAP>* createIncident(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY);
static Traversor2<MAP>* createAdjacent(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY);
};
/*******************************************************************************
VERTEX CENTERED TRAVERSALS
*******************************************************************************/
// Traverse the edges incident to a given vertex
template <typename MAP>
class Traversor2VE
class Traversor2VE : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -53,7 +71,7 @@ public:
// Traverse the faces incident to a given vertex
template <typename MAP>
class Traversor2VF
class Traversor2VF : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -70,7 +88,7 @@ public:
// Traverse the vertices adjacent to a given vertex through sharing a common edge
template <typename MAP>
class Traversor2VVaE
class Traversor2VVaE : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -87,7 +105,7 @@ public:
// Traverse the vertices adjacent to a given vertex through sharing a common face
template <typename MAP>
class Traversor2VVaF
class Traversor2VVaF : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -110,7 +128,7 @@ public:
// Traverse the vertices incident to a given edge
template <typename MAP>
class Traversor2EV
class Traversor2EV : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -127,7 +145,7 @@ public:
// Traverse the faces incident to a given edge
template <typename MAP>
class Traversor2EF
class Traversor2EF : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -144,7 +162,7 @@ public:
// Traverse the edges adjacent to a given edge through sharing a common vertex
template <typename MAP>
class Traversor2EEaV
class Traversor2EEaV : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -163,7 +181,7 @@ public:
// Traverse the edges adjacent to a given edge through sharing a common face
template <typename MAP>
class Traversor2EEaF
class Traversor2EEaF : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -186,7 +204,7 @@ public:
// Traverse the vertices incident to a given face
template <typename MAP>
class Traversor2FV
class Traversor2FV : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -204,7 +222,7 @@ public:
// Traverse the edges incident to a given face (equivalent to vertices)
template <typename MAP>
class Traversor2FE : public Traversor2FV<MAP>
class Traversor2FE: public Traversor2FV<MAP>
{
public:
Traversor2FE(MAP& map, Dart dart):Traversor2FV<MAP>(map,dart){}
......@@ -213,7 +231,7 @@ public:
// Traverse the faces adjacent to a given face through sharing a common vertex
template <typename MAP>
class Traversor2FFaV
class Traversor2FFaV : public Traversor2<MAP>
{
private:
MAP& m ;
......@@ -232,7 +250,7 @@ public:
// Traverse the faces adjacent to a given face through sharing a common edge
template <typename MAP>
class Traversor2FFaE
class Traversor2FFaE : public Traversor2<MAP>
{
private:
MAP& m ;
......
......@@ -453,4 +453,75 @@ Dart Traversor2FFaE<MAP>::next()
return current ;
}
template<typename MAP>
Traversor2<MAP>* Traversor2<MAP>::createIncident(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY)
{
int code = 0x100*(orbX-VERTEX) + orbY-VERTEX;
switch(code)
{
case 0x0001:
return new Traversor2VE<MAP>(map,dart);
break;
case 0x0002:
return new Traversor2VF<MAP>(map,dart);
break;
case 0x0100:
return new Traversor2EV<MAP>(map,dart);
break;
case 0x0102:
break;
case 0x0200:
return new Traversor2FV<MAP>(map,dart);
break;
case 0x0201:
return new Traversor2FE<MAP>(map,dart);
break;
default:
return NULL;
break;
}
return NULL;
}
template<typename MAP>
Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY)
{
int code = 0x100*(orbX-VERTEX) + orbY-VERTEX;
switch(code)
{
case 0x0001:
return new Traversor2VVaE<MAP>(map,dart);
break;
case 0x0002:
return new Traversor2VVaF<MAP>(map,dart);
break;
case 0x0100:
return new Traversor2EEaV<MAP>(map,dart);
break;
case 0x0102:
return new Traversor2EEaF<MAP>(map,dart);
break;
case 0x0200:
return new Traversor2FFaV<MAP>(map,dart);
break;
case 0x0201:
return new Traversor2FFaE<MAP>(map,dart);
break;
default:
return NULL;
break;
}
return NULL;
}
} // namespace CGoGN
......@@ -101,7 +101,6 @@ DartMarkerStore* MarkerForTraversor<MAP>::dmark()
template <typename MAP>
Traversor3XY<MAP>::Traversor3XY(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY, bool forceDartMarker, unsigned int thread) :
// Traversor3MarkOnly<MAP,ORBIT_Y>(map, forceDartMarker, thread, true),
m_map(map),
m_dmark(NULL),
m_cmark(NULL),
......
......@@ -73,7 +73,7 @@ public:
/// start the chrono
inline void start() { gettimeofday(&m_start, NULL) ; }
/// return elapsed time since start (cumulative if several calls)
/// return elapsed time since start in ms (cumulative if several calls)
inline int elapsed()
{
gettimeofday(&m_end, NULL) ;
......
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