Commit c5412ed5 authored by Pierre Kraemer's avatar Pierre Kraemer

MR : test without darts duplication

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