Commit 6cfb0639 authored by untereiner's avatar untereiner

MR Progressive Mesh for 2maps are working !

parent b5e420f2
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
{} {}
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
{} {}
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -142,7 +142,7 @@ public: ...@@ -142,7 +142,7 @@ public:
void updateBeforeCollapse(Dart d) ; void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
void updateBeforeCollapse(Dart d) ; void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d); void updateWithoutCollapse();
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -246,7 +246,7 @@ public: ...@@ -246,7 +246,7 @@ public:
void updateBeforeCollapse(Dart d) ; void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -344,7 +344,7 @@ public: ...@@ -344,7 +344,7 @@ public:
void updateBeforeCollapse(Dart d) ; void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -392,7 +392,7 @@ public: ...@@ -392,7 +392,7 @@ public:
void updateBeforeCollapse(Dart d) ; void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
bool nextEdgeWithoutUpdates(Dart& d) { } void updateWithoutCollapse() { }
} ; } ;
/***************************************************************************************************************** /*****************************************************************************************************************
......
...@@ -480,19 +480,17 @@ void EdgeSelector_QEM<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo) ...@@ -480,19 +480,17 @@ void EdgeSelector_QEM<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
} }
template <typename PFP> template <typename PFP>
bool EdgeSelector_QEM<PFP>::nextEdgeWithoutUpdates(Dart& d) void EdgeSelector_QEM<PFP>::updateWithoutCollapse()
{ {
if(cur == edges.end() || edges.empty())
return false ;
EdgeInfo& einfo = edgeInfo[(*cur).second] ; EdgeInfo& einfo = edgeInfo[(*cur).second] ;
einfo.valid = false ; einfo.valid = false ;
edges.erase(einfo.it) ; edges.erase(einfo.it) ;
//edges.erase(cur) ;
cur = edges.begin(); cur = edges.begin();
d = (*cur).second ;
return true ;
} }
/************************************************************************************ /************************************************************************************
* QUADRIC ERROR METRIC (Memoryless version) * * QUADRIC ERROR METRIC (Memoryless version) *
************************************************************************************/ ************************************************************************************/
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
virtual void updateBeforeCollapse(Dart d) = 0 ; virtual void updateBeforeCollapse(Dart d) = 0 ;
virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ; virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ;
virtual bool nextEdgeWithoutUpdates(Dart& d) = 0; virtual void updateWithoutCollapse() = 0;
} ; } ;
} // namespace Decimation } // namespace Decimation
......
...@@ -142,8 +142,9 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -142,8 +142,9 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ; unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
unsigned int nbDeletedVertex=0; unsigned int nbDeletedVertex=0;
unsigned int percentWantedPerLevel = 20; unsigned int percentWantedPerLevel = 50;
unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ; //unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ;
unsigned int nbWantedPerLevel = nbVertices * percentWantedPerLevel / 100 ;
CGoGNout << " initializing selector.." << CGoGNflush ; CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ; m_initOk = m_selector->init() ;
...@@ -158,9 +159,10 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -158,9 +159,10 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
bool finished = false ; bool finished = false ;
Dart d ; Dart d ;
while(!finished) while(!finished)
{ {
if(!m_selector->nextEdgeWithoutUpdates(d)) if(!m_selector->nextEdge(d))
break ; break ;
if(!me.isMarked(d)) if(!me.isMarked(d))
...@@ -169,19 +171,21 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -169,19 +171,21 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
Dart dt = d; Dart dt = d;
do do
{ {
Traversor2VF<typename PFP::MAP> tf(m_map, dt) ; Traversor2VE<typename PFP::MAP> tf(m_map, dt) ;
for(Dart it = tf.begin(); it != tf.end(); it = tf.next()) for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{ {
me.markOrbit<FACE>(it); me.markOrbit<EDGE>(it);
me.markOrbit<EDGE>(m_map.phi1(it));
} }
dt = m_map.phi1(dt); dt = m_map.phi1(dt);
}while(dt != d); }while(dt != d);
Traversor2VF<typename PFP::MAP> tf(m_map, m_map.phi_1(m_map.phi2(d))) ; Traversor2VE<typename PFP::MAP> tf(m_map, m_map.phi_1(m_map.phi2(d))) ;
for(Dart it = tf.begin(); it != tf.end(); it = tf.next()) for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{ {
me.markOrbit<FACE>(it); me.markOrbit<EDGE>(it);
me.markOrbit<EDGE>(m_map.phi1(it));
} }
++nbDeletedVertex ; ++nbDeletedVertex ;
...@@ -189,45 +193,39 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices) ...@@ -189,45 +193,39 @@ void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
edges.push_back(d); edges.push_back(d);
} }
m_selector->updateWithoutCollapse();
if(nbDeletedVertex >= nbWantedPerLevel) if(nbDeletedVertex >= nbWantedPerLevel)
finished = true ; finished = true ;
} }
std::cout << "nbDeletedVertices : " << nbDeletedVertex << std::endl; std::cout << "nbDeletedVertices : " << nbDeletedVertex << std::endl;
if(!edges.empty())
{
//create the new level
m_map.addLevelFront();
m_map.setCurrentLevel(0);
//create the new level AttributeContainer& attribs = m_map.getMRAttributeContainer();
m_map.addLevelFront(); AttributeMultiVector<unsigned int>* attribLevel = m_map.getMRLevelAttributeVector();
m_map.setCurrentLevel(0); AttributeMultiVector<unsigned int>* attribDarts = m_map.getMRDartAttributeVector(0);
AttributeContainer& attribs = m_map.getMRAttributeContainer(); for(unsigned int i = attribs.begin(); i != attribs.end(); attribs.next(i))
AttributeMultiVector<unsigned int>* attribLevel = m_map.getMRLevelAttributeVector(); {
AttributeMultiVector<unsigned int>* attribDarts = m_map.getMRDartAttributeVector(0); if((*attribDarts)[i] == MRNULL)
++(*attribLevel)[i];
}
for(unsigned int i = attribs.begin(); i != attribs.end(); attribs.next(i)) for(std::vector<Dart>::iterator it = edges.begin() ; it != edges.end() ; ++it)
{ {
if((*attribDarts)[i] == MRNULL) // if(*it == Dart(301459))
++(*attribLevel)[i]; // break;
}
for(std::vector<Dart>::iterator it = edges.begin() ; it != edges.end() ; ++it) collapseEdge(*it);
{ }
collapseEdge(*it);
} }
// Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
// Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
//
// m_selector->updateBeforeCollapse(d) ; // update selector
//
// collapseEdge(d);
//
// m_selector->updateAfterCollapse(d2, dd2) ; // update selector
//
//
// CGoGNout << "..done (" << nbDeletedVertex << " vertices)" << CGoGNendl ;
//
// m_map.printMR();
} }
...@@ -244,6 +242,11 @@ void Map2MR_PM<PFP>::collapseEdge(Dart d) ...@@ -244,6 +242,11 @@ void Map2MR_PM<PFP>::collapseEdge(Dart d)
//m_map.printMR(); //m_map.printMR();
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi1(d)), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi_1(d)), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi1(m_map.phi2(d))), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi_1(m_map.phi2(d))), 0);
m_map.duplicateDartAtOneLevel(d, 0); m_map.duplicateDartAtOneLevel(d, 0);
m_map.duplicateDartAtOneLevel(m_map.phi1(d), 0); m_map.duplicateDartAtOneLevel(m_map.phi1(d), 0);
m_map.duplicateDartAtOneLevel(m_map.phi_1(d), 0); m_map.duplicateDartAtOneLevel(m_map.phi_1(d), 0);
...@@ -251,10 +254,7 @@ void Map2MR_PM<PFP>::collapseEdge(Dart d) ...@@ -251,10 +254,7 @@ void Map2MR_PM<PFP>::collapseEdge(Dart d)
m_map.duplicateDartAtOneLevel(m_map.phi_1(m_map.phi2(d)), 0); m_map.duplicateDartAtOneLevel(m_map.phi_1(m_map.phi2(d)), 0);
m_map.duplicateDartAtOneLevel(m_map.phi1(m_map.phi2(d)), 0); m_map.duplicateDartAtOneLevel(m_map.phi1(m_map.phi2(d)), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi1(d)), 0); //m_map.printMR();
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi_1(d)), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi1(m_map.phi2(d))), 0);
m_map.duplicateDartAtOneLevel(m_map.phi2(m_map.phi_1(m_map.phi2(d))), 0);
m_map.collapseEdge(d); m_map.collapseEdge(d);
......
...@@ -117,6 +117,14 @@ inline void GenericMap::deleteDart(Dart d) ...@@ -117,6 +117,14 @@ inline void GenericMap::deleteDart(Dart d)
if(getDartLevel(d) > m_mrCurrentLevel) if(getDartLevel(d) > m_mrCurrentLevel)
{ {
unsigned int di = (*m_mrDarts[m_mrCurrentLevel + 1])[d.index];
// si le brin de niveau i pointe sur le meme brin que le niveau i-1
if(di != index)
{
if(isDartValid(d))//index))
deleteDartLine(index) ;
}
(*m_mrDarts[m_mrCurrentLevel])[d.index] = MRNULL ; (*m_mrDarts[m_mrCurrentLevel])[d.index] = MRNULL ;
return; return;
} }
...@@ -124,7 +132,7 @@ inline void GenericMap::deleteDart(Dart d) ...@@ -124,7 +132,7 @@ 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
if(getDartLevel(d) == m_mrCurrentLevel) if(getDartLevel(d) == m_mrCurrentLevel)
{ {
if(isDartValid(index)) if(isDartValid(d))//index))
deleteDartLine(index) ; deleteDartLine(index) ;
m_mrattribs.removeLine(d.index); m_mrattribs.removeLine(d.index);
...@@ -132,11 +140,11 @@ inline void GenericMap::deleteDart(Dart d) ...@@ -132,11 +140,11 @@ inline void GenericMap::deleteDart(Dart d)
} }
else else
{ {
unsigned int di = (*m_mrDarts[m_mrCurrentLevel - 1])[d.index]; //m_mrDarts[m_mrCurrentLevel - 1]->operator[](d.index) ; unsigned int di = (*m_mrDarts[m_mrCurrentLevel - 1])[d.index];
// si le brin de niveau i pointe sur le meme brin que le niveau i-1 // si le brin de niveau i pointe sur le meme brin que le niveau i-1
if(di != index) if(di != index)
{ {
if(isDartValid(index)) if(isDartValid(d))//index))
deleteDartLine(index) ; deleteDartLine(index) ;
} }
...@@ -155,7 +163,7 @@ inline void GenericMap::deleteDartLine(unsigned int index) ...@@ -155,7 +163,7 @@ inline void GenericMap::deleteDartLine(unsigned int index)
m_attribs[DART].removeLine(index) ; // free the dart line m_attribs[DART].removeLine(index) ; // free the dart line
for (unsigned int t = 0; t < m_nbThreads; ++t) // clear markers of for (unsigned int t = 0; t < m_nbThreads; ++t) // clear markers of
(*m_markTables[DART][t])[index].clear() ; // the removed dart (*m_markTables[DART][t])[index].clear() ; // the removed dart
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{ {
...@@ -167,7 +175,7 @@ inline void GenericMap::deleteDartLine(unsigned int index) ...@@ -167,7 +175,7 @@ inline void GenericMap::deleteDartLine(unsigned int index)
if(m_attribs[orbit].unrefLine(emb)) // unref the pointed embedding line 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 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_markTables[orbit][t])[emb].clear() ; // its last unref (and was thus freed)
} }
} }
} }
......
...@@ -260,7 +260,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces) ...@@ -260,7 +260,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
phi2unsew(d); // Unlink the opposite edges phi2unsew(d); // Unlink the opposite edges
Dart f = phi1(e) ; Dart f = phi1(e) ;
Dart h = alpha1(e); Dart h = phi2(phi_1(e));
if (h != e) if (h != e)
resV = h; resV = h;
...@@ -276,7 +276,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces) ...@@ -276,7 +276,7 @@ Dart Map2::collapseEdge(Dart d, bool delDegenerateFaces)
f = phi1(d) ; f = phi1(d) ;
if(resV == NIL) if(resV == NIL)
{ {
h = alpha1(d); h = phi2(phi_1(d));
if (h != d) if (h != d)
resV = h; resV = h;
} }
......
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