Commit 03b5d009 authored by Pierre Kraemer's avatar Pierre Kraemer

on addLevel, embeddings are not copied

parent 98dca2f2
...@@ -239,7 +239,6 @@ private: ...@@ -239,7 +239,6 @@ private:
* internal functions * internal functions
*/ */
void deleteDartLine(unsigned int index) ; void deleteDartLine(unsigned int index) ;
void copyDartLine(unsigned int dest, unsigned int src) ;
unsigned int newCopyOfDartLine(unsigned int index) ; unsigned int newCopyOfDartLine(unsigned int index) ;
public: public:
......
...@@ -109,28 +109,17 @@ inline Dart GenericMap::newDart() ...@@ -109,28 +109,17 @@ inline Dart GenericMap::newDart()
inline void GenericMap::deleteDart(Dart d) inline void GenericMap::deleteDart(Dart d)
{ {
// hypothese : lors d'une suppression de brin, les attributs du brin supprimé
// sont identiques à tous les niveaux > au niveau où a lieu la suppression
if(m_isMultiRes) if(m_isMultiRes)
{ {
// if a dart is deleted on its insertion level // a MRdart can only be deleted on its insertion level
assert(getDartLevel(d) == m_mrCurrentLevel || !"deleteDart : try to delete a dart on a level greater than its insertion level") ;
// all the darts pointed in greater levels are deleted // all the darts pointed in greater levels are deleted
// and then the MRdart is deleted // and then the MRdart is deleted
if((*m_mrLevels)[d.index] == m_mrCurrentLevel) for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
{ deleteDartLine((*m_mrDarts[i])[d.index]) ;
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) m_mrattribs.removeLine(d.index) ;
deleteDartLine((*m_mrDarts[i])[d.index]) ; m_mrNbDarts[m_mrCurrentLevel]-- ;
m_mrattribs.removeLine(d.index) ;
m_mrNbDarts[m_mrCurrentLevel]-- ;
}
// if a dart is deleted after its insertion level
// the dart of previous level is copied in the greater levels
else
{
unsigned int dprev = (*m_mrDarts[m_mrCurrentLevel - 1])[d.index] ;
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
copyDartLine((*m_mrDarts[i])[d.index], dprev) ;
}
} }
else else
deleteDartLine(dartIndex(d)) ; deleteDartLine(dartIndex(d)) ;
...@@ -160,49 +149,14 @@ inline void GenericMap::deleteDartLine(unsigned int index) ...@@ -160,49 +149,14 @@ inline void GenericMap::deleteDartLine(unsigned int index)
} }
} }
inline void GenericMap::copyDartLine(unsigned int dest, unsigned int src)
{
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if (m_embeddings[orbit]) // for each embedded orbit
{
unsigned int emb = (*m_embeddings[orbit])[dest] ; // get the embedding of the destination dart
if(emb != EMBNULL)
{
if(m_attribs[orbit].unrefLine(emb)) // unref the pointed embedding line
{
for (unsigned int t = 0; t < m_nbThreads; ++t) // and clear its markers if it was
(*m_markTables[orbit][t])[emb].clear() ; // its last unref (and was thus freed)
}
}
}
}
m_attribs[DART].copyLine(dest, src) ;
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if (m_embeddings[orbit]) // for each embedded orbit
{
unsigned int emb = (*m_embeddings[orbit])[src] ; // add a ref to the pointed attributes
if(emb != EMBNULL)
m_attribs[orbit].refLine(emb) ;
}
}
}
inline unsigned int GenericMap::newCopyOfDartLine(unsigned int index) inline unsigned int GenericMap::newCopyOfDartLine(unsigned int index)
{ {
unsigned int newindex = m_attribs[DART].insertLine() ; unsigned int newindex = m_attribs[DART].insertLine() ; // create a new dart line
m_attribs[DART].copyLine(newindex, index) ; m_attribs[DART].copyLine(newindex, index) ; // copy the given dart line
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{ {
if (m_embeddings[orbit]) if (m_embeddings[orbit]) // put the embeddings of the
{ (*m_embeddings[orbit])[newindex] = EMBNULL ; // new line to EMBNULL
unsigned int emb = (*m_embeddings[orbit])[newindex] ; // add a ref to the pointed attributes
if(emb != EMBNULL)
m_attribs[orbit].refLine(emb) ;
}
} }
return newindex ; return newindex ;
} }
......
...@@ -35,6 +35,20 @@ class Map2MR_Primal : public EmbeddedMap2 ...@@ -35,6 +35,20 @@ class Map2MR_Primal : public EmbeddedMap2
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 *
***************************************************/ ***************************************************/
......
...@@ -190,21 +190,20 @@ void GenericMap::addLevel() ...@@ -190,21 +190,20 @@ void GenericMap::addLevel()
unsigned int newLevel = m_mrDarts.size() ; unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ; std::stringstream ss ;
ss << "MRdart_"<< newLevel ; ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* amvMR = m_mrattribs.addAttribute<unsigned int>(ss.str()) ; AttributeMultiVector<unsigned int>* newAttrib = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.push_back(amvMR) ; m_mrDarts.push_back(newAttrib) ;
m_mrNbDarts.push_back(0) ; m_mrNbDarts.push_back(0) ;
if(m_mrDarts.size() > 1) if(m_mrDarts.size() > 1)
{ {
// copy the darts indices of the previous level AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1] ;
m_mrattribs.copyAttribute(amvMR->getIndex(), m_mrDarts[newLevel - 1]->getIndex()) ;
// duplicate all the darts in the new level // duplicate all the darts in the new level
for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
{ {
unsigned int oldi = (*amvMR)[i] ; // get the index of the dart in previous level unsigned int oldi = (*prevAttrib)[i] ; // get the index of the dart in previous level
(*amvMR)[i] = newCopyOfDartLine(oldi) ; // copy the dart and affect it to the new level (*newAttrib)[i] = newCopyOfDartLine(oldi) ; // copy the dart and affect it to the new level
} }
} }
} }
......
...@@ -262,7 +262,10 @@ void Map2MR_Primal::subdivideEdge(Dart d) ...@@ -262,7 +262,10 @@ void Map2MR_Primal::subdivideEdge(Dart d)
pushLevel() ; pushLevel() ;
if(eLevel == getMaxLevel()) if(eLevel == getMaxLevel())
{
addLevel() ; 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