Commit c5412ed5 authored by Pierre Kraemer's avatar Pierre Kraemer

MR : test without darts duplication

parent 6a6f5c35
...@@ -235,12 +235,15 @@ protected: ...@@ -235,12 +235,15 @@ protected:
*/ */
void deleteDart(Dart d) ; void deleteDart(Dart d) ;
private: /**
* create a copy of a dart (based on its index in m_attribs[DART]) and returns its index
*/
unsigned int newCopyOfDartLine(unsigned int index) ;
/** /**
* internal functions * internal functions
*/ */
void deleteDartLine(unsigned int index) ; void deleteDartLine(unsigned int index) ;
unsigned int newCopyOfDartLine(unsigned int index) ;
public: public:
/** /**
......
...@@ -44,7 +44,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l) ...@@ -44,7 +44,7 @@ inline void GenericMap::setCurrentLevel(unsigned int l)
inline void GenericMap::incCurrentLevel() inline void GenericMap::incCurrentLevel()
{ {
if(m_mrCurrentLevel < m_mrDarts.size()) if(m_mrCurrentLevel < m_mrDarts.size() - 1)
++m_mrCurrentLevel ; ++m_mrCurrentLevel ;
else else
CGoGNout << "incCurrentLevel : already at maximum resolution level" << CGoGNendl ; CGoGNout << "incCurrentLevel : already at maximum resolution level" << CGoGNendl ;
...@@ -99,7 +99,7 @@ inline Dart GenericMap::newDart() ...@@ -99,7 +99,7 @@ inline Dart GenericMap::newDart()
(*m_mrDarts[m_mrCurrentLevel])[mrdi] = di ; (*m_mrDarts[m_mrCurrentLevel])[mrdi] = di ;
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i) for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i)
(*m_mrDarts[i])[mrdi] = newCopyOfDartLine(di) ; (*m_mrDarts[i])[mrdi] = di ; // newCopyOfDartLine(di) ;
return Dart::create(mrdi) ; return Dart::create(mrdi) ;
} }
...@@ -114,10 +114,12 @@ inline void GenericMap::deleteDart(Dart d) ...@@ -114,10 +114,12 @@ inline void GenericMap::deleteDart(Dart d)
// a MRdart can only be 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") ; 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
// and then the MRdart is deleted
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
deleteDartLine((*m_mrDarts[i])[d.index]) ; {
unsigned int index = (*m_mrDarts[i])[d.index] ;
if(isDartValid(index))
deleteDartLine(index) ;
}
m_mrattribs.removeLine(d.index) ; m_mrattribs.removeLine(d.index) ;
m_mrNbDarts[m_mrCurrentLevel]-- ; m_mrNbDarts[m_mrCurrentLevel]-- ;
} }
...@@ -157,6 +159,11 @@ inline unsigned int GenericMap::newCopyOfDartLine(unsigned int index) ...@@ -157,6 +159,11 @@ inline unsigned int GenericMap::newCopyOfDartLine(unsigned int index)
{ {
if (m_embeddings[orbit]) // put the embeddings of the if (m_embeddings[orbit]) // put the embeddings of the
(*m_embeddings[orbit])[newindex] = EMBNULL ; // new line to EMBNULL (*m_embeddings[orbit])[newindex] = EMBNULL ; // new line to EMBNULL
// {
// unsigned int emb = (*m_embeddings[orbit])[newindex] ;
// if(emb != EMBNULL)
// m_attribs[orbit].refLine(emb) ;
// }
} }
return newindex ; return newindex ;
} }
......
...@@ -35,14 +35,14 @@ class Map2MR_Primal : public EmbeddedMap2 ...@@ -35,14 +35,14 @@ class Map2MR_Primal : public EmbeddedMap2
protected: protected:
bool shareVertexEmbeddings ; bool shareVertexEmbeddings ;
FunctorType& vertexVertexFunctor ; // FunctorType& vertexVertexFunctor ;
FunctorType& edgeVertexFunctor ; // FunctorType& edgeVertexFunctor ;
FunctorType& faceVertexFunctor ; // FunctorType& faceVertexFunctor ;
public: public:
Map2MR_Primal() ; Map2MR_Primal() ;
std::string mapTypeName() { return "Map2MR_Primal";} std::string mapTypeName() { return "Map2MR_Primal" ; }
/*************************************************** /***************************************************
* CELLS INFORMATION * * CELLS INFORMATION *
...@@ -101,17 +101,13 @@ public: ...@@ -101,17 +101,13 @@ public:
*/ */
bool faceIsSubdividedOnce(Dart d) ; bool faceIsSubdividedOnce(Dart d) ;
protected:
/***************************************************
* EMBEDDINGS MANAGEMENT *
***************************************************/
void copyVertexEmbeddings() ;
/*************************************************** /***************************************************
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
protected:
void duplicateDart(Dart d) ;
/** /**
* add a new resolution level * add a new resolution level
*/ */
...@@ -121,12 +117,12 @@ public: ...@@ -121,12 +117,12 @@ public:
/** /**
* subdivide the edge of d to the next level * subdivide the edge of d to the next level
*/ */
void subdivideEdge(Dart d) ; unsigned int subdivideEdge(Dart d) ;
/** /**
* subdivide the face of d to the next level * subdivide the face of d to the next level
*/ */
void subdivideFace(Dart d) ; unsigned int subdivideFace(Dart d) ;
/** /**
* coarsen the edge of d from the next level * coarsen the edge of d from the next level
...@@ -138,17 +134,17 @@ public: ...@@ -138,17 +134,17 @@ public:
*/ */
void coarsenFace(Dart d) ; void coarsenFace(Dart d) ;
/** // /**
* vertices attributes management // * vertices attributes management
*/ // */
void setVertexVertexFunctor(FunctorType& f) { vertexVertexFunctor = f ; } // void setVertexVertexFunctor(FunctorType& f) { vertexVertexFunctor = f ; }
void computeVertexVertex(Dart d) { vertexVertexFunctor(d) ; } // void computeVertexVertex(Dart d) { vertexVertexFunctor(d) ; }
//
void setEdgeVertexFunctor(FunctorType& f) { edgeVertexFunctor = f ; } // void setEdgeVertexFunctor(FunctorType& f) { edgeVertexFunctor = f ; }
void computeEdgeVertex(Dart d) { edgeVertexFunctor(d) ; } // void computeEdgeVertex(Dart d) { edgeVertexFunctor(d) ; }
//
void setFaceVertexFunctor(FunctorType& f) { faceVertexFunctor = f ; } // void setFaceVertexFunctor(FunctorType& f) { faceVertexFunctor = f ; }
void computeFaceVertex(Dart d) { faceVertexFunctor(d) ; } // void computeFaceVertex(Dart d) { faceVertexFunctor(d) ; }
} ; } ;
} // namespace CGoGN } // namespace CGoGN
......
...@@ -200,13 +200,14 @@ void GenericMap::addLevel() ...@@ -200,13 +200,14 @@ void GenericMap::addLevel()
if(m_mrDarts.size() > 1) if(m_mrDarts.size() > 1)
{ {
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1] ; AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1] ;
m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->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 = (*prevAttrib)[i] ; // get the index of the dart in previous level // unsigned int oldi = (*prevAttrib)[i] ; // get the index of the dart in previous level
(*newAttrib)[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
} // }
} }
} }
......
...@@ -249,35 +249,48 @@ bool Map2MR_Primal::faceIsSubdividedOnce(Dart d) ...@@ -249,35 +249,48 @@ bool Map2MR_Primal::faceIsSubdividedOnce(Dart d)
} }
/*************************************************** /***************************************************
* EMBEDDINGS MANAGEMENT * * SUBDIVISION *
***************************************************/ ***************************************************/
void Map2MR_Primal::copyVertexEmbeddings() void Map2MR_Primal::duplicateDart(Dart d)
{ {
unsigned int maxL = getMaxLevel() ; if(getDartLevel(d) < getCurrentLevel())
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 oldindex = dartIndex(d) ;
unsigned int newidx = (*m_mrDarts[maxL])[i] ; unsigned int newindex = newCopyOfDartLine(oldindex) ;
unsigned int emb = (*m_embeddings[VERTEX])[previdx] ; for(unsigned int i = getCurrentLevel(); i <= getMaxLevel(); ++i)
(*m_embeddings[VERTEX])[newidx] = emb ; {
if(emb != EMBNULL) (*m_mrDarts[i])[d.index] = newindex ;
m_attribs[VERTEX].refLine(emb); if(shareVertexEmbeddings)
{
unsigned int emb = (*m_embeddings[VERTEX])[oldindex] ;
(*m_embeddings[VERTEX])[newindex] = emb ;
if(emb != EMBNULL)
m_attribs[VERTEX].refLine(emb);
}
}
} }
} }
/***************************************************
* SUBDIVISION *
***************************************************/
void Map2MR_Primal::addNewLevel() void Map2MR_Primal::addNewLevel()
{ {
addLevel() ; addLevel() ;
if(shareVertexEmbeddings) if(shareVertexEmbeddings)
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);
}
}
} }
void Map2MR_Primal::subdivideEdge(Dart d) unsigned int 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") ;
assert(!edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ; assert(!edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ;
...@@ -290,12 +303,19 @@ void Map2MR_Primal::subdivideEdge(Dart d) ...@@ -290,12 +303,19 @@ void Map2MR_Primal::subdivideEdge(Dart d)
addNewLevel() ; addNewLevel() ;
setCurrentLevel(eLevel + 1) ; setCurrentLevel(eLevel + 1) ;
Dart dd = phi2(d) ;
duplicateDart(d) ;
duplicateDart(phi1(d)) ;
duplicateDart(dd) ;
duplicateDart(phi1(dd)) ;
cutEdge(d) ; cutEdge(d) ;
popLevel() ; popLevel() ;
return eLevel ;
} }
void Map2MR_Primal::subdivideFace(Dart d) unsigned int Map2MR_Primal::subdivideFace(Dart d)
{ {
assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideFace : called with a dart introduced after current level") ; assert(getDartLevel(d) <= getCurrentLevel() || !"subdivideFace : called with a dart introduced after current level") ;
assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ; assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
...@@ -350,6 +370,8 @@ void Map2MR_Primal::subdivideFace(Dart d) ...@@ -350,6 +370,8 @@ void Map2MR_Primal::subdivideFace(Dart d)
} }
popLevel() ; popLevel() ;
return fLevel ;
} }
void Map2MR_Primal::coarsenEdge(Dart d) void Map2MR_Primal::coarsenEdge(Dart 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