Commit ce89d70a authored by Sylvain Thery's avatar Sylvain Thery

add Surface namespace in ProgressiveMesh

parent 03e6495a
......@@ -41,6 +41,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace PMesh
{
......@@ -126,6 +129,8 @@ private:
} //namespace PMesh
} // Surface
} //namespace Algo
} //namespace CGoGN
......
......@@ -30,13 +30,16 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace PMesh
{
template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh(
MAP& map, DartMarker& inactive,
Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a,
Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
) :
m_map(map), positionsTable(position), inactiveMarker(inactive), dartSelect(inactiveMarker)
......@@ -47,31 +50,31 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
pos_v.push_back(&positionsTable) ;
switch(a)
{
case Algo::Decimation::A_QEM : {
m_approximators.push_back(new Algo::Decimation::Approximator_QEM<PFP>(m_map, pos_v)) ;
case Algo::Surface::Decimation::A_QEM : {
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_QEM<PFP>(m_map, pos_v)) ;
break ; }
case Algo::Decimation::A_MidEdge : {
m_approximators.push_back(new Algo::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v)) ;
case Algo::Surface::Decimation::A_MidEdge : {
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v)) ;
break ; }
case Algo::Decimation::A_hHalfCollapse : {
Algo::Decimation::Predictor_HalfCollapse<PFP>* pred = new Algo::Decimation::Predictor_HalfCollapse<PFP>(m_map, positionsTable) ;
case Algo::Surface::Decimation::A_hHalfCollapse : {
Algo::Surface::Decimation::Predictor_HalfCollapse<PFP>* pred = new Algo::Surface::Decimation::Predictor_HalfCollapse<PFP>(m_map, positionsTable) ;
m_predictors.push_back(pred) ;
m_approximators.push_back(new Algo::Decimation::Approximator_HalfCollapse<PFP>(m_map, pos_v, pred)) ;
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_HalfCollapse<PFP>(m_map, pos_v, pred)) ;
break ; }
case Algo::Decimation::A_CornerCutting : {
Algo::Decimation::Predictor_CornerCutting<PFP>* pred = new Algo::Decimation::Predictor_CornerCutting<PFP>(m_map, positionsTable) ;
case Algo::Surface::Decimation::A_CornerCutting : {
Algo::Surface::Decimation::Predictor_CornerCutting<PFP>* pred = new Algo::Surface::Decimation::Predictor_CornerCutting<PFP>(m_map, positionsTable) ;
m_predictors.push_back(pred) ;
m_approximators.push_back(new Algo::Decimation::Approximator_CornerCutting<PFP>(m_map, pos_v, pred)) ;
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_CornerCutting<PFP>(m_map, pos_v, pred)) ;
break ; }
case Algo::Decimation::A_TangentPredict1 : {
Algo::Decimation::Predictor_TangentPredict1<PFP>* pred = new Algo::Decimation::Predictor_TangentPredict1<PFP>(m_map, positionsTable) ;
case Algo::Surface::Decimation::A_TangentPredict1 : {
Algo::Surface::Decimation::Predictor_TangentPredict1<PFP>* pred = new Algo::Surface::Decimation::Predictor_TangentPredict1<PFP>(m_map, positionsTable) ;
m_predictors.push_back(pred) ;
m_approximators.push_back(new Algo::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v, pred)) ;
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v, pred)) ;
break ; }
case Algo::Decimation::A_TangentPredict2 : {
Algo::Decimation::Predictor_TangentPredict2<PFP>* pred = new Algo::Decimation::Predictor_TangentPredict2<PFP>(m_map, positionsTable) ;
case Algo::Surface::Decimation::A_TangentPredict2 : {
Algo::Surface::Decimation::Predictor_TangentPredict2<PFP>* pred = new Algo::Surface::Decimation::Predictor_TangentPredict2<PFP>(m_map, positionsTable) ;
m_predictors.push_back(pred) ;
m_approximators.push_back(new Algo::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v, pred)) ;
m_approximators.push_back(new Algo::Surface::Decimation::Approximator_MidEdge<PFP>(m_map, pos_v, pred)) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
......@@ -79,23 +82,23 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
CGoGNout << " creating selector.." << CGoGNflush ;
switch(s)
{
case Algo::Decimation::S_MapOrder : {
m_selector = new Algo::Decimation::EdgeSelector_MapOrder<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_MapOrder : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
case Algo::Decimation::S_Random : {
m_selector = new Algo::Decimation::EdgeSelector_Random<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_Random : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Random<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
case Algo::Decimation::S_EdgeLength : {
m_selector = new Algo::Decimation::EdgeSelector_Length<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_EdgeLength : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Length<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
case Algo::Decimation::S_QEM : {
m_selector = new Algo::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_QEM : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
case Algo::Decimation::S_MinDetail : {
m_selector = new Algo::Decimation::EdgeSelector_MinDetail<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_MinDetail : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
case Algo::Decimation::S_Curvature : {
m_selector = new Algo::Decimation::EdgeSelector_Curvature<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
case Algo::Surface::Decimation::S_Curvature : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
......@@ -103,17 +106,17 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
m_initOk = true ;
CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
for(typename std::vector<Algo::Surface::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::Decimation::Approximator<PFP, VEC3, EDGE>*>(*it) ;
m_positionApproximator = reinterpret_cast<Algo::Surface::Decimation::Approximator<PFP, VEC3, EDGE>*>(*it) ;
}
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " initializing predictors.." << CGoGNflush ;
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
for(typename std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
if(! (*it)->init())
m_initOk = false ;
CGoGNout << "..done" << CGoGNendl ;
......@@ -135,9 +138,9 @@ ProgressiveMesh<PFP>::~ProgressiveMesh()
delete m_splits[i] ;
if(m_selector)
delete m_selector ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
for(typename std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
delete (*it) ;
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
for(typename std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
delete (*it) ;
if(quantizationInitialized)
delete q ;
......@@ -164,7 +167,7 @@ void ProgressiveMesh<PFP>::createPM(unsigned int percentWantedVertices)
VSplit<PFP>* vs = new VSplit<PFP>(m_map, d, dd2, d2) ; // create new VSplit node
m_splits.push_back(vs) ; // and store it
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
for(typename std::vector<Algo::Surface::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) ;
......@@ -181,7 +184,7 @@ void ProgressiveMesh<PFP>::createPM(unsigned int percentWantedVertices)
vs->setApproxE1(newE1) ;
vs->setApproxE2(newE2) ;
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
for(typename std::vector<Algo::Surface::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
......@@ -270,7 +273,7 @@ void ProgressiveMesh<PFP>::refine()
if(!m_predictors.empty())
{
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator pit = m_predictors.begin();
for(typename std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>::iterator pit = m_predictors.begin();
pit != m_predictors.end();
++pit)
{
......@@ -281,7 +284,7 @@ void ProgressiveMesh<PFP>::refine()
typename PFP::MATRIX33 invLocalFrame ;
if(m_localFrameDetailVectors)
{
typename PFP::MATRIX33 localFrame = Algo::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
typename PFP::MATRIX33 localFrame = Algo::Surface::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
localFrame.invert(invLocalFrame) ;
}
......@@ -296,8 +299,8 @@ void ProgressiveMesh<PFP>::refine()
if(!m_predictors.empty())
{
typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator pit ;
typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator ait ;
typename std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>::iterator pit ;
typename std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>::iterator ait ;
for(pit = m_predictors.begin(), ait = m_approximators.begin();
pit != m_predictors.end();
++pit, ++ait)
......@@ -307,7 +310,7 @@ void ProgressiveMesh<PFP>::refine()
detailTransform = &invLocalFrame ;
(*pit)->affectPredict(d) ;
if((*ait)->getType() == Algo::Decimation::A_hHalfCollapse)
if((*ait)->getType() == Algo::Surface::Decimation::A_hHalfCollapse)
{
(*ait)->addDetail(dd, m_detailAmount, true, detailTransform) ;
}
......@@ -378,7 +381,7 @@ void ProgressiveMesh<PFP>::localizeDetailVectors()
{
Dart d = m_splits[m_cur-1]->getEdge() ;
Dart dd2 = m_splits[m_cur-1]->getRightEdge() ;
typename PFP::MATRIX33 localFrame = Algo::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
typename PFP::MATRIX33 localFrame = Algo::Surface::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
VEC3 det = m_positionApproximator->getDetail(d) ;
det = localFrame * det ;
m_positionApproximator->setDetail(d, det) ;
......@@ -409,7 +412,7 @@ void ProgressiveMesh<PFP>::globalizeDetailVectors()
{
Dart d = m_splits[m_cur-1]->getEdge() ;
Dart dd2 = m_splits[m_cur-1]->getRightEdge() ;
typename PFP::MATRIX33 localFrame = Algo::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
typename PFP::MATRIX33 localFrame = Algo::Surface::Geometry::vertexLocalFrame<PFP>(m_map, dd2, positionsTable) ;
typename PFP::MATRIX33 invLocalFrame ;
localFrame.invert(invLocalFrame) ;
VEC3 det = m_positionApproximator->getDetail(d) ;
......@@ -573,7 +576,7 @@ void ProgressiveMesh<PFP>::calculCourbeDebitDistortion()
*/
} //namespace PMesh
} // Surface
} //namespace Algo
}
} //namespace CGoGN
......@@ -31,6 +31,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace PMesh
{
......@@ -98,9 +101,8 @@ public:
} ;
} //namespace PMesh
} // Surface
} //namespace Algo
} //namespace CGoGN
#endif
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