Commit b5d8570a authored by untereiner's avatar untereiner

renaming a namespace for volumetric decimation

parent d5ff9c22
......@@ -37,7 +37,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
enum ApproximatorType
......@@ -144,9 +144,9 @@ public:
};
} // namespace DecimationVolumes
} // namespace Decimation
}
} // namespace Volume
} // namespace Algo
......
......@@ -39,7 +39,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
template <typename PFP>
......@@ -51,9 +51,9 @@ void decimate(
unsigned int percentWantedVertices
);
} //namespace DecimationVolumes
} //namespace Decimation
}
} //namesapce Volume
} //namespace Algo
......
......@@ -31,7 +31,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
template <typename PFP>
......@@ -56,10 +56,10 @@ void decimate(typename PFP::MAP& map, SelectorType s, ApproximatorType a,
switch(s)
{
case S_MapOrder :
selector = new Algo::DecimationVolumes::EdgeSelector_MapOrder<PFP>(map, position, approximators) ;
selector = new Algo::Volume::Decimation::EdgeSelector_MapOrder<PFP>(map, position, approximators) ;
break ;
case S_Random :
selector = new Algo::DecimationVolumes::EdgeSelector_Random<PFP>(map, position, approximators) ;
selector = new Algo::Volume::Decimation::EdgeSelector_Random<PFP>(map, position, approximators) ;
break ;
default:
CGoGNout << "not yet implemented" << CGoGNendl;
......@@ -122,9 +122,9 @@ void decimate(typename PFP::MAP& map, SelectorType s, ApproximatorType a,
delete (*it) ;
}
} //namespace DecimationVolumes
} //namespace Decimation
}
} //namespace Volume
} //namespace Algo
......
......@@ -15,7 +15,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
/*
......@@ -186,9 +186,9 @@ public:
} //end namespace DecimationVolumes
} //end namespace Decimation
}
} //namespace Volume
} //end namespace Algo
......
......@@ -35,7 +35,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
/************************************************************************************
* MAP ORDER *
......@@ -323,7 +323,7 @@ void EdgeSelector_SG98<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
// einfo.valid = true ;
}
} //end namespace DecimationVolumique
}
} //end namespace Decimation
} //namespace Volume
} //end namespace Algo
} //end namespace CGoGN
......@@ -36,7 +36,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
template <typename PFP>
......@@ -78,9 +78,9 @@ public:
} ;
} //namespace DecimationVolumes
} //namespace Decimation
}
} //namespace Volume
} //namespace Algo
......
......@@ -34,7 +34,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
/************************************************************************************
......@@ -122,9 +122,9 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
// }
}
} //end namespace DecimationVolumes
} //end namespace Decimation
}
} //namespace Volume
} //end namespace Algo
......
......@@ -37,7 +37,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
enum OperatorType
......@@ -179,9 +179,9 @@ public:
};
} //end namespace DecimationVolumes
} //end namespace Decimation
}
} //namespace Volume
} //end namespace Algo
......
......@@ -31,7 +31,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
/************************************************************************************
......@@ -161,9 +161,9 @@ void OperatorList<PFP>::refine(VertexAttribute<typename PFP::VEC3>& position)
}
} //end namespace DecimationVolumes
} //end namespace Decimation
}
} //namespace Volume
} //end namespace Algo
......
......@@ -13,7 +13,7 @@ namespace Algo
namespace Volume
{
namespace DecimationVolumes
namespace Decimation
{
enum SelectorType
......@@ -62,9 +62,9 @@ public:
virtual void updateWithoutCollapse() = 0;
};
} //end namespace DecimationVolumes
} //end namespace Decimation
}
} //namespace Volume
} //end namespace Algo
......
......@@ -65,14 +65,14 @@ private:
bool m_initOk ;
Algo::Decimation::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Decimation::PredictorGen<PFP>*> m_predictors ;
Algo::Surface::Decimation::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*> m_predictors ;
Algo::Decimation::Approximator<PFP, VEC3>* m_positionApproximator ;
Algo::Surface::Decimation::Approximator<PFP, VEC3, EDGE>* m_positionApproximator ;
std::vector<Filter*> synthesisFilters ;
std::vector<Filter*> analysisFilters ;
std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ;
public:
Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position);
......@@ -80,7 +80,7 @@ public:
~Map2MR_PM();
//create a progressive mesh (a coarser level)
void createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a) ;
void createPM(Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::ApproximatorType a) ;
void addNewLevel(unsigned int percentWantedVertices);
......@@ -94,8 +94,8 @@ public:
bool initOk() { return m_initOk; }
void addSynthesisFilter(Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Filter* f) { analysisFilters.push_back(f) ; }
void addSynthesisFilter(Algo::MR::Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Algo::MR::Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
......
......@@ -123,7 +123,7 @@ void Map2MR_PM<PFP>::createPM(Algo::Surface::Decimation::SelectorType s, Algo::S
if(! (*it)->init())
m_initOk = false ;
if((*it)->getApproximatedAttributeName() == "position")
m_positionApproximator = reinterpret_cast<Algo::Surface::Decimation::Approximator<PFP, VEC3>*>(*it) ;
m_positionApproximator = reinterpret_cast<Algo::Surface::Decimation::Approximator<PFP, VEC3, EDGE>*>(*it) ;
}
CGoGNout << "..done" << CGoGNendl ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __MAP3MR_PM__
#define __MAP3MR_PM__
#include "Topology/map/embeddedMap3.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor3.h"
#include "Container/attributeContainer.h"
#include "Algo/DecimationVolumes/selector.h"
#include "Algo/DecimationVolumes/edgeSelector.h"
#include "Algo/DecimationVolumes/geometryApproximator.h"
#include "Algo/Multiresolution/filter.h"
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace MR
{
template <typename PFP>
class Map3MR_PM
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
MAP& m_map ;
VertexAttribute<VEC3>& m_position;
bool m_initOk ;
Algo::Volume::Decimation::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::Volume::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Volume::Decimation::PredictorGen<PFP>*> m_predictors ;
Algo::Volume::Decimation::Approximator<PFP, VEC3>* m_positionApproximator ;
std::vector<Filter*> synthesisFilters ;
std::vector<Filter*> analysisFilters ;
public:
Map3MR_PM(MAP& map, VertexAttribute<VEC3>& position);
~Map3MR_PM();
//create a progressive mesh (a coarser level)
void createPM(Algo::Volume::Decimation::SelectorType s, Algo::Volume::Decimation::ApproximatorType a) ;
void addNewLevel(unsigned int percentWantedVertices);
void collapseEdge(Dart d);
//coarsen the mesh -> analysis
void coarsen() ;
//refine the mesh -> synthesis
void refine() ;
bool initOk() { return m_initOk; }
void addSynthesisFilter(Filter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Filter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
/**
* Given the vertex of d in the current level,
* return a dart of from the vertex of the current level
*/
Dart vertexOrigin(Dart d) ;
// /**
// * Return the level of the vertex of d in the current level map
// */
// unsigned int vertexLevel(Dart d);
} ;
} // namespace Multiresolution
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/Multiresolution/Map3MR/map3MR_PM.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Container/attributeMultiVector.h"
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace MR
{
template <typename PFP>
Map3MR_PM<PFP>::Map3MR_PM(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position) : m_map(map), m_position(position)
{
}
template <typename PFP>
Map3MR_PM<PFP>::~Map3MR_PM()
{
if(m_selector)
delete m_selector ;
for(typename std::vector<Algo::Volume::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
delete (*it) ;
for(typename std::vector<Algo::Volume::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
delete (*it) ;
}
template <typename PFP>
void Map3MR_PM<PFP>::createPM(Algo::Volume::Decimation::SelectorType s, Algo::Volume::Decimation::ApproximatorType a)
{
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
std::vector<VertexAttribute< typename PFP::VEC3>* > pos_v ;
pos_v.push_back(&m_position) ;
switch(a)
{
case Algo::Volume::Decimation::A_QEM : {
m_approximators.push_back(new Algo::Volume::Decimation::Approximator_QEM<PFP>(m_map, pos_v)) ;
break ; }
case Algo::Volume::Decimation::A_MidEdge : {
m_approximators.push_back(new Algo::Volume::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v)) ;
break ; }
case Algo::Volume::Decimation::A_hHalfCollapse : {
Algo::Volume::Decimation::Predictor_HalfCollapse<PFP>* pred = new Algo::Volume::Decimation::Predictor_HalfCollapse<PFP>(m_map, m_position) ;
m_predictors.push_back(pred) ;
m_approximators.push_back(new Algo::Volume::Decimation::Approximator_HalfCollapse<PFP>(m_map, pos_v, pred)) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " creating selector.." << CGoGNflush ;
switch(s)
{
case Algo::Volume::Decimation::S_MapOrder : {
m_selector = new Algo::Volume::Decimation::EdgeSelector_MapOrder<PFP>(m_map, m_position, m_approximators) ;
break ; }
case Algo::Volume::Decimation::S_Random : {
m_selector = new Algo::Volume::Decimation::EdgeSelector_Random<PFP>(m_map, m_position, m_approximators) ;
break ; }
case Algo::Volume::Decimation::S_EdgeLength : {
m_selector = new Algo::Volume::Decimation::EdgeSelector_Length<PFP>(m_map, m_position, m_approximators) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
m_initOk = true ;
CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::Volume::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
{
if(! (*it)->init())
m_initOk = false ;
if((*it)->getApproximatedAttributeName() == "position")
m_positionApproximator = reinterpret_cast<Algo::Volume::Decimation::Approximator<PFP, VEC3>*>(*it) ;
}
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " initializing predictors.." << CGoGNflush ;
for(typename std::vector<Algo::Volume::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
if(! (*it)->init())
m_initOk = false ;
CGoGNout << "..done" << CGoGNendl ;
}
template <typename PFP>
void Map3MR_PM<PFP>::addNewLevel(unsigned int percentWantedVertices)
{
unsigned int nbVertices = m_map.template getNbOrbits<VERTEX>() ;
unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
unsigned int nbDeletedVertex=0;
unsigned int percentWantedPerLevel = 50;
//unsigned int nbWantedPerLevel = nbWantedVertices * percentWantedPerLevel / 100 ;
unsigned int nbWantedPerLevel = nbVertices * percentWantedPerLevel / 100 ;
CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ;
CGoGNout << "..done" << CGoGNendl ;
std::vector<Dart> edges;
edges.reserve(nbWantedPerLevel);
std::cout << "stops at : " << nbWantedPerLevel << std::endl;
DartMarkerStore me(m_map); //mark edges not to collapse
bool finished = false ;
Dart d ;
while(!finished)
{
if(!m_selector->nextEdge(d))
break ;
if(!me.isMarked(d))
{
//Mark le 1 voisinage
Dart dt = d;
do
{
Traversor3VE<typename PFP::MAP> tf(m_map, dt) ;
for(Dart it = tf.begin(); it != tf.end(); it = tf.next())
{
me.markOrbit<EDGE>(it);
me.markOrbit<EDGE>(m_map.phi1(it));
}
dt = m_map.phi1(dt);
}while(dt != d);
Traversor3VE<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())
{
me.markOrbit<EDGE>(it);
me.markOrbit<EDGE>(m_map.phi1(it));
}
++nbDeletedVertex ;
edges.push_back(d);
}
m_selector->updateWithoutCollapse();
if(nbDeletedVertex >= nbWantedPerLevel)
finished = true ;
}
std::cout << "nbDeletedVertices : " << nbDeletedVertex << std::endl;
if(!edges.empty())
{
//create the new level
m_map.addLevelFront();
m_map.setCurrentLevel(0);
AttributeContainer& attribs = m_map.getMRAttributeContainer();
AttributeMultiVector<unsigned int>* attribLevel = m_map.getMRLevelAttributeVector();
AttributeMultiVector<unsigned int>* attribDarts = m_map.getMRDartAttributeVector(0);
for(unsigned int i = attribs.begin(); i != attribs.end(); attribs.next(i))
{
if((*attribDarts)[i] == MRNULL)
++(*attribLevel)[i];
}
for(std::vector<Dart>::iterator it = edges.begin() ; it != edges.end() ; ++it)
{
collapseEdge(*it);
}
}
//m_map.printMR();
}
template <typename PFP>
void Map3MR_PM<PFP>::collapseEdge(Dart d)
{
//incremente le dartLevel des brins des faces a supprimer
m_map.incDartLevel(d);
m_map.incDartLevel(m_map.phi1(d));
m_map.incDartLevel(m_map.phi_1(d));
m_map.incDartLevel(m_map.phi2(d));
m_map.incDartLevel(m_map.phi_1(m_map.phi2(d)));
m_map.incDartLevel(m_map.phi1(m_map.phi2(d)));
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(m_map.phi1(d), 0);
m_map.duplicateDartAtOneLevel(m_map.phi_1(d), 0);
m_map.duplicateDartAtOneLevel(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);