Commit bb0f0406 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

cleanup of all files in namespace ALGO::SURFACE::DECIMATION

parent b64fb9aa
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -41,21 +41,26 @@ namespace Decimation
enum ApproximatorType
{
// One approx per edge
// Geometry approximators
A_QEM = 0,
A_MidEdge = 1,
A_CornerCutting = 2,
A_TangentPredict1 = 3,
A_TangentPredict2 = 4,
A_NormalArea = 5,
// Geometry + color approximators
A_ColorNaive = 6,
A_ColorQEMext = 7,
A_GeomColorOpt = 8,
A_Lightfield = 9,
// note: the following "h" prefix means that half-edges are prioritized instead of edges.
A_hHalfCollapse = 10,
A_hQEM = 11,
A_hLightfieldHalf = 12,
A_MidEdgeLFopt = 13
// One approx per half-edge
// Generic (considers all provided attributes) approximator
A_hHalfCollapse = 9,
// Geometry approximator
A_hQEM = 10,
A_OTHER // for extensions use this type
} ;
template <typename PFP>
......@@ -147,16 +152,6 @@ public:
return m_attrV[index]->name() ;
}
// std::vector<std::string> getApproximatedAttributeNames() const
// {
// std::vector<std::string> names ;
// names.resize(m_attrV.size()) ;
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// names[i] = m_attrV[i]->name() ;
//
// return names ;
// }
unsigned int getNbApproximated() const
{
return m_attrV.size() ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -160,7 +160,7 @@ public:
} //namespace Decimation
}
} // namespace Surface
} //namespace Algo
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -76,6 +76,7 @@ int decimate(
* \param s the selector
* \param a a vector containing the approximators
* \param nbWantedVertices the aimed amount of vertices after decimation
* \param recomputePriorityList if false and a priority list exists, it is not recomputed
* \param edgeErrors will (if not null) contain the edge errors computed by the approximator/selector (default NULL)
* \param callback_wrapper a callback function for progress monitoring (default NULL)
* \param callback_object the object to call the callback on (default NULL)
......@@ -88,6 +89,7 @@ int decimate(
EdgeSelector<PFP>* s,
std::vector<ApproximatorGen<PFP>*>& a,
unsigned int nbWantedVertices,
bool recomputePriorityList = true,
EdgeAttribute<typename PFP::REAL> *edgeErrors = NULL,
void (*callback_wrapper)(void*, const void*) = NULL, void *callback_object = NULL
) ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -43,7 +43,7 @@ int decimate(
)
{
assert(attribs.size() >= 1 || !"Decimate: not enough attribs provided") ;
assert(attribs[0]->name() == "position" || !"Decimate: first attribute is not position") ;
assert(attribs[0]->name() == "position" || !"Decimate: first attribute should always be the position") ;
VertexAttribute<typename PFP::VEC3> position = *(attribs[0]) ;
std::vector<ApproximatorGen<PFP>*> approximators ;
......@@ -106,69 +106,6 @@ int decimate(
// pos
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, attribs)) ;
break ;
/*case A_hLightfieldHalf:
{
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[3] ;
// pos
v_approx[0].push_back(attribs[0]) ;
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_approx[0])) ;
// frame
assert(attribs.size() >= 4 || !"Decimate: A_hLightfieldHalf --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < 3 ; ++i)
v_approx[1].push_back(attribs[i+1]) ;
approximators.push_back(new Approximator_FrameInterpolationHalfEdge<PFP>(map, v_approx[1])) ;
// hemifunction
assert(attribs.size() >= 5 || !"Decimate: A_hLightfieldHalf --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < attribs.size() - 4 ; ++i)
v_approx[2].push_back(attribs[i+4]) ;
approximators.push_back(new Approximator_HemiFuncCoefsHalfEdge<PFP>(map, v_approx[2])) ;
}
break ;
case A_Lightfield :
{
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[3] ;
// pos
v_approx[0].push_back(attribs[0]) ;
approximators.push_back(new Approximator_QEM<PFP>(map, v_approx[0])) ;
// frame
assert(attribs.size() >= 4 || !"Decimate: A_Lightfield --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < 3 ; ++i)
v_approx[1].push_back(attribs[i+1]) ;
approximators.push_back(new Approximator_FrameInterpolation<PFP>(map, v_approx[1])) ;
// hemifunction
assert(attribs.size() >= 5 || !"Decimate: A_Lightfield --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < attribs.size() - 4 ; ++i)
v_approx[2].push_back(attribs[i+4]) ;
approximators.push_back(new Approximator_HemiFuncCoefs<PFP>(map, v_approx[2])) ;
}
break ;
case A_MidEdgeLFopt :
{
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[3] ;
// pos
v_approx[0].push_back(attribs[0]) ;
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_approx[0])) ;
// frame
assert(attribs.size() >= 4 || !"Decimate: A_MidEdgeLFopt --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < 3 ; ++i)
v_approx[1].push_back(attribs[i+1]) ;
approximators.push_back(new Approximator_FrameInterpolation<PFP>(map, v_approx[1])) ;
// hemifunction
assert(attribs.size() >= 5 || !"Decimate: A_MidEdgeLFopt --> not enough attribs provided") ;
for (unsigned int i = 0 ; i < attribs.size() - 4 ; ++i)
v_approx[2].push_back(attribs[i+4]) ;
approximators.push_back(new Approximator_HemiFuncCoefs<PFP>(map, v_approx[2])) ;
}
break ;*/
}
switch(s)
......@@ -212,42 +149,12 @@ int decimate(
case S_hQEMml :
selector = new HalfEdgeSelector_QEMml<PFP>(map, position, approximators) ;
break ;
case S_hColorExperimental:
selector = new HalfEdgeSelector_ColorExperimental<PFP>(map, position, approximators) ;
break ;
case S_hColorGradient:
selector = new HalfEdgeSelector_ColorGradient<PFP>(map, position, approximators) ;
break ;
case S_GeomColOptGrad:
selector = new EdgeSelector_GeomColOptGradient<PFP>(map, position, approximators) ;
break ;
/*case S_Lightfield :
selector = new EdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_hLightfield :
selector = new HalfEdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_hLightfieldAvgColor :
selector = new HalfEdgeSelector_LightfieldAvgColor<PFP>(map, position, approximators) ;
break ;
case S_hLightfieldKCL :
selector = new HalfEdgeSelector_LightfieldKCL<PFP>(map, position, approximators) ;
break ;
case S_hLFexperimental:
selector = new HalfEdgeSelector_LFexperimental<PFP>(map, position, approximators) ;
break ;
case S_hLFgradient:
selector = new HalfEdgeSelector_LFgradient<PFP>(map, position, approximators) ;
break ;
case S_hColorPerFace:
selector = new HalfEdgeSelector_ColorPerFace<PFP>(map, position, approximators) ;
break ;
case S_hLFperFace:
selector = new HalfEdgeSelector_LFperFace<PFP>(map, position, approximators) ;
break ;
case S_LightfieldGradient:
selector = new EdgeSelector_LightfieldGradient<PFP>(map, position, approximators) ;
break ;*/
}
int status = decimate(map, selector, approximators, nbWantedVertices, edgeErrors, callback_wrapper, callback_object) ;
......@@ -267,19 +174,23 @@ int decimate(
typename PFP::MAP& map,
EdgeSelector<PFP>* selector, std::vector<ApproximatorGen<PFP>*>& approximators,
unsigned int nbWantedVertices,
EdgeAttribute<typename PFP::REAL> *edgeErrors = NULL,
void (*callback_wrapper)(void*, const void*) = NULL, void *callback_object = NULL
bool recomputePriorityList,
EdgeAttribute<typename PFP::REAL> *edgeErrors,
void (*callback_wrapper)(void*, const void*), void *callback_object
)
{
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
(*it)->init() ;
if(!selector->init())
return -1 ; // init failed
Dart d ;
if (recomputePriorityList || !selector->nextEdge(d))
{
if(!selector->init())
return -1 ; // init failed
}
unsigned int nbVertices = map.template getNbOrbits<VERTEX>() ;
bool finished = false ;
Dart d ;
while(!finished)
{
......
This diff is collapsed.
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -158,7 +158,6 @@ public:
typedef typename PFP::REAL REAL ;
protected:
// VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
EdgeAttribute<Geom::Matrix<3,3,REAL> > edgeMatrix ;
public:
......@@ -177,7 +176,7 @@ public:
} //namespace Decimation
}
} // namespace Surface
} //namespace Algo
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......@@ -380,9 +380,6 @@ bool Approximator_NormalArea<PFP>::init()
edgeMatrix = this->m_map.template getAttribute<Geom::Matrix<3,3,REAL>, EDGE>("NormalAreaMatrix") ;
assert(edgeMatrix.isValid());
// m_quadric = this->m_map.template getAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
// Does not require to be valid (if it is not, altenatives will be used).
if(this->m_predictor)
{
return false ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2013, IGG Team, ICube, 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 *
......
This diff is collapsed.
/*******************************************************************************
* 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 __LIGHTFIELD_APPROXIMATOR_H__
#define __LIGHTFIELD_APPROXIMATOR_H__
#include "Algo/Decimation/approximator.h"
#include "Topology/generic/mapBrowser.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Decimation
{
/************************************************************************************
* FULL CONTRACTION LF APPROXIMATORS *
************************************************************************************/
template <typename PFP>
class Approximator_FrameInterpolation : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
VertexAttribute<VEC3> m_position ;
EdgeAttribute<VEC3> m_approxposition ;
VertexAttribute<VEC3> *m_frameT ;
VertexAttribute<VEC3> *m_frameB ;
VertexAttribute<VEC3> *m_frameN ;
public:
Approximator_FrameInterpolation(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, attr, pred),
m_frameT(NULL),
m_frameB(NULL),
m_frameN(NULL)
{
if (this->m_attrV.size() < 3)
std::cerr << "Approximator_FrameInterpolation: not enough attributes provided (only " << this->m_attrV.size() << " instead of 3)" << std::endl ;
m_frameT = this->m_attrV[0] ;
m_frameB = this->m_attrV[1] ;
m_frameN = this->m_attrV[2] ;
}
~Approximator_FrameInterpolation()
{}
ApproximatorType getType() const
{
return A_Lightfield ;
}
bool init()
{
assert(m_frameT->isValid() || !"Approximator_FrameInterpolation: the first approximated attribute is not valid") ;
assert(m_frameB->isValid() || !"Approximator_FrameInterpolation: the second approximated attribute is not valid") ;
assert(m_frameN->isValid() || !"Approximator_FrameInterpolation: the third approximated attribute is not valid") ;
m_position = this->m_map.template getAttribute<VEC3, VERTEX>("position") ;
assert(m_position.isValid() || !"Approximator_FrameInterpolation::init: the position attribute is not valid") ;
m_approxposition = this->m_map.template getAttribute<VEC3, EDGE>("approx_position") ;
assert(m_approxposition.isValid() || !"Approximator_FrameInterpolation::init: the approx_position attribute is not valid") ;
return m_frameT->isValid() && m_frameB->isValid() && m_frameN->isValid() && m_position.isValid() && m_approxposition.isValid() ;
}
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_HemiFuncCoefs: public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
unsigned int m_nbCoefs ;
unsigned int m_HFtype ;
VertexAttribute<VEC3 > m_frameT ;
VertexAttribute<VEC3 > m_frameB ;
VertexAttribute<VEC3 > m_frameN ;
EdgeAttribute<VEC3 > m_newFrameT ;
EdgeAttribute<VEC3 > m_newFrameB ;
EdgeAttribute<VEC3 > m_newFrameN ;
std::vector<VertexAttribute<VEC3>* > m_coefs ;
EdgeAttribute<Utils::QuadricHF<REAL> > m_quadricHF ;
public:
Approximator_HemiFuncCoefs(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, attr, pred),
m_nbCoefs(0),
m_HFtype(0) // SH = 0
{
unsigned int i ;
for (i = 0 ; i < 200 ; ++i)
{
// check if number i is present
if ((this->m_attrV.size() <= i) || this->m_attrV[i]->name().find("coefs") == std::string::npos)
break ;
m_coefs.push_back(this->m_attrV[i]) ;
}
// check name of last valid
if (this->m_attrV[i-1]->name().find("PB") != std::string::npos)
m_HFtype = 1 ;
m_nbCoefs = i ;
// set quadric
m_quadricHF = this->m_map.template addAttribute<Utils::QuadricHF<REAL>, EDGE>("HFquadric") ;
}
~Approximator_HemiFuncCoefs()
{
this->m_map.removeAttribute(m_quadricHF) ;
}
ApproximatorType getType() const
{
return A_Lightfield ;
}
bool init() ;
void approximate(Dart d) ;
} ;
// TODO : merge Approximator_FrameInterpolationHalfEdge and FullEdge ? By using template ?
/************************************************************************************
* HALF EDGE CONTRACTION LF APPROXIMATORS *
************************************************************************************/
template <typename PFP>
class Approximator_FrameInterpolationHalfEdge : public Approximator<PFP, typename PFP::VEC3, DART>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
VertexAttribute<VEC3> m_position ;
DartAttribute<VEC3> m_approxposition ;
VertexAttribute<VEC3> *m_frameT ;
VertexAttribute<VEC3> *m_frameB ;
VertexAttribute<VEC3> *m_frameN ;
public:
Approximator_FrameInterpolationHalfEdge(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL):
Approximator<PFP, VEC3, DART>(m, attr, pred),
m_frameT(NULL),
m_frameB(NULL),
m_frameN(NULL)
{
if (this->m_attrV.size() < 3)
std::cerr << "Approximator_FrameInterpolation: not enough attributes provided (only " << this->m_attrV.size() << " instead of 3)" << std::endl ;
m_frameT = this->m_attrV[0] ;
m_frameB = this->m_attrV[1] ;
m_frameN = this->m_attrV[2] ;
}
~Approximator_FrameInterpolationHalfEdge()
{}
ApproximatorType getType() const
{
return A_hLightfieldHalf ;
}
bool init()
{
assert(m_frameT->isValid() || !"Approximator_FrameInterpolation: the first approximated attribute is not valid") ;
assert(m_frameB->isValid() || !"Approximator_FrameInterpolation: the second approximated attribute is not valid") ;
assert(m_frameN->isValid() || !"Approximator_FrameInterpolation: the third approximated attribute is not valid") ;
m_position = this->m_map.template getAttribute<VEC3, VERTEX>("position") ;
assert(m_position.isValid() || !"Approximator_FrameInterpolation::init: the position attribute is not valid") ;
m_approxposition = this->m_map.template getAttribute<VEC3, DART>("approx_position") ;
assert(m_approxposition.isValid() || !"Approximator_FrameInterpolation::init: the approx_position attribute is not valid") ;
return m_frameT->isValid() && m_frameB->isValid() && m_frameN->isValid() && m_position.isValid() && m_approxposition.isValid() ;
}
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_HemiFuncCoefsHalfEdge: public Approximator<PFP, typename PFP::VEC3, DART>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
unsigned int m_nbCoefs ;
unsigned int m_HFtype ;
VertexAttribute<VEC3 > m_frameT ;
VertexAttribute<VEC3 > m_frameB ;
VertexAttribute<VEC3 > m_frameN ;
DartAttribute<VEC3 > m_newFrameT ;
DartAttribute<VEC3 > m_newFrameB ;
DartAttribute<VEC3 > m_newFrameN ;
std::vector<VertexAttribute<VEC3>* > m_coefs ;
DartAttribute<Utils::QuadricHF<REAL> > m_quadricHF ;
public:
Approximator_HemiFuncCoefsHalfEdge(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, DART>(m, attr, pred),
m_nbCoefs(0),
m_HFtype(0) // SH = 0
{
unsigned int i ;
for (i = 0 ; i < 200 ; ++i)
{
// check if number i is present
if ((this->m_attrV.size() <= i) || this->m_attrV[i]->name().find("coefs") == std::string::npos)
break ;
m_coefs.push_back(this->m_attrV[i]) ;
}
// check name of last valid
if (this->m_attrV[i-1]->name().find("PB") != std::string::npos)
m_HFtype = 1 ;
m_nbCoefs = i ;
// set quadric
m_quadricHF = this->m_map.template addAttribute<Utils::QuadricHF<REAL>, DART>("HFquadric") ;
}
~Approximator_HemiFuncCoefsHalfEdge()
{
this->m_map.removeAttribute(m_quadricHF) ;
}
ApproximatorType getType() const
{
return A_hLightfieldHalf ;
}
bool init() ;
void approximate(Dart d) ;
} ;
} //namespace Decimation
}