Commit e0942ffc authored by Pierre Kraemer's avatar Pierre Kraemer

boolean to chose to share vertex embeddings

parent 03b5d009
...@@ -32,23 +32,12 @@ namespace CGoGN ...@@ -32,23 +32,12 @@ namespace CGoGN
class Map2MR_Primal : public EmbeddedMap2 class Map2MR_Primal : public EmbeddedMap2
{ {
protected:
bool shareVertexEmbeddings ;
public: public:
Map2MR_Primal() ; Map2MR_Primal() ;
void copyVertexEmbeddings()
{
unsigned int maxL = getMaxLevel() ;
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int previdx = (*m_mrDarts[maxL - 1])[i] ;
unsigned int newidx = (*m_mrDarts[maxL])[i] ;
unsigned int emb = (*m_embeddings[VERTEX])[previdx] ;
(*m_embeddings[VERTEX])[newidx] = emb ;
if(emb != EMBNULL)
m_attribs[VERTEX].refLine(emb);
}
}
/*************************************************** /***************************************************
* CELLS INFORMATION * * CELLS INFORMATION *
***************************************************/ ***************************************************/
...@@ -106,10 +95,21 @@ public: ...@@ -106,10 +95,21 @@ public:
*/ */
bool faceIsSubdividedOnce(Dart d) ; bool faceIsSubdividedOnce(Dart d) ;
/***************************************************
* EMBEDDINGS MANAGEMENT *
***************************************************/
void copyVertexEmbeddings() ;
/*************************************************** /***************************************************
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
/**
* add a new resolution level
*/
void addNewLevel() ;
/** /**
* subdivide the edge of d to the next level * subdivide the edge of d to the next level
*/ */
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
namespace CGoGN namespace CGoGN
{ {
Map2MR_Primal::Map2MR_Primal() Map2MR_Primal::Map2MR_Primal() : shareVertexEmbeddings(true)
{ {
initMR() ; initMR() ;
} }
...@@ -248,10 +248,35 @@ bool Map2MR_Primal::faceIsSubdividedOnce(Dart d) ...@@ -248,10 +248,35 @@ bool Map2MR_Primal::faceIsSubdividedOnce(Dart d)
return false ; return false ;
} }
/***************************************************
* EMBEDDINGS MANAGEMENT *
***************************************************/
void Map2MR_Primal::copyVertexEmbeddings()
{
unsigned int maxL = getMaxLevel() ;
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{
unsigned int previdx = (*m_mrDarts[maxL - 1])[i] ;
unsigned int newidx = (*m_mrDarts[maxL])[i] ;
unsigned int emb = (*m_embeddings[VERTEX])[previdx] ;
(*m_embeddings[VERTEX])[newidx] = emb ;
if(emb != EMBNULL)
m_attribs[VERTEX].refLine(emb);
}
}
/*************************************************** /***************************************************
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
void Map2MR_Primal::addNewLevel()
{
addLevel() ;
if(shareVertexEmbeddings)
copyVertexEmbeddings() ;
}
void Map2MR_Primal::subdivideEdge(Dart d) void Map2MR_Primal::subdivideEdge(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideEdge : called with a dart introduced after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideEdge : called with a dart introduced after current level") ;
...@@ -262,10 +287,7 @@ void Map2MR_Primal::subdivideEdge(Dart d) ...@@ -262,10 +287,7 @@ void Map2MR_Primal::subdivideEdge(Dart d)
pushLevel() ; pushLevel() ;
if(eLevel == getMaxLevel()) if(eLevel == getMaxLevel())
{ addNewLevel() ;
addLevel() ;
copyVertexEmbeddings() ;
}
setCurrentLevel(eLevel + 1) ; setCurrentLevel(eLevel + 1) ;
cutEdge(d) ; cutEdge(d) ;
......
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