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,47 +29,67 @@ template <typename MAP, unsigned int ORBIT> ...@@ -29,47 +29,67 @@ 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)
{ {
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>()) quickTraversal = map.template getQuickTraversal<ORBIT>() ;
cmark = new CellMarker<ORBIT>(map, thread) ; if(quickTraversal != NULL)
{
cont = &(m.template getAttributeContainer<ORBIT>()) ;
}
else else
dmark = new DartMarker(map, thread) ; {
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>())
cmark = new CellMarker<ORBIT>(map, thread) ;
else
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(dmark) if(quickTraversal == NULL)
delete dmark ; {
else if(dmark)
delete cmark ; delete dmark ;
else
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(!firstTraversal) if(quickTraversal != NULL)
{ {
if(dmark) qCurrent = cont->begin() ;
dmark->unmarkAll() ; current = (*quickTraversal)[qCurrent] ;
else
cmark->unmarkAll() ;
} }
current = m.begin() ;
while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
m.next(current) ;
if(current == m.end())
current = NIL ;
else else
{ {
if(dmark) if(!firstTraversal)
dmark->markOrbit<ORBIT>(current) ; {
if(dmark)
dmark->unmarkAll() ;
else
cmark->unmarkAll() ;
}
current = m.begin() ;
while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
m.next(current) ;
if(current == m.end())
current = NIL ;
else else
cmark->mark(current) ; {
if(dmark)
dmark->markOrbit<ORBIT>(current) ;
else
cmark->mark(current) ;
}
firstTraversal = false ;
} }
firstTraversal = false ;
return current ; return current ;
} }
...@@ -84,32 +104,40 @@ Dart TraversorCell<MAP, ORBIT>::next() ...@@ -84,32 +104,40 @@ Dart TraversorCell<MAP, ORBIT>::next()
{ {
if(current != NIL) if(current != NIL)
{ {
bool ismarked ; if(quickTraversal != NULL)
if(dmark) {
ismarked = dmark->isMarked(current) ; cont->next(qCurrent) ;
current = (*quickTraversal)[qCurrent] ;
}
else else
ismarked = cmark->isMarked(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
{ {
m.next(current) ; bool ismarked ;
if(current == m.end()) if(dmark)
current = NIL ; ismarked = dmark->isMarked(current) ;
else else
ismarked = cmark->isMarked(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarked(current) || !m_good(current)))
{ {
if(dmark) m.next(current) ;
ismarked = dmark->isMarked(current) ; if(current == m.end())
current = NIL ;
else else
ismarked = cmark->isMarked(current) ; {
if(dmark)
ismarked = dmark->isMarked(current) ;
else
ismarked = cmark->isMarked(current) ;
}
} }
}
if(current != NIL) if(current != NIL)
{ {
if(dmark) if(dmark)
dmark->markOrbit<ORBIT>(current) ; dmark->markOrbit<ORBIT>(current) ;
else else
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