Commit 630fb1fd authored by Pierre Kraemer's avatar Pierre Kraemer

suite de la reorganisation des cartes

parent 5b0741d1
...@@ -85,9 +85,7 @@ protected: ...@@ -85,9 +85,7 @@ protected:
* (initialized by enableQuickTraversal function) * (initialized by enableQuickTraversal function)
*/ */
AttributeMultiVector<Dart>* m_quickTraversal[NB_ORBITS] ; AttributeMultiVector<Dart>* m_quickTraversal[NB_ORBITS] ;
AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* m_quickLocalIncidentTraversal[NB_ORBITS][NB_ORBITS] ; AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* m_quickLocalIncidentTraversal[NB_ORBITS][NB_ORBITS] ;
AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* m_quickLocalAdjacentTraversal[NB_ORBITS][NB_ORBITS] ; AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* m_quickLocalAdjacentTraversal[NB_ORBITS][NB_ORBITS] ;
/** /**
...@@ -98,7 +96,6 @@ protected: ...@@ -98,7 +96,6 @@ protected:
/** /**
* Direct access to the attributes that store Marks * Direct access to the attributes that store Marks
*/ */
AttributeMultiVector<Mark>* m_markTables[NB_ORBITS][NB_THREAD] ; AttributeMultiVector<Mark>* m_markTables[NB_ORBITS][NB_THREAD] ;
unsigned int m_nbThreads ; unsigned int m_nbThreads ;
...@@ -112,44 +109,6 @@ protected: ...@@ -112,44 +109,6 @@ protected:
std::vector<DartMarkerGen*> dartMarkers[NB_THREAD] ; std::vector<DartMarkerGen*> dartMarkers[NB_THREAD] ;
std::vector<CellMarkerGen*> cellMarkers[NB_THREAD] ; std::vector<CellMarkerGen*> cellMarkers[NB_THREAD] ;
/**
* is map a multiresolution map
*/
#ifndef CGoGN_FORCE_MR
static const bool m_isMultiRes = false ;
#else
static const bool m_isMultiRes = true ;
#endif
/**
* container for multiresolution darts
*/
AttributeContainer m_mrattribs ;
/**
* pointers to attributes of m_mrattribs that store indices in m_attribs[DART] (one for each level)
*/
std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ;
/**
* pointer to attribute of m_mrattribs that stores darts insertion levels
*/
AttributeMultiVector<unsigned int>* m_mrLevels ;
/**
* vector that stores the number of darts inserted on each resolution level
*/
std::vector<unsigned int> m_mrNbDarts ;
/**
* current level in multiresolution map
*/
unsigned int m_mrCurrentLevel ;
/**
* stack for current level temporary storage
*/
std::vector<unsigned int> m_mrLevelStack ;
public: public:
static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ; static const unsigned int UNKNOWN_ATTRIB = AttributeContainer::UNKNOWN ;
...@@ -176,109 +135,6 @@ public: ...@@ -176,109 +135,6 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
MarkSet& getMarkerSet(unsigned int thread = 0) { return m_marksets[ORBIT][thread]; } MarkSet& getMarkerSet(unsigned int thread = 0) { return m_marksets[ORBIT][thread]; }
/****************************************
* RESOLUTION LEVELS MANAGEMENT *
****************************************/
void printMR() ;
/**
* initialize the multiresolution attribute container
*/
void initMR() ;
/**
* get the current resolution level (use only in MRMaps)
*/
unsigned int getCurrentLevel() ;
/**
* set the current resolution level (use only in MRMaps)
*/
void setCurrentLevel(unsigned int l) ;
/**
* increment the current resolution level (use only in MRMaps)
*/
void incCurrentLevel() ;
/**
* decrement the current resolution level (use only in MRMaps)
*/
void decCurrentLevel() ;
/**
* store current resolution level on a stack (use only in MRMaps)
*/
void pushLevel() ;
/**
* set as current the resolution level of the top of the stack (use only in MRMaps)
*/
void popLevel() ;
/**
* get the maximum resolution level (use only in MRMaps)
*/
unsigned int getMaxLevel() ;
//private:
// /*
// * add a resolution level
// */
// AttributeMultiVector<unsigned int>* addLevel();
/**
* add a resolution level in the back of the level table (use only in MRMaps)
*/
void addLevelBack() ;
/**
* add a resolution level in the front of the level table (use only in MRMaps)
*/
void addLevelFront();
/**
* remove last resolution level (use only in MRMaps)
*/
void removeLevelBack() ;
/**
* remove first resolution level (use only in MRMaps)
*/
void removeLevelFront();
/**
* copy MRDarts from level-1 to level
*/
void copyLevel(unsigned int level);
/**
* duplicate darts from level-1 to level
*/
void duplicateDarts(unsigned int newlevel);
/**
* duplicate a dart starting from current level
*/
void duplicateDart(Dart d) ;
void duplicateDartAtOneLevel(Dart d, unsigned int level) ;
void propagateDartRelation(Dart d, AttributeMultiVector<Dart>* rel) ;
void propagateDartRelation(Dart d, Dart e, AttributeMultiVector<Dart>* rel);
void propagateDartRelation(Dart d, Dart e, Dart f, AttributeMultiVector<Dart>* rel, AttributeMultiVector<Dart>* rel2);
template <unsigned int ORBIT>
void propagateDartEmbedding(Dart d) ;
template <unsigned int ORBIT>
void propagateOrbitEmbedding(Dart d) ;
/**************************************** /****************************************
* DARTS MANAGEMENT * * DARTS MANAGEMENT *
****************************************/ ****************************************/
...@@ -291,7 +147,7 @@ protected: ...@@ -291,7 +147,7 @@ protected:
/** /**
* Erase a dart of the map * Erase a dart of the map
*/ */
void deleteDart(Dart d) ; virtual void deleteDart(Dart d) ;
/** /**
* create a copy of a dart (based on its index in m_attribs[DART]) and returns its index * create a copy of a dart (based on its index in m_attribs[DART]) and returns its index
...@@ -305,44 +161,16 @@ protected: ...@@ -305,44 +161,16 @@ protected:
public: public:
/** /**
* get the index of dart in topological table * @brief dartIndex
*/ * @param d
unsigned int dartIndex(Dart d) const; * @return index of dart (depends on map implementation)
/**
* get the Dart of index in topological table
*/
Dart indexDart(unsigned int index) const;
/**
* @brief are we in MR ?
*/
static bool isMultiRes() { return m_isMultiRes; }
/**
* get the insertion level of a dart (use only in MRMaps)
*/
unsigned int getDartLevel(Dart d) const ;
/**
*
*/
void incDartLevel(Dart d) const ;
/**
* get the number of darts inserted in the given leveldart (use only in MRMaps)
*/ */
unsigned int getNbInsertedDarts(unsigned int level) ; virtual unsigned int dartIndex(Dart d) const ;
/**
* get the number of darts that define the map of the given leveldart (use only in MRMaps)
*/
unsigned int getNbDarts(unsigned int level) ;
/** /**
* @return the number of darts in the map * @return the number of darts in the map
*/ */
unsigned int getNbDarts() ; virtual unsigned int getNbDarts() ;
/** /**
* return true if the dart d refers to a valid index * return true if the dart d refers to a valid index
...@@ -463,7 +291,6 @@ public: ...@@ -463,7 +291,6 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
void initAllOrbitsEmbedding(bool realloc = false) ; void initAllOrbitsEmbedding(bool realloc = false) ;
/**************************************** /****************************************
* QUICK TRAVERSAL MANAGEMENT * * QUICK TRAVERSAL MANAGEMENT *
****************************************/ ****************************************/
...@@ -542,18 +369,6 @@ public: ...@@ -542,18 +369,6 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
AttributeMultiVector<unsigned int>* getEmbeddingAttributeVector() ; AttributeMultiVector<unsigned int>* getEmbeddingAttributeVector() ;
/**
* get the MR attribute container
*/
AttributeContainer& getMRAttributeContainer() ;
/**
* get the MR attribute container
*/
AttributeMultiVector<unsigned int>* getMRDartAttributeVector(unsigned int level) ;
AttributeMultiVector<unsigned int>* getMRLevelAttributeVector();
/** /**
* swap two attribute containers * swap two attribute containers
*/ */
...@@ -696,38 +511,21 @@ public: ...@@ -696,38 +511,21 @@ public:
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
/** // /**
* Begin of map // * Apply a functor on each dart of the map
* @return the first dart of the map // * @param f a ref to the functor obj
*/ // */
Dart begin() const ; // bool foreach_dart(FunctorType& f) ;
/**
* End of map
* @return the end iterator (next of last) of the map
*/
Dart end() const ;
/**
* allow to go from a dart to the next
* in the order of storage
* @param d reference to the dart to be modified
*/
void next(Dart& d) const ;
/** virtual Dart begin() const;
* Apply a functor on each dart of the map virtual Dart end() const;
* @param f a ref to the functor obj virtual void next(Dart& d) const;
*/
bool foreach_dart(FunctorType& f) ;
//! Apply a functor on every dart of an orbit //! Apply a functor on every dart of an orbit
/*! @param dim dimension of orbit /*! @param dim dimension of orbit
* @param d a dart of the orbit * @param d a dart of the orbit
* @param f a functor obj * @param f a functor obj
*/ */
// template <unsigned int ORBIT>
// bool foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread = 0) ;
template <unsigned int ORBIT> template <unsigned int ORBIT>
bool foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread = 0) const; bool foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread = 0) const;
...@@ -745,38 +543,20 @@ public: ...@@ -745,38 +543,20 @@ public:
virtual bool foreach_dart_of_edge2(Dart /*d*/, FunctorType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; } virtual bool foreach_dart_of_edge2(Dart /*d*/, FunctorType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
virtual bool foreach_dart_of_face2(Dart /*d*/, FunctorType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; } virtual bool foreach_dart_of_face2(Dart /*d*/, FunctorType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_vertex(Dart d, FunctorConstType& f, unsigned int thread = 0) const = 0 ;
// virtual bool foreach_dart_of_edge(Dart d, FunctorConstType& f, unsigned int thread = 0) const = 0 ;
// virtual bool foreach_dart_of_face(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_volume(Dart /*d*/, FunctorConstType& /*f*/, unsigned /*int thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_cc(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_vertex1(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_edge1(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_vertex2(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_edge2(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
// virtual bool foreach_dart_of_face2(Dart /*d*/, FunctorConstType& /*f*/, unsigned int /*thread = 0*/) const { std::cerr << "Not implemented" << std::endl; return false; }
/** /**
* execute functor for each orbit * execute functor for each orbit
* @param dim the dimension of the orbit * @param dim the dimension of the orbit
* @param f the functor * @param f the functor
*/ */
template <unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
bool foreach_orbit(FunctorType& f, unsigned int thread = 0) const; bool foreach_orbit(FunctorType& f, unsigned int thread = 0) const;
// template <unsigned int ORBIT>
// bool foreach_orbit(FunctorConstType& f, unsigned int thread = 0) const;
//! Count the number of orbits of dimension dim in the map //! Count the number of orbits of dimension dim in the map
/*! @param dim the dimension of the orbit /*! @param dim the dimension of the orbit
* @return the number of orbits * @return the number of orbits
*/ */
template <unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
unsigned int getNbOrbits() const; unsigned int getNbOrbits() const;
//! For an orbit of a given dimension, return the number of incident cells of an other given dimension //! For an orbit of a given dimension, return the number of incident cells of an other given dimension
...@@ -785,6 +565,10 @@ public: ...@@ -785,6 +565,10 @@ public:
template <typename MAP, unsigned int ORBIT, unsigned int INCIDENT> template <typename MAP, unsigned int ORBIT, unsigned int INCIDENT>
unsigned int degree(Dart d) const; unsigned int degree(Dart d) const;
/****************************************
* BOUNDARY MANAGEMENT *
****************************************/
protected: protected:
/// boundary markers /// boundary markers
Mark m_boundaryMarkers[2] ; // 0 for dim 2 / 1 for dim 3 Mark m_boundaryMarkers[2] ; // 0 for dim 2 / 1 for dim 3
......
...@@ -29,56 +29,6 @@ ...@@ -29,56 +29,6 @@
namespace CGoGN namespace CGoGN
{ {
/****************************************
* MULTIRES *
****************************************/
inline unsigned int GenericMap::getCurrentLevel()
{
return m_mrCurrentLevel ;
}
inline void GenericMap::setCurrentLevel(unsigned int l)
{
if(l < m_mrDarts.size())
m_mrCurrentLevel = l ;
else
CGoGNout << "setCurrentLevel : try to access nonexistent resolution level" << CGoGNendl ;
}
inline void GenericMap::incCurrentLevel()
{
if(m_mrCurrentLevel < m_mrDarts.size() - 1)
++m_mrCurrentLevel ;
else
CGoGNout << "incCurrentLevel : already at maximum resolution level" << CGoGNendl ;
}
inline void GenericMap::decCurrentLevel()
{
if(m_mrCurrentLevel > 0)
--m_mrCurrentLevel ;
else
CGoGNout << "decCurrentLevel : already at minimum resolution level" << CGoGNendl ;
}
inline void GenericMap::pushLevel()
{
m_mrLevelStack.push_back(m_mrCurrentLevel) ;
}
inline void GenericMap::popLevel()
{
m_mrCurrentLevel = m_mrLevelStack.back() ;
m_mrLevelStack.pop_back() ;
}
inline unsigned int GenericMap::getMaxLevel()
{
return m_mrDarts.size() - 1 ;
}
/**************************************** /****************************************
* DARTS MANAGEMENT * * DARTS MANAGEMENT *
****************************************/ ****************************************/
...@@ -88,84 +38,19 @@ inline Dart GenericMap::newDart() ...@@ -88,84 +38,19 @@ inline Dart GenericMap::newDart()
unsigned int di = m_attribs[DART].insertLine(); // insert a new dart line unsigned int di = m_attribs[DART].insertLine(); // insert a new dart line
for(unsigned int i = 0; i < NB_ORBITS; ++i) for(unsigned int i = 0; i < NB_ORBITS; ++i)
{ {
if (m_embeddings[i]) // set all its embeddings if (m_embeddings[i]) // set all its embeddings
(*m_embeddings[i])[di] = EMBNULL ; // to EMBNULL (*m_embeddings[i])[di] = EMBNULL ; // to EMBNULL
}
if (m_isMultiRes)
{
unsigned int mrdi = m_mrattribs.insertLine() ; // insert a new MRdart line
(*m_mrLevels)[mrdi] = m_mrCurrentLevel ; // set the introduction level of the dart
m_mrNbDarts[m_mrCurrentLevel]++ ;
for(unsigned int i = 0; i < m_mrCurrentLevel; ++i) // for all previous levels
(*m_mrDarts[i])[mrdi] = MRNULL ; // this MRdart does not exist
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) // for all levels from current to max
(*m_mrDarts[i])[mrdi] = di ; // make this MRdart point to the new dart line
return Dart::create(mrdi) ;
} }
return Dart::create(di) ; return Dart::create(di) ;
} }
inline void GenericMap::deleteDart(Dart d)
{
if(m_isMultiRes)
{
unsigned int index = (*m_mrDarts[m_mrCurrentLevel])[d.index] ;
if(getDartLevel(d) > m_mrCurrentLevel)
{
unsigned int di = (*m_mrDarts[m_mrCurrentLevel + 1])[d.index];
// si le brin de niveau i pointe sur le meme brin que le niveau i-1
if(di != index)
{
if(isDartValid(d))//index))
deleteDartLine(index) ;
}
(*m_mrDarts[m_mrCurrentLevel])[d.index] = MRNULL ;
return;
}
// a MRdart can only be deleted on its insertion level
if(getDartLevel(d) == m_mrCurrentLevel)
{
if(isDartValid(d))
{
deleteDartLine(index) ;
m_mrattribs.removeLine(d.index);
m_mrNbDarts[m_mrCurrentLevel]--;
}
}
else
{
unsigned int di = (*m_mrDarts[m_mrCurrentLevel - 1])[d.index];
// si le brin de niveau i pointe sur le meme brin que le niveau i-1
if(di != index)
{
if(isDartValid(d))//index))
deleteDartLine(index) ;
}
for(unsigned int i = m_mrCurrentLevel; i <= getMaxLevel(); ++i) // for all levels from current to max
{
(*m_mrDarts[i])[d.index] = di ; //copy the index from previous level
}
}
}
else
deleteDartLine(dartIndex(d)) ;
}
inline void GenericMap::deleteDartLine(unsigned int index) inline void GenericMap::deleteDartLine(unsigned int index)
{ {
m_attribs[DART].removeLine(index) ; // free the dart line m_attribs[DART].removeLine(index) ; // free the dart line
for (unsigned int t = 0; t < m_nbThreads; ++t) // clear markers of for (unsigned int t = 0; t < m_nbThreads; ++t) // clear markers of
(*m_markTables[DART][t])[index].clear() ; // the removed dart (*m_markTables[DART][t])[index].clear() ; // the removed dart
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{ {
...@@ -200,163 +85,8 @@ inline unsigned int GenericMap::copyDartLine(unsigned int index) ...@@ -200,163 +85,8 @@ inline unsigned int GenericMap::copyDartLine(unsigned int index)
return newindex ; return newindex ;
} }
inline void GenericMap::duplicateDart(Dart d)
{
assert(getDartLevel(d) <= m_mrCurrentLevel || !"duplicateDart : called with a dart inserted after current level") ;
if(getDartLevel(d) == m_mrCurrentLevel) // no need to duplicate
return ; // a dart from its insertion level
unsigned int oldindex = dartIndex(d) ;
if(m_mrCurrentLevel > 0)
{
if((*m_mrDarts[m_mrCurrentLevel - 1])[d.index] != oldindex) // no need to duplicate if the dart is already
return ; // duplicated with respect to previous level
}
unsigned int newindex = copyDartLine(oldindex) ;
for(unsigned int i = m_mrCurrentLevel; i <= getMaxLevel(); ++i) // for all levels from current to max
{
assert((*m_mrDarts[i])[d.index] == oldindex || !"duplicateDart : dart was already duplicated on a greater level") ;
(*m_mrDarts[i])[d.index] = newindex ; // make this MRdart points to the new dart line
}
}
inline void GenericMap::duplicateDartAtOneLevel(Dart d, unsigned int level)
{