Commit b73e64da authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

add initMR function to be called by MRmaps classes at construction

parent 366ba117
...@@ -113,22 +113,22 @@ protected: ...@@ -113,22 +113,22 @@ protected:
#endif #endif
/** /**
* container for mr-darts that store indices in attribs[DART] for each level * container for multiresolution darts
*/ */
AttributeContainer m_mrattribs ; AttributeContainer m_mrattribs ;
/** /**
* pointer to indices mvectors (one for each level) * pointers to attributes that store indices in m_attribs[DART] (one for each level)
*/ */
std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ; std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ;
/** /**
* pointers to mvector of levels * pointer to attribute that stores darts insertion levels
*/ */
AttributeMultiVector<unsigned char>* m_mrLevels ; AttributeMultiVector<unsigned int>* m_mrLevels ;
/** /**
* current level of multiresoltion * current level in multiresolution map
*/ */
unsigned int m_mrCurrentLevel ; unsigned int m_mrCurrentLevel ;
...@@ -146,6 +146,11 @@ public: ...@@ -146,6 +146,11 @@ public:
virtual std::string mapTypeName() = 0 ; virtual std::string mapTypeName() = 0 ;
/**
* initialize the multiresolution attribute container
*/
void initMR() ;
/** /**
* Clear the map * Clear the map
* @param removeAttrib * @param removeAttrib
......
...@@ -67,7 +67,7 @@ inline unsigned int GenericMap::getMaxLevel() ...@@ -67,7 +67,7 @@ inline unsigned int GenericMap::getMaxLevel()
inline unsigned int GenericMap::getDartLevel(Dart d) inline unsigned int GenericMap::getDartLevel(Dart d)
{ {
return m_mrLevels->operator [](d.index) ; return m_mrLevels->operator[](d.index) ;
} }
/**************************************** /****************************************
......
...@@ -90,16 +90,6 @@ GenericMap::GenericMap() : m_nbThreads(1) ...@@ -90,16 +90,6 @@ GenericMap::GenericMap() : m_nbThreads(1)
#ifndef CGoGN_FORCE_MR #ifndef CGoGN_FORCE_MR
m_isMultiRes = false; m_isMultiRes = false;
#endif #endif
if(m_isMultiRes)
{
m_mrDarts.reserve(16) ;
m_mrLevelStack.reserve(16) ;
m_mrLevels = m_mrattribs.addAttribute<unsigned char>("MRLevel") ;
addLevel() ;
setCurrentLevel(0) ;
}
} }
GenericMap::~GenericMap() GenericMap::~GenericMap()
...@@ -132,6 +122,21 @@ GenericMap::~GenericMap() ...@@ -132,6 +122,21 @@ GenericMap::~GenericMap()
} }
} }
void GenericMap::initMR()
{
m_isMultiRes = true;
m_mrattribs.clear(true) ;
m_mrDarts.clear() ;
m_mrDarts.reserve(16) ;
m_mrLevelStack.clear() ;
m_mrLevelStack.reserve(16) ;
m_mrLevels = m_mrattribs.addAttribute<unsigned int>("MRLevel") ;
addLevel() ;
setCurrentLevel(0) ;
}
void GenericMap::clear(bool removeAttrib) void GenericMap::clear(bool removeAttrib)
{ {
if (removeAttrib) if (removeAttrib)
...@@ -154,15 +159,7 @@ void GenericMap::clear(bool removeAttrib) ...@@ -154,15 +159,7 @@ void GenericMap::clear(bool removeAttrib)
} }
if (m_isMultiRes) if (m_isMultiRes)
{ initMR() ;
m_mrattribs.clear(true) ;
m_mrDarts.clear() ;
m_mrLevels = m_mrattribs.addAttribute<unsigned char>("MRLevel") ;
addLevel() ;
setCurrentLevel(0) ;
m_mrLevelStack.clear() ;
}
} }
/**************************************** /****************************************
...@@ -551,7 +548,7 @@ void GenericMap::update_topo_shortcuts() ...@@ -551,7 +548,7 @@ void GenericMap::update_topo_shortcuts()
std::string sub = names[i].substr(0, 7); std::string sub = names[i].substr(0, 7);
if (sub=="MRLevel") if (sub=="MRLevel")
m_mrLevels = m_mrattribs.getDataVector<unsigned char>(i); m_mrLevels = m_mrattribs.getDataVector<unsigned int>(i);
if (sub=="MRdart_") if (sub=="MRdart_")
{ {
......
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