Commit b3abfc41 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:~kraemer/CGoGN_template

parents 480085e4 35e4aa3e
...@@ -214,6 +214,8 @@ void Viewer::importMesh(std::string& filename) ...@@ -214,6 +214,8 @@ void Viewer::importMesh(std::string& filename)
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ; position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
} }
myMap.enableQuickTraversal<VERTEX>() ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
......
...@@ -36,7 +36,6 @@ namespace Algo ...@@ -36,7 +36,6 @@ namespace Algo
namespace Decimation namespace Decimation
{ {
/** /**
* Example of Edge_Critera class parameter * Example of Edge_Critera class parameter
* Will be used as edge embedding * Will be used as edge embedding
......
...@@ -40,7 +40,7 @@ void statModele(typename PFP::MAP& map, const typename PFP::TVEC3& position) ...@@ -40,7 +40,7 @@ void statModele(typename PFP::MAP& map, const typename PFP::TVEC3& position)
int nbFaces = 0; int nbFaces = 0;
int nbVertex = 0; int nbVertex = 0;
CellMarker mVertex(map, VERTEX); CellMarker<VERTEX> mVertex(map);
float ratioMinMax = 0; float ratioMinMax = 0;
int nbEdgePerVertex = 0; int nbEdgePerVertex = 0;
......
...@@ -729,7 +729,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi ...@@ -729,7 +729,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
*/ */
DartMarkerStore mf(map); // Lock a face marker to save one dart per face DartMarkerStore mf(map); // Lock a face marker to save one dart per face
CellMarker mv(map, VERTEX); CellMarker<VERTEX> mv(map);
typename PFP::VEC3 volCenter; typename PFP::VEC3 volCenter;
unsigned count = 0 ; unsigned count = 0 ;
...@@ -1102,7 +1102,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos ...@@ -1102,7 +1102,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos
*/ */
DartMarkerStore mf(map); // Lock a face marker to save one dart per face DartMarkerStore mf(map); // Lock a face marker to save one dart per face
CellMarker mv(map, VERTEX); CellMarker<VERTEX> mv(map);
typename PFP::VEC3 volCenter; typename PFP::VEC3 volCenter;
unsigned count = 0 ; unsigned count = 0 ;
...@@ -1344,7 +1344,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos ...@@ -1344,7 +1344,7 @@ Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& pos
//std::cout << "1ere etape finished" << std::endl; //std::cout << "1ere etape finished" << std::endl;
CellMarker mtf(map, FACE); CellMarker<FACE> mtf(map);
//Etape 2 //Etape 2
for (std::vector<std::pair<Dart,Dart> >::iterator edges = subdividedfacesT.begin(); edges != subdividedfacesT.end(); ++edges) for (std::vector<std::pair<Dart,Dart> >::iterator edges = subdividedfacesT.begin(); edges != subdividedfacesT.end(); ++edges)
......
...@@ -85,6 +85,12 @@ protected: ...@@ -85,6 +85,12 @@ protected:
*/ */
AttributeMultiVector<unsigned int>* m_embeddings[NB_ORBITS] ; AttributeMultiVector<unsigned int>* m_embeddings[NB_ORBITS] ;
/**
* Direct access to quick traversal attributes
* (initialized by enableQuickTraversal function)
*/
AttributeMultiVector<Dart>* m_quickTraversal[NB_ORBITS] ;
/** /**
* Marks manager * Marks manager
*/ */
...@@ -370,6 +376,22 @@ public: ...@@ -370,6 +376,22 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
void initCell(unsigned int i) ; void initCell(unsigned int i) ;
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
template <unsigned int ORBIT>
void enableQuickTraversal() ;
template <unsigned int ORBIT>
void updateQuickTraversal() ;
template <unsigned int ORBIT>
AttributeMultiVector<Dart>* getQuickTraversal() ;
template <unsigned int ORBIT>
void disableQuickTraversal() ;
/**************************************** /****************************************
* ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
****************************************/ ****************************************/
......
...@@ -352,6 +352,54 @@ inline void GenericMap::initCell(unsigned int i) ...@@ -352,6 +352,54 @@ inline void GenericMap::initCell(unsigned int i)
m_attribs[ORBIT].initLine(i) ; m_attribs[ORBIT].initLine(i) ;
} }
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
template <unsigned int ORBIT>
inline void GenericMap::enableQuickTraversal()
{
if(m_quickTraversal[ORBIT] == NULL)
{
if(!isOrbitEmbedded<ORBIT>())
addEmbedding<ORBIT>() ;
m_quickTraversal[ORBIT] = m_attribs[ORBIT].addAttribute<Dart>("quick_traversal") ;
}
updateQuickTraversal<ORBIT>() ;
}
template <unsigned int ORBIT>
inline void GenericMap::updateQuickTraversal()
{
assert(m_quickTraversal[ORBIT] != NULL || !"updateQuickTraversal on a disabled orbit") ;
CellMarker<ORBIT> cm(*this) ;
for(Dart d = begin(); d != end(); next(d))
{
if(!cm.isMarked(d))
{
cm.mark(d) ;
(*m_quickTraversal[ORBIT])[getEmbedding<ORBIT>(d)] = d ;
}
}
}
template <unsigned int ORBIT>
inline AttributeMultiVector<Dart>* GenericMap::getQuickTraversal()
{
return m_quickTraversal[ORBIT] ;
}
template <unsigned int ORBIT>
inline void GenericMap::disableQuickTraversal()
{
if(m_quickTraversal[ORBIT] != NULL)
{
m_attribs[ORBIT].removeAttribute<Dart>(m_quickTraversal[ORBIT]->getIndex()) ;
m_quickTraversal[ORBIT] = NULL ;
}
}
/**************************************** /****************************************
* ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
****************************************/ ****************************************/
......
...@@ -38,8 +38,14 @@ class TraversorCell: public Traversor<MAP> ...@@ -38,8 +38,14 @@ class TraversorCell: public Traversor<MAP>
{ {
private: private:
MAP& m ; MAP& m ;
AttributeContainer* cont ;
unsigned int qCurrent ;
DartMarker* dmark ; DartMarker* dmark ;
CellMarker<ORBIT>* cmark ; CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* quickTraversal ;
Dart current ; Dart current ;
bool firstTraversal ; bool firstTraversal ;
const FunctorSelect& m_good ; const FunctorSelect& m_good ;
......
...@@ -29,24 +29,42 @@ template <typename MAP, unsigned int ORBIT> ...@@ -29,24 +29,42 @@ template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : TraversorCell<MAP, ORBIT>::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
m(map), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good) m(map), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
{ {
quickTraversal = map.template getQuickTraversal<ORBIT>() ;
if(quickTraversal != NULL)
{
cont = &(m.template getAttributeContainer<ORBIT>()) ;
}
else
{
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>()) if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>())
cmark = new CellMarker<ORBIT>(map, thread) ; cmark = new CellMarker<ORBIT>(map, thread) ;
else else
dmark = new DartMarker(map, thread) ; dmark = new DartMarker(map, thread) ;
}
} }
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::~TraversorCell() TraversorCell<MAP, ORBIT>::~TraversorCell()
{ {
if(quickTraversal == NULL)
{
if(dmark) if(dmark)
delete dmark ; delete dmark ;
else else
delete cmark ; delete cmark ;
}
} }
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::begin() Dart TraversorCell<MAP, ORBIT>::begin()
{ {
if(quickTraversal != NULL)
{
qCurrent = cont->begin() ;
current = (*quickTraversal)[qCurrent] ;
}
else
{
if(!firstTraversal) if(!firstTraversal)
{ {
if(dmark) if(dmark)
...@@ -70,6 +88,8 @@ Dart TraversorCell<MAP, ORBIT>::begin() ...@@ -70,6 +88,8 @@ Dart TraversorCell<MAP, ORBIT>::begin()
} }
firstTraversal = false ; firstTraversal = false ;
}
return current ; return current ;
} }
...@@ -83,6 +103,13 @@ template <typename MAP, unsigned int ORBIT> ...@@ -83,6 +103,13 @@ template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::next() Dart TraversorCell<MAP, ORBIT>::next()
{ {
if(current != NIL) if(current != NIL)
{
if(quickTraversal != NULL)
{
cont->next(qCurrent) ;
current = (*quickTraversal)[qCurrent] ;
}
else
{ {
bool ismarked ; bool ismarked ;
if(dmark) if(dmark)
...@@ -112,6 +139,7 @@ Dart TraversorCell<MAP, ORBIT>::next() ...@@ -112,6 +139,7 @@ Dart TraversorCell<MAP, ORBIT>::next()
cmark->mark(current) ; cmark->mark(current) ;
} }
} }
}
return current ; return current ;
} }
......
...@@ -73,6 +73,7 @@ GenericMap::GenericMap() : m_nbThreads(1) ...@@ -73,6 +73,7 @@ GenericMap::GenericMap() : m_nbThreads(1)
m_attribs[i].setOrbit(i) ; m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ; m_attribs[i].setRegistry(m_attributes_registry_map) ;
m_embeddings[i] = NULL ; m_embeddings[i] = NULL ;
m_quickTraversal[i] = NULL ;
for(unsigned int j = 0; j < NB_THREAD; ++j) for(unsigned int j = 0; j < NB_THREAD; ++j)
{ {
m_marksets[i][j].clear() ; m_marksets[i][j].clear() ;
......
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