Commit 91c76a9d authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

Merge cgogn.unistra.fr:~kraemer/CGoGN

parents fbf4fa5d 11df28e3
...@@ -42,7 +42,7 @@ template <typename PFP, typename EMBV, typename EMB> ...@@ -42,7 +42,7 @@ template <typename PFP, typename EMBV, typename EMB>
EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs) EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs)
{ {
EMB center = AttribOps::zero<EMB,PFP>() ; EMB center = AttribOps::zero<EMB,PFP>() ;
unsigned count = 0 ; unsigned int count = 0 ;
Traversor3WV<typename PFP::MAP> tra(map,d); Traversor3WV<typename PFP::MAP> tra(map,d);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next()) for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
......
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
{ {
unsigned int v0 = vID[indices[0]] ; unsigned int v0 = vID[indices[0]] ;
unsigned int v1 = vID[indices[1]] ; unsigned int v1 = vID[indices[1]] ;
unsigned int v2 = vID[indices[2]] ; // unsigned int v2 = vID[indices[2]] ;
Dart it = d ; Dart it = d ;
do do
......
...@@ -119,12 +119,12 @@ protected: ...@@ -119,12 +119,12 @@ protected:
AttributeContainer m_mrattribs ; AttributeContainer m_mrattribs ;
/** /**
* pointers to attributes that store indices in m_attribs[DART] (one for each level) * pointers to attributes of m_mrattribs that store indices in m_attribs[DART] (one for each level)
*/ */
std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ; std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ;
/** /**
* pointer to attribute that stores darts insertion levels * pointer to attribute of m_mrattribs that stores darts insertion levels
*/ */
AttributeMultiVector<unsigned int>* m_mrLevels ; AttributeMultiVector<unsigned int>* m_mrLevels ;
......
...@@ -96,8 +96,13 @@ inline Dart GenericMap::newDart() ...@@ -96,8 +96,13 @@ inline Dart GenericMap::newDart()
for(unsigned int i = 0; i < m_mrCurrentLevel; ++i) // for all previous levels for(unsigned int i = 0; i < m_mrCurrentLevel; ++i) // for all previous levels
(*m_mrDarts[i])[mrdi] = MRNULL ; // this MRdart does not exist (*m_mrDarts[i])[mrdi] = MRNULL ; // this MRdart does not exist
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) // for all levels from current to max // for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i) // for all levels from current to max
(*m_mrDarts[i])[mrdi] = di ; // make this MRdart points to the new dart line // (*m_mrDarts[i])[mrdi] = di ; // make this MRdart point to the new dart line
(*m_mrDarts[m_mrCurrentLevel])[mrdi] = di ; // for the current level, this MRdart points to the new dart line
for(unsigned int i = m_mrCurrentLevel + 1; i < m_mrDarts.size(); ++i) // for all levels from current + 1 to max
(*m_mrDarts[i])[mrdi] = copyDartLine(di) ; // make this MRdart point to a copy of the new dart line
return Dart::create(mrdi) ; return Dart::create(mrdi) ;
} }
...@@ -156,7 +161,6 @@ inline unsigned int GenericMap::copyDartLine(unsigned int index) ...@@ -156,7 +161,6 @@ inline unsigned int GenericMap::copyDartLine(unsigned int index)
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])
// (*m_embeddings[orbit])[newindex] = EMBNULL ;
{ {
unsigned int emb = (*m_embeddings[orbit])[newindex] ; // add a ref to the cells pointed unsigned int emb = (*m_embeddings[orbit])[newindex] ; // add a ref to the cells pointed
if(emb != EMBNULL) // by the new dart line if(emb != EMBNULL) // by the new dart line
......
...@@ -41,7 +41,6 @@ public: ...@@ -41,7 +41,6 @@ public:
virtual void operator() () = 0 ; virtual void operator() () = 0 ;
} ; } ;
/********************************************************************************* /*********************************************************************************
* LOOP BASIC FUNCTIONS * LOOP BASIC FUNCTIONS
*********************************************************************************/ *********************************************************************************/
......
...@@ -104,15 +104,18 @@ public: ...@@ -104,15 +104,18 @@ public:
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
protected:
// void propagatePhi1(Dart d) ;
// void propagatePhi_1(Dart d) ;
/** /**
* add a new resolution level * add a new resolution level
*/ */
void addNewLevel() ; void addNewLevel(bool embedNewVertices = true) ;
void propagateDartRelation(Dart d, AttributeMultiVector<Dart>* rel) ;
void propagateDartEmbedding(Dart d, unsigned int orbit) ;
void propagateOrbitEmbedding(Dart d, unsigned int orbit) ;
Dart cutEdge(Dart d) ;
void splitFace(Dart d, Dart e) ;
protected:
/** /**
* subdivide the edge of d to the next level * subdivide the edge of d to the next level
*/ */
...@@ -138,9 +141,7 @@ public: ...@@ -138,9 +141,7 @@ public:
* vertices attributes management * vertices attributes management
*/ */
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; } void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; } void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; } void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
} ; } ;
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
std::string mapTypeName() { return "Map2MR_PrimalRegular" ; } std::string mapTypeName() { return "Map2MR_PrimalRegular" ; }
void addNewLevel(bool embedNewVertices) ; void addNewLevel(bool embedNewVertices = true) ;
void addSynthesisFilter(Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; } void addSynthesisFilter(Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; } void addAnalysisFilter(Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; }
......
...@@ -202,11 +202,11 @@ void GenericMap::addLevel() ...@@ -202,11 +202,11 @@ void GenericMap::addLevel()
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1] ; // copy the indices of AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[newLevel - 1] ; // copy the indices of
m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ; // previous level into new level m_mrattribs.copyAttribute(newAttrib->getIndex(), prevAttrib->getIndex()) ; // previous level into 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] = copyDartLine(oldi) ; // copy the dart and affect it to the new level (*newAttrib)[i] = copyDartLine(oldi) ; // copy the dart and affect it to the new level
// } }
} }
} }
......
...@@ -250,61 +250,166 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d) ...@@ -250,61 +250,166 @@ bool Map2MR_PrimalAdapt::faceIsSubdividedOnce(Dart d)
* SUBDIVISION * * SUBDIVISION *
***************************************************/ ***************************************************/
//void Map2MR_PrimalAdapt::propagatePhi1(Dart d) void Map2MR_PrimalAdapt::addNewLevel(bool embedNewVertices)
{
pushLevel() ;
addLevel() ;
setCurrentLevel(getMaxLevel()) ;
// for(unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i))
// {
// unsigned int newindex = copyDartLine((*m_mrDarts[m_mrCurrentLevel])[i]) ; // duplicate all darts
// (*m_mrDarts[m_mrCurrentLevel])[i] = newindex ; // on the new max level
// if(!shareVertexEmbeddings)
// (*m_embeddings[VERTEX])[newindex] = EMBNULL ; // set vertex embedding to EMBNULL if no sharing
// }
popLevel() ;
}
void Map2MR_PrimalAdapt::propagateDartRelation(Dart d, AttributeMultiVector<Dart>* rel)
{
Dart dd = (*rel)[dartIndex(d)] ;
pushLevel() ;
for(unsigned int i = getCurrentLevel() + 1; i <= getMaxLevel(); ++i)
{
setCurrentLevel(i) ;
(*rel)[dartIndex(d)] = dd ;
}
popLevel() ;
}
void Map2MR_PrimalAdapt::propagateDartEmbedding(Dart d, unsigned int orbit)
{
unsigned int emb = getEmbedding(orbit, d) ;
pushLevel() ;
for(unsigned int i = getCurrentLevel() + 1; i <= getMaxLevel(); ++i)
{
setCurrentLevel(i) ;
setDartEmbedding(orbit, d, emb) ;
}
popLevel() ;
}
void Map2MR_PrimalAdapt::propagateOrbitEmbedding(Dart d, unsigned int orbit)
{
unsigned int emb = getEmbedding(orbit, d) ;
pushLevel() ;
for(unsigned int i = getCurrentLevel() + 1; i <= getMaxLevel(); ++i)
{
setCurrentLevel(i) ;
embedOrbit(orbit, d, emb) ;
}
popLevel() ;
}
//Dart Map2MR_PrimalAdapt::cutEdge(Dart d)
//{ //{
// assert(getDartLevel(d) <= getCurrentLevel() || !"propagatePhi1 : called with a dart inserted after current level") ; // Dart dd = phi2(d) ;
// //
// if(getCurrentLevel() == getMaxLevel()) // Dart d1 = newDart() ;
// return ; // Dart dd1 = newDart() ;
// //
// bool finished = false ; // pushLevel() ;
// unsigned int i = getCurrentLevel() + 1 ; // for(unsigned int i = getCurrentLevel(); i <= getMaxLevel(); ++i)
// do
// { // {
// unsigned int prevdi = (*m_mrDarts[i - 1])[d.index] ; // setCurrentLevel(i) ;
// unsigned int curdi = (*m_mrDarts[i])[d.index] ; //
// if(curdi != prevdi) // phi2unsew(d) ;
// (*m_phi1)[curdi] = (*m_phi1)[prevdi] ; //
// else // phi1sew(d, d1) ;
// finished = true ; // if (isBoundaryMarked(d))
// ++i ; // boundaryMark(d1) ;
// if(i > getMaxLevel())
// finished = true ;
// } while(!finished) ;
//}
// //
//void Map2MR_PrimalAdapt::propagatePhi_1(Dart d) // phi1sew(dd, dd1) ;
// if (isBoundaryMarked(dd))
// boundaryMark(dd1) ;
//
// phi2sew(d, dd1) ;
// phi2sew(dd, d1) ;
// }
// popLevel() ;
//
// return d1 ;
//}
Dart Map2MR_PrimalAdapt::cutEdge(Dart d)
{
Dart dd = phi2(d) ;
Dart d1 = EmbeddedMap2::cutEdge(d) ;
Dart dd1 = phi1(dd) ;
Dart d11 = phi1(d1) ;
Dart dd11 = phi1(dd1) ;
propagateDartRelation(d, m_phi1) ;
propagateDartRelation(d, m_phi2) ;
propagateDartRelation(dd, m_phi1) ;
propagateDartRelation(dd, m_phi2) ;
propagateDartRelation(d1, m_phi1) ;
propagateDartRelation(d1, m_phi_1) ;
propagateDartRelation(d1, m_phi2) ;
propagateDartRelation(dd1, m_phi1) ;
propagateDartRelation(dd1, m_phi_1) ;
propagateDartRelation(dd1, m_phi2) ;
propagateDartRelation(d11, m_phi_1) ;
propagateDartRelation(dd11, m_phi_1) ;
return d1 ;
}
//void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e)
//{ //{
// assert(getDartLevel(d) <= getCurrentLevel() || !"propagatePhi_1 : called with a dart inserted after current level") ; // Dart dprev = phi_1(d) ;
// Dart eprev = phi_1(e) ;
// //
// if(getCurrentLevel() == getMaxLevel()) // Dart dd = newDart() ;
// return ; // Dart ee = newDart() ;
// //
// bool finished = false ; // pushLevel() ;
// unsigned int i = getCurrentLevel() + 1 ; // for(unsigned int i = getCurrentLevel(); i <= getMaxLevel(); ++i)
// do
// { // {
// unsigned int prevdi = (*m_mrDarts[i - 1])[d.index] ; // setCurrentLevel(i) ;
// unsigned int curdi = (*m_mrDarts[i])[d.index] ; //
// if(curdi != prevdi) // phi1sew(dprev, dd) ;
// (*m_phi_1)[curdi] = (*m_phi_1)[prevdi] ; // if (isBoundaryMarked(dprev))
// else // boundaryMark(dd);
// finished = true ; //
// ++i ; // phi1sew(eprev, ee) ;
// if(i > getMaxLevel()) // if (isBoundaryMarked(eprev))
// finished = true ; // boundaryMark(ee);
// } while(!finished) ; //
// phi1sew(dprev, eprev) ;
//
// phi2sew(dd, ee) ;
//
// copyDartEmbedding(VERTEX, ee, d) ;
// copyDartEmbedding(VERTEX, dd, e) ;
// }
// popLevel() ;
//} //}
void Map2MR_PrimalAdapt::addNewLevel() void Map2MR_PrimalAdapt::splitFace(Dart d, Dart e)
{ {
addLevel() ; Dart dprev = phi_1(d) ;
if(shareVertexEmbeddings) Dart eprev = phi_1(e) ;
{ EmbeddedMap2::splitFace(d, e) ;
} Dart dd = phi1(dprev) ;
else Dart ee = phi1(eprev) ;
{
} propagateDartRelation(d, m_phi_1) ;
propagateDartRelation(e, m_phi_1) ;
propagateDartRelation(dd, m_phi1) ;
propagateDartRelation(dd, m_phi_1) ;
propagateDartRelation(dd, m_phi2) ;
propagateDartRelation(ee, m_phi1) ;
propagateDartRelation(ee, m_phi_1) ;
propagateDartRelation(ee, m_phi2) ;
propagateDartRelation(dprev, m_phi1) ;
propagateDartRelation(eprev, m_phi1) ;
propagateDartEmbedding(dd, VERTEX) ;
propagateDartEmbedding(ee, VERTEX) ;
} }
void Map2MR_PrimalAdapt::subdivideEdge(Dart d) void Map2MR_PrimalAdapt::subdivideEdge(Dart d)
...@@ -316,19 +421,12 @@ void Map2MR_PrimalAdapt::subdivideEdge(Dart d) ...@@ -316,19 +421,12 @@ void Map2MR_PrimalAdapt::subdivideEdge(Dart d)
incCurrentLevel() ; incCurrentLevel() ;
duplicateDart(d) ; Dart d1 = cutEdge(d) ;
Dart dd1 = phi2(d) ;
Dart dd = phi2(d) ;
duplicateDart(dd) ;
Dart d1 = phi1(d) ;
duplicateDart(d1) ;
Dart dd1 = phi1(dd) ;
duplicateDart(dd1) ;
cutEdge(d) ; (*edgeVertexFunctor)(d1) ;
(*edgeVertexFunctor)(phi1(d)) ; propagateDartEmbedding(d1, VERTEX) ;
propagateDartEmbedding(dd1, VERTEX) ;
decCurrentLevel() ; decCurrentLevel() ;
} }
...@@ -366,9 +464,9 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) ...@@ -366,9 +464,9 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
do do
{ {
++degree ; // compute the degree of the face ++degree ; // compute the degree of the face
Dart nf = phi2(it) ; // Dart nf = phi2(it) ;
if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first // if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first
subdivideFace(nf) ; // subdivideFace(nf) ;
if(!edgeIsSubdivided(it)) if(!edgeIsSubdivided(it))
subdivideEdge(it) ; // and cut the edges (if they are not already) subdivideEdge(it) ; // and cut the edges (if they are not already)
it = phi1(it) ; it = phi1(it) ;
...@@ -381,18 +479,21 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) ...@@ -381,18 +479,21 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
Dart dd = phi1(old) ; Dart dd = phi1(old) ;
Dart e = phi1(dd) ; Dart e = phi1(dd) ;
(*vertexVertexFunctor)(e) ; (*vertexVertexFunctor)(e) ;
propagateOrbitEmbedding(e, VERTEX) ;
e = phi1(e) ; e = phi1(e) ;
splitFace(dd, e) ; splitFace(dd, e) ;
dd = e ; dd = e ;
e = phi1(dd) ; e = phi1(dd) ;
(*vertexVertexFunctor)(e) ; (*vertexVertexFunctor)(e) ;
propagateOrbitEmbedding(e, VERTEX) ;
e = phi1(e) ; e = phi1(e) ;
splitFace(dd, e) ; splitFace(dd, e) ;
dd = e ; dd = e ;
e = phi1(dd) ; e = phi1(dd) ;
(*vertexVertexFunctor)(e) ; (*vertexVertexFunctor)(e) ;
propagateOrbitEmbedding(e, VERTEX) ;
e = phi1(e) ; e = phi1(e) ;
splitFace(dd, e) ; splitFace(dd, e) ;
} }
...@@ -401,6 +502,7 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) ...@@ -401,6 +502,7 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
Dart dd = phi1(old) ; Dart dd = phi1(old) ;
Dart next = phi1(dd) ; Dart next = phi1(dd) ;
(*vertexVertexFunctor)(next) ; (*vertexVertexFunctor)(next) ;
propagateOrbitEmbedding(next, VERTEX) ;
next = phi1(next) ; next = phi1(next) ;
splitFace(dd, next) ; // insert a first edge splitFace(dd, next) ; // insert a first edge
Dart ne = alpha1(dd) ; Dart ne = alpha1(dd) ;
...@@ -409,16 +511,19 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d) ...@@ -409,16 +511,19 @@ unsigned int Map2MR_PrimalAdapt::subdivideFace(Dart d)
dd = phi1(next) ; dd = phi1(next) ;
(*vertexVertexFunctor)(dd) ; (*vertexVertexFunctor)(dd) ;
propagateOrbitEmbedding(dd, VERTEX) ;
dd = phi1(dd) ; dd = phi1(dd) ;
while(dd != ne) // turn around the face and insert new edges while(dd != ne) // turn around the face and insert new edges
{ // linked to the central vertex { // linked to the central vertex
splitFace(phi1(ne), dd) ; splitFace(phi1(ne), dd) ;
dd = phi1(dd) ; dd = phi1(dd) ;
(*vertexVertexFunctor)(dd) ; (*vertexVertexFunctor)(dd) ;
propagateOrbitEmbedding(dd, VERTEX) ;
dd = phi1(dd) ; dd = phi1(dd) ;
} }
(*faceVertexFunctor)(phi2(ne)) ; (*faceVertexFunctor)(phi2(ne)) ;
propagateOrbitEmbedding(phi2(ne), VERTEX) ;
} }
popLevel() ; popLevel() ;
......
...@@ -40,13 +40,13 @@ void Map2MR_PrimalRegular::addNewLevel(bool embedNewVertices) ...@@ -40,13 +40,13 @@ void Map2MR_PrimalRegular::addNewLevel(bool embedNewVertices)
addLevel() ; addLevel() ;
setCurrentLevel(getMaxLevel()) ; setCurrentLevel(getMaxLevel()) ;
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 newindex = copyDartLine((*m_mrDarts[m_mrCurrentLevel])[i]) ; // duplicate all darts // unsigned int newindex = copyDartLine((*m_mrDarts[m_mrCurrentLevel])[i]) ; // duplicate all darts
(*m_mrDarts[m_mrCurrentLevel])[i] = newindex ; // on the new max level // (*m_mrDarts[m_mrCurrentLevel])[i] = newindex ; // on the new max level
if(!shareVertexEmbeddings) // if(!shareVertexEmbeddings)
(*m_embeddings[VERTEX])[newindex] = EMBNULL ; // set vertex embedding to EMBNULL if no sharing // (*m_embeddings[VERTEX])[newindex] = EMBNULL ; // set vertex embedding to EMBNULL if no sharing
} // }
// cut edges // cut edges
TraversorE<Map2MR_PrimalRegular> travE(*this) ; TraversorE<Map2MR_PrimalRegular> travE(*this) ;
......
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