Commit b1b59022 authored by untereiner's avatar untereiner

adding multiresolution branch in algorithm directory

parent 293b5646
......@@ -75,14 +75,19 @@ public:
~Map2MR_PM();
//add a coarse level
void addNewLevel() ;
//add a coarser level
void addNewLevel(unsigned int percentWantedVertices);
//create the progressive meshes
void createPM(unsigned int percentWantedVertices);
//coarsen the mesh -> analysis
void coarsen() ;
//refine the mesh -> synthesis
void refine() ;
bool initOk() { return m_initOk; }
} ;
} // namespace Multiresolution
......
......@@ -38,7 +38,6 @@ Map2MR_PM<PFP>::Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position,
) :
m_map(map), m_position(position)
{
m_map.initMR() ;
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
switch(a)
......@@ -117,7 +116,6 @@ Map2MR_PM<PFP>::Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position,
CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ;
CGoGNout << "..done" << CGoGNendl ;
}
template <typename PFP>
......@@ -134,22 +132,25 @@ Map2MR_PM<PFP>::~Map2MR_PM()
template <typename PFP>
void Map2MR_PM<PFP>::addNewLevel()
void Map2MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
{
m_map.pushLevel() ;
//Add the current level higher
unsigned int newLevel = m_map.getMaxLevel() + 1 ;
std::stringstream ss ;
ss << "MRdart_"<< newLevel ;
//AttributeMultiVector<unsigned int>* newAttrib = m_map.addMRRelation(ss.str());
//AttributeMultiVector<unsigned int>* newAttrib = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
//m_mrDarts.push_back(newAttrib) ;
//m_mrNbDarts.push_back(0) ;
m_map.pushLevel() ;
//m_map.push_front(newAttrib);
m_map.addFrontLevel();
m_map.setCurrentLevel(0);
// //Add the current level higher
//
// unsigned int newLevel = m_map.getMaxLevel() + 1 ;
// std::stringstream ss ;
// ss << "MRdart_"<< newLevel ;
//
// AttributeMultiVector<unsigned int>* newAttrib = m_map.addMRRelation(ss.str());
// AttributeMultiVector<unsigned int>* newAttrib = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
// m_mrDarts.push_back(newAttrib) ;
// m_mrNbDarts.push_back(0) ;
//
// //m_map.push_front(newAttrib);
// if(m_mrDarts.size() > 1)
// {
// for(unsigned int i = newLevel; i > 0 ; --i)
......@@ -161,14 +162,66 @@ void Map2MR_PM<PFP>::addNewLevel()
// }
// }
//
m_map.popLevel() ;
m_map.setCurrentLevel(0);
// m_map.popLevel() ;
//
// m_map.setCurrentLevel(0);
}
template <typename PFP>
void Map2MR_PM<PFP>::createPM(unsigned int percentWantedVertices)
{
//addNewLevel();
m_map.pushLevel() ;
m_map.addFrontLevel();
m_map.setCurrentLevel(0) ;
// std::cout << "level : " << m_map.getMaxLevel() << std::endl;
//
// unsigned int nbVertices = m_map.template getNbOrbits<VERTEX>() ;
// unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
// CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ;
//
// bool finished = false ;
// Dart d ;
// while(!finished)
// {
// if(!m_selector->nextEdge(d))
// break ;
//
// --nbVertices ;
// Dart d2 = m_map.phi2(m_map.phi_1(d)) ;
// Dart dd2 = m_map.phi2(m_map.phi_1(m_map.phi2(d))) ;
//
// for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
// {
// (*it)->approximate(d) ; // compute approximated attributes with its associated detail
// (*it)->saveApprox(d) ;
// }
//
// m_selector->updateBeforeCollapse(d) ; // update selector
//
// m_map.collapseEdge(d);
//
// unsigned int newV = m_map.template embedNewCell<VERTEX>(d2) ;
// unsigned int newE1 = m_map.template embedNewCell<EDGE>(d2) ;
// unsigned int newE2 = m_map.template embedNewCell<EDGE>(dd2) ;
//// vs->setApproxV(newV) ;
//// vs->setApproxE1(newE1) ;
//// vs->setApproxE2(newE2) ;
//
// for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
// (*it)->affectApprox(d2); // affect data to the resulting vertex
//
// m_selector->updateAfterCollapse(d2, dd2) ; // update selector
//
// if(nbVertices <= nbWantedVertices)
// finished = true ;
// }
// delete m_selector ;
// m_selector = NULL ;
//
// m_map.popLevel() ;
// CGoGNout << "..done (" << nbVertices << " vertices)" << CGoGNendl ;
}
template <typename PFP>
......
......@@ -229,6 +229,11 @@ public:
*/
void addLevel() ;
/**
* add a resolution level in the front of the level table (use only in MRMaps)
*/
void addFrontLevel() ;
/**
* remove last resolution level (use only in MRMaps)
*/
......
......@@ -210,6 +210,29 @@ void GenericMap::addLevel()
}
}
void GenericMap::addFrontLevel()
{
unsigned int newLevel = m_mrDarts.size() ;
std::stringstream ss ;
ss << "MRdart_"<< newLevel ;
AttributeMultiVector<unsigned int>* newAttrib = m_mrattribs.addAttribute<unsigned int>(ss.str()) ;
m_mrDarts.insert(m_mrDarts.begin(), newAttrib) ;
m_mrNbDarts.insert(m_mrNbDarts.begin(), 0) ;
if(m_mrDarts.size() > 1)
{
AttributeMultiVector<unsigned int>* prevAttrib = m_mrDarts[1] ; // copy the indices of
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))
{
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
}
}
}
void GenericMap::removeLevel()
{
unsigned int maxL = getMaxLevel() ;
......
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