Commit ed704c58 authored by Sylvain Thery's avatar Sylvain Thery

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

parents 1bbca422 b73e64da
......@@ -113,22 +113,22 @@ protected:
#endif
/**
* container for mr-darts that store indices in attribs[DART] for each level
* container for multiresolution darts
*/
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 ;
/**
* 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 ;
......@@ -146,6 +146,11 @@ public:
virtual std::string mapTypeName() = 0 ;
/**
* initialize the multiresolution attribute container
*/
void initMR() ;
/**
* Clear the map
* @param removeAttrib
......@@ -164,34 +169,40 @@ public:
****************************************/
/**
* get the current level of multi-resolution (use only in MRMaps)
* get the current resolution level (use only in MRMaps)
*/
unsigned int getCurrentLevel() ;
/**
* set the current level of multi-resolution (use only in MRMaps)
* set the current resolution level (use only in MRMaps)
*/
void setCurrentLevel(unsigned int l) ;
/**
* store current level of multi-resolution on a stack (use only in MRMaps)
* store current resolution level on a stack (use only in MRMaps)
*/
void pushLevel() ;
/**
* get back level of multi-resolution of the stack in current (use only in MRMaps)
* set as current the resolution level of the top of the stack (use only in MRMaps)
*/
void popLevel() ;
/**
* get the max level of multi-resolution (use only in MRMaps)
* get the maximum resolution level (use only in MRMaps)
*/
unsigned int getMaxLevel() ;
/**
* add a level of multi-resolution (use only in MRMaps)
* add a resolution level (use only in MRMaps)
*/
void addLevel() ;
/**
* get the insertion level of a dart (use only in MRMaps)
*/
unsigned int getDartLevel(Dart d) ;
/****************************************
* DARTS MANAGEMENT *
****************************************/
......@@ -207,7 +218,6 @@ protected:
void deleteDart(Dart d) ;
public:
/**
* get the index of dart in topological table
*/
......
......@@ -32,6 +32,44 @@ inline unsigned int GenericMap::dartIndex(Dart d)
return d.index;
}
/****************************************
* 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 inexisting 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 ;
}
inline unsigned int GenericMap::getDartLevel(Dart d)
{
return m_mrLevels->operator[](d.index) ;
}
/****************************************
* DARTS MANAGEMENT *
****************************************/
......@@ -220,20 +258,36 @@ inline AttributeMultiVector<unsigned int>* GenericMap::getEmbeddingAttributeVect
inline Dart GenericMap::begin()
{
return Dart::create(m_attribs[DART].begin());
if (m_isMultiRes)
{
unsigned int d = m_mrattribs.begin() ;
while (getDartLevel(d) > m_mrCurrentLevel)
m_mrattribs.next(d) ;
return Dart::create(d) ;
}
return Dart::create(m_attribs[DART].begin()) ;
}
inline Dart GenericMap::end()
{
if (m_isMultiRes)
return Dart::create(m_mrattribs.end()) ;
return Dart::create(m_attribs[DART].end()) ;
}
inline void GenericMap::next(Dart& d)
{
unsigned int d_index = dartIndex(d);
m_attribs[DART].next(d_index) ;
d = Dart::create(d_index);
if (m_isMultiRes)
{
do
{
m_mrattribs.next(d.index) ;
} while ((d.index != m_mrattribs.end() ) && (getDartLevel(d.index) > m_mrCurrentLevel)) ;
}
else
m_attribs[DART].next(d.index) ;
}
/****************************************
......@@ -259,42 +313,4 @@ inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& na
return amv ;
}
/******************************************
* TOPOLOGICAL MULTIRESOLUTION MANAGEMENT*
******************************************/
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 << "try to access inexisting 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 ;
}
} //namespace CGoGN
......@@ -124,14 +124,8 @@ inline void Map1::phi1sew(Dart d, Dart e)
Dart g = (*m_phi1)[e_index] ;
(*m_phi1)[d_index] = g ;
(*m_phi1)[e_index] = f ;
// unsigned int g_index = dartIndex(g);
// (*m_phi_1)[g_index] = d ;
(*m_phi_1)[dartIndex(g)] = d ;
// unsigned int f_index = dartIndex(f);
// (*m_phi_1)[f_index] = e ;
(*m_phi_1)[dartIndex(f)] = e ;
}
inline void Map1::phi1unsew(Dart d)
......@@ -142,7 +136,6 @@ inline void Map1::phi1unsew(Dart d)
Dart f = (*m_phi1)[e_index] ;
(*m_phi1)[d_index] = f ;
(*m_phi1)[e_index] = e ;
// unsigned int f_index = dartIndex(f);
(*m_phi_1)[dartIndex(f)] = d ;
(*m_phi_1)[e_index] = e ;
}
......
......@@ -25,13 +25,96 @@
#ifndef __MAP2MR_PRIMAL__
#define __MAP2MR_PRIMAL__
#include "Topology/map/map2.h"
#include "Topology/map/embeddedMap2.h"
namespace CGoGN
{
class Map2MR_Primal : protected Map2
class Map2MR_Primal : public EmbeddedMap2
{
public:
Map2MR_Primal() ;
/***************************************************
* CELLS INFORMATION *
***************************************************/
/**
* Return the level of insertion of the vertex of d
*/
unsigned int vertexInsertionLevel(Dart d) ;
/**
* Return the level of the edge of d in the current level map
*/
unsigned int edgeLevel(Dart d) ;
/**
* Return the level of the face of d in the current level map
*/
unsigned int faceLevel(Dart d) ;
/**
* Given the face of d in the current level map,
* return a level 0 dart of its origin face
*/
Dart faceOrigin(Dart d) ;
/**
* Return the oldest dart of the face of d in the current level map
*/
Dart faceOldestDart(Dart d) ;
/**
* Return true if the edge of d in the current level map
* has already been subdivided to the next level
*/
bool edgeIsSubdivided(Dart d) ;
/**
* Return true if the edge of d in the current level map
* is subdivided to the next level,
* none of its resulting edges is in turn subdivided to the next level
* and the middle vertex is of degree 2
*/
bool edgeCanBeCoarsened(Dart d) ;
/**
* Return true if the face of d in the current level map
* has already been subdivided to the next level
*/
bool faceIsSubdivided(Dart d) ;
/**
* Return true if the face of d in the current level map
* is subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level
*/
bool faceIsSubdividedOnce(Dart d) ;
/***************************************************
* SUBDIVISION *
***************************************************/
/**
* subdivide the edge of d to the next level
*/
void subdivideEdge(Dart d) ;
/**
* subdivide the face of d to the next level
*/
void subdivideFace(Dart d) ;
/**
* coarsen the edge of d from the next level
*/
void coarsenEdge(Dart d) ;
/**
* coarsen the face of d from the next level
*/
void coarsenFace(Dart d) ;
} ;
} // namespace CGoGN
......
......@@ -90,16 +90,6 @@ GenericMap::GenericMap() : m_nbThreads(1)
#ifndef CGoGN_FORCE_MR
m_isMultiRes = false;
#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()
......@@ -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)
{
if (removeAttrib)
......@@ -154,15 +159,24 @@ void GenericMap::clear(bool removeAttrib)
}
if (m_isMultiRes)
{
m_mrattribs.clear(true);
m_mrLevels = NULL;
unsigned int nb = m_mrDarts.size();
for (unsigned int i = 0; i<nb; ++i)
m_mrDarts[i]=NULL;
m_mrCurrentLevel=0;
m_mrLevelStack.clear();
}
initMR() ;
}
/****************************************
* MULTIRES *
****************************************/
void GenericMap::addLevel()
{
unsigned int level = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< level ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ;
// copy the darts pointers of the previous level
if(m_mrDarts.size() > 1)
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ;
}
/****************************************
......@@ -534,7 +548,7 @@ void GenericMap::update_topo_shortcuts()
std::string sub = names[i].substr(0, 7);
if (sub=="MRLevel")
m_mrLevels = m_mrattribs.getDataVector<unsigned char>(i);
m_mrLevels = m_mrattribs.getDataVector<unsigned int>(i);
if (sub=="MRdart_")
{
......@@ -801,30 +815,6 @@ void GenericMap::boundaryUnmarkAll()
m_markTables[DART][0]->operator[](i).unsetMark(m_boundaryMarker);
}
void GenericMap::addLevel()
{
unsigned int level = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< level ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ;
// copy the darts pointers of the previous level
if(m_mrDarts.size() > 1)
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[m_mrDarts.size() - 2]->getIndex()) ;
}
} // namespace CGoGN
//
......
......@@ -66,7 +66,6 @@ void Map2::rdfi(Dart t, DartMarker& m1, DartMarker& m2)
}
}
void Map2::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
......@@ -229,10 +228,10 @@ Dart Map2::deleteVertex(Dart d)
Dart Map2::cutEdge(Dart d)
{
Dart e = phi2(d);
phi2unsew(d); // remove old phi2 links
phi2unsew(d); // remove old phi2 links
Dart nd = Map1::cutEdge(d); // Cut the 1-edge of d
Dart ne = Map1::cutEdge(e); // Cut the 1-edge of phi2(d)
phi2sew(d, ne); // Correct the phi2 links
phi2sew(d, ne); // Correct the phi2 links
phi2sew(e, nd);
return nd;
}
......
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