Commit d5158c60 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:~vanhoey/CGoGN

Conflicts:
	include/Geometry/vector_gen.h
	include/Geometry/vector_gen.hpp
parents 773d5647 256936a6
......@@ -371,7 +371,7 @@ void MyQT::cb_initGL()
m_render = new Algo::Render::GL2::MapRender();
m_render_topo = new Algo::Render::GL2::TopoRender() ;
m_ds = new Utils::Drawer();
m_ds = new Utils::Drawer() ;
// create VBO for position
m_positionVBO = new Utils::VBO();
......
......@@ -59,6 +59,10 @@ Dans Preferences -> Shaders Preferences, on peut désormais configurer certaines
- Installer et redémarrer
- Dans Preferences -> General -> Editors -> File Associations il est possible d'associer les CMakeLists.txt à ce logiciel d'édition
* Problème indexeur
Si l'indexeur plante avec comme message "Out of memory" (c'est la cas par défaut sur Juno lors de l'indexation totale de CGoGN),
relancer eclipse avec l'option "/opt/eclipse/eclipse -vmargs -Xms512m -Xmx1024M" avant de refaire une indexation globale.
=========================================================================================
ENGLISH VERSION
=========================================================================================
......@@ -122,3 +126,7 @@ In Preferences -> Shaders Preferences, you can now configure some options relate
- Install and restart
- In Preferences -> General -> Editors -> File Associations You can associate the CMakeLists.txt to editing software
* Indexer problem
If the indexer fails with an "Out of Memory" error (this is the case when indexing CGoGN fully on eclipse Juno for instance),
then relaunch eclipse using some options to use a bigger heap "/opt/eclipse/eclipse -vmargs -Xms512m -Xmx1024M" before indexing
CGoGN globally.
This diff is collapsed.
......@@ -48,8 +48,8 @@ enum ApproximatorType
A_Lightfield,
// note: the following "h" prefix means that half-edges are prioritized instead of edges.
A_hHalfCollapse,
A_hQEM
// A_hLightfieldHalf,
A_hQEM,
A_hLightfieldHalf
} ;
template <typename PFP>
......@@ -81,7 +81,8 @@ public:
virtual void addDetail(Dart d, double amount, bool sign, typename PFP::MATRIX33* detailTransform) = 0 ;
} ;
template <typename PFP, typename T>
template <typename PFP, typename T, unsigned int ORBIT>
class Approximator : public ApproximatorGen<PFP>
{
public:
......@@ -93,8 +94,8 @@ protected:
Predictor<PFP, T>* m_predictor ;
std::vector<VertexAttribute<T>* > m_attrV ; // vertex attributes to be approximated
std::vector<EdgeAttribute<T> > m_approx ; // attributes to store approximation result
std::vector<EdgeAttribute<T> > m_detail ; // attributes to store detail information for reconstruction
std::vector<AttributeHandler<T,ORBIT> > m_approx ; // attributes to store approximation result
std::vector<AttributeHandler<T,ORBIT> > m_detail ; // attributes to store detail information for reconstruction
std::vector<T> m_app ;
public:
......@@ -115,13 +116,13 @@ public:
std::stringstream aname ;
aname << "approx_" << m_attrV[i]->name() ;
m_approx[i] = this->m_map.template addAttribute<T, EDGE>(aname.str()) ;
m_approx[i] = this->m_map.template addAttribute<T, ORBIT>(aname.str()) ;
if(m_predictor) // if predictors are associated to the approximator
{ // create attributes to store the details needed for reconstruction
std::stringstream dname ;
dname << "detail_" << m_attrV[i]->name() ;
m_detail[i] = this->m_map.template addAttribute<T, EDGE>(dname.str()) ;
m_detail[i] = this->m_map.template addAttribute<T, ORBIT>(dname.str()) ;
}
}
}
......@@ -244,6 +245,169 @@ public:
}
} ;
//template <typename PFP, typename T>
//class ApproximatorEdge : public ApproximatorGen<PFP>
//{
//public:
// typedef typename PFP::MAP MAP ;
// typedef typename PFP::VEC3 VEC3 ;
// typedef typename PFP::REAL REAL ;
//
//protected:
// Predictor<PFP, T>* m_predictor ;
//
// std::vector<VertexAttribute<T>* > m_attrV ; // vertex attributes to be approximated
// std::vector<EdgeAttribute<T> > m_approx ; // attributes to store approximation result
// std::vector<EdgeAttribute<T> > m_detail ; // attributes to store detail information for reconstruction
// std::vector<T> m_app ;
//
//public:
// ApproximatorEdge(MAP& m, std::vector<VertexAttribute<T>* > va, Predictor<PFP, T> * predictor) :
// ApproximatorGen<PFP>(m), m_predictor(predictor), m_attrV(va)
// {
// const unsigned int& size = m_attrV.size() ;
// assert(size > 0 || !"ApproximatorEdge: no attributes provided") ;
//
// m_approx.resize(size) ;
// m_detail.resize(size) ;
// m_app.resize(size) ;
//
// for (unsigned int i = 0 ; i < size ; ++i)
// {
// if (!m_attrV[i]->isValid())
// std::cerr << "ApproximatorEdge Warning: attribute number " << i << " is not valid" << std::endl ;
//
// std::stringstream aname ;
// aname << "approx_" << m_attrV[i]->name() ;
// m_approx[i] = this->m_map.template addAttribute<T, EDGE>(aname.str()) ;
//
// if(m_predictor) // if predictors are associated to the approximator
// { // create attributes to store the details needed for reconstruction
// std::stringstream dname ;
// dname << "detail_" << m_attrV[i]->name() ;
// m_detail[i] = this->m_map.template addAttribute<T, EDGE>(dname.str()) ;
// }
// }
// }
//
// virtual ~ApproximatorEdge()
// {
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// {
// this->m_map.template removeAttribute(m_approx[i]) ;
// if(m_predictor)
// this->m_map.template removeAttribute(m_detail[i]) ;
// }
// }
//
// const std::string& getApproximatedAttributeName(unsigned int index = 0) const
// {
// 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() ;
// }
//
// void saveApprox(Dart d)
// {
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// m_app[i] = m_approx[i][d] ;
// }
//
// void affectApprox(Dart d)
// {
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// m_attrV[i]->operator[](d) = m_app[i] ;
// }
//
// const T& getApprox(Dart d, unsigned int index = 0) const
// {
// return m_approx[index][d] ;
// }
//
// std::vector<T> getAllApprox(Dart d) const
// {
// std::vector<T> res ;
// res.resize(m_attrV.size()) ;
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// res[i] = m_approx[i][d] ;
//
// return res ;
// }
//
// const Predictor<PFP, T>* getPredictor() const
// {
// return m_predictor ;
// }
//
// const T& getDetail(Dart d, unsigned int index = 0) const
// {
// assert(m_predictor || !"Trying to get detail on a non-predictive scheme") ;
// return m_detail[index][d] ;
// }
//
// std::vector<T> getAllDetail(Dart d) const
// {
// assert(m_predictor || !"Trying to get detail on a non-predictive scheme") ;
//
// std::vector<T> res ;
// res.resize(m_attrV.size()) ;
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// res[i] = m_detail[i][d] ;
// return res ;
// }
//
// void setDetail(Dart d, unsigned int index, T& val)
// {
// assert(m_predictor || !"Trying to set detail on a non-predictive scheme") ;
// m_detail[index][d] = val ;
// }
//
// void setDetail(Dart d, std::vector<T>& val)
// {
// assert(m_predictor || !"Trying to set detail on a non-predictive scheme") ;
//
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// m_detail[index][d] = val[i] ;
// }
//
//
//// // TODO works only for vector types !!
//// REAL detailMagnitude(Dart d)
//// {
//// assert(m_predictor || !"Trying to get detail magnitude on a non-predictive scheme") ;
//// return m_detail[d].norm2() ;
//// }
//
// void addDetail(Dart d, double amount, bool sign, typename PFP::MATRIX33* detailTransform)
// {
// assert(m_predictor || !"Trying to add detail on a non-predictive scheme") ;
//
// for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
// {
// T det = m_detail[i][d] ;
// if(detailTransform)
// det = (*detailTransform) * det ;
// det *= amount ;
// if(!sign)
// det *= REAL(-1) ;
// m_attrV[i]->operator[](d) += det ;
// }
// }
//} ;
} //namespace Decimation
} //namespace Algo
......
......@@ -38,7 +38,7 @@ namespace Decimation
{
template <typename PFP>
class Approximator_ColorNaive : public Approximator<PFP, typename PFP::VEC3>
class Approximator_ColorNaive : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
......@@ -53,7 +53,7 @@ protected:
public:
Approximator_ColorNaive(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, attr, pred)
Approximator<PFP, VEC3, EDGE>(m, attr, pred)
{
m_color = this->m_attrV[0] ;
}
......@@ -82,7 +82,7 @@ public:
} ;
template <typename PFP>
class Approximator_ColorQEMext : public Approximator<PFP, typename PFP::VEC3>
class Approximator_ColorQEMext : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
......@@ -91,13 +91,13 @@ public:
typedef Geom::Vector<6,REAL> VEC6 ;
protected:
VertexAttribute<QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<Utils::QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<VEC3> *m_position ;
VertexAttribute<VEC3> *m_color ;
public:
Approximator_ColorQEMext(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, attr, pred)
Approximator<PFP, VEC3, EDGE>(m, attr, pred)
{
assert(attr.size() > 1 || !"Approximator_ColorQEMext: there are not sufficient attributes provided") ;
......@@ -118,6 +118,45 @@ public:
void approximate(Dart d) ;
} ;
/*
template <typename PFP>
class Approximator_ColorQEMextHalfCollapse : public Approximator<PFP, typename PFP::VEC3>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
typedef Geom::Vector<6,REAL> VEC6 ;
protected:
VertexAttribute<Utils::QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<VEC3> *m_position ;
VertexAttribute<VEC3> *m_color ;
public:
Approximator_ColorQEMextHalfCollapse(MAP& m, std::vector<VertexAttribute<VEC3>* >& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, attr, pred)
{
assert(attr.size() > 1 || !"Approximator_ColorQEMext_HalfCollapse: there are not sufficient attributes provided") ;
m_position = this->m_attrV[0] ;
m_color = this->m_attrV[1] ;
}
~Approximator_ColorQEMextHalfCollapse()
{}
ApproximatorType getType() const
{
return A_ColorQEMextHalfCollapse ;
}
bool init() ;
void approximate(Dart d) ;
} ;
*/
} //namespace Decimation
} //namespace Algo
......
......@@ -56,7 +56,7 @@ void Approximator_ColorNaive<PFP>::approximate(Dart d)
template <typename PFP>
bool Approximator_ColorQEMext<PFP>::init()
{
m_quadric = this->m_map.template getAttribute<QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ;
m_quadric = this->m_map.template getAttribute<Utils::QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ;
// Does not require to be valid (if it is not, altenatives will be used).
if(this->m_predictor)
......@@ -75,7 +75,7 @@ void Approximator_ColorQEMext<PFP>::approximate(Dart d)
// get some darts
Dart dd = m.phi2(d) ;
QuadricNd<REAL,6> q1, q2 ;
Utils::QuadricNd<REAL,6> q1, q2 ;
if(!m_quadric.isValid()) // if the selector is not QEM, compute local error quadrics
{
// compute the error quadric associated to v1
......@@ -93,7 +93,7 @@ void Approximator_ColorQEMext<PFP>::approximate(Dart d)
p2[i+3] = this->m_attrV[1]->operator[](m.phi_1(it))[i] ;
}
QuadricNd<REAL,6> q(p0,p1,p2) ;
Utils::QuadricNd<REAL,6> q(p0,p1,p2) ;
q1 += q ;
it = m.phi2_1(it) ;
} while(it != d) ;
......@@ -113,7 +113,7 @@ void Approximator_ColorQEMext<PFP>::approximate(Dart d)
p2[i+3] = this->m_attrV[1]->operator[](m.phi_1(it))[i] ;
}
QuadricNd<REAL,6> q(p0,p1,p2) ;
Utils::QuadricNd<REAL,6> q(p0,p1,p2) ;
q2 += q ;
it = m.phi2_1(it) ;
} while(it != dd) ;
......@@ -124,7 +124,7 @@ void Approximator_ColorQEMext<PFP>::approximate(Dart d)
q2 = m_quadric[dd] ;
}
QuadricNd<REAL,6> quad ;
Utils::QuadricNd<REAL,6> quad ;
quad += q1 ; // compute the sum of the
quad += q2 ; // two vertices quadrics
......
......@@ -40,6 +40,20 @@ namespace Algo
namespace Decimation
{
/**
* Decimate the mesh through edge contraction
* by using a selector and approximator scheme.
*
* \param map the map to decimate
* \param s the SelectorType
* \param a the ApproximatorType
* \param position the vertex position embeddings
* \param nbWantedVertices the aimed amount of vertices after decimation
* \param selected the selector stipulating which darts are eligible for contraction
* \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)
*/
template <typename PFP>
void decimate(
typename PFP::MAP& map,
......@@ -48,6 +62,7 @@ void decimate(
std::vector<VertexAttribute<typename PFP::VEC3> *>& position,
unsigned int nbWantedVertices,
const FunctorSelect& selected = allDarts,
VertexAttribute<typename PFP::VEC3> *edgeErrors = NULL,
void (*callback_wrapper)(void*, const void*) = NULL, void *callback_object = NULL
) ;
......
......@@ -35,6 +35,7 @@ template <typename PFP>
void decimate(
typename PFP::MAP& map, SelectorType s, ApproximatorType a,
std::vector<VertexAttribute<typename PFP::VEC3>* >& attribs, unsigned int nbWantedVertices, const FunctorSelect& selected,
EdgeAttribute<typename PFP::REAL> *edgeErrors,
void (*callback_wrapper)(void*, const void*), void* callback_object
)
{
......@@ -92,27 +93,27 @@ void 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_LightfieldHalf --> 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_FrameHalf<PFP>(map, v_approx[1])) ;
//
// // hemifunction
// assert(attribs.size() >= 5 || !"Decimate: A_LightfieldHalf --> 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_LightfieldCoefsHalf<PFP>(map, v_approx[2])) ;
// }
// 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_QEMhalfEdge<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] ;
......@@ -165,12 +166,18 @@ void decimate(
case S_QEMextColor :
selector = new EdgeSelector_QEMextColor<PFP>(map, position, approximators, selected) ;
break ;
case S_hQEMextColor :
selector = new HalfEdgeSelector_QEMextColor<PFP>(map, position, approximators, selected) ;
break ;
case S_hQEMml :
selector = new HalfEdgeSelector_QEMml<PFP>(map, position, approximators, selected) ;
break ;
case S_Lightfield :
selector = new EdgeSelector_Lightfield<PFP>(map, position, approximators, selected) ;
break ;
case S_hLightfield :
selector = new HalfEdgeSelector_Lightfield<PFP>(map, position, approximators, selected) ;
break ;
}
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
......@@ -188,6 +195,8 @@ void decimate(
return ;
}
if (edgeErrors != NULL)
selector->getEdgeErrors(edgeErrors) ;
unsigned int nbVertices = map.template getNbOrbits<VERTEX>() ;
bool finished = false ;
......
......@@ -163,13 +163,13 @@ private:
typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<Quadric<REAL> > quadric ;
Quadric<REAL> tmpQ ;
VertexAttribute<Utils::Quadric<REAL> > quadric ;
Utils::Quadric<REAL> tmpQ ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
Approximator<PFP, typename PFP::VEC3, EDGE>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
......@@ -181,7 +181,7 @@ public:
m_positionApproximator(NULL)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
quadric = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
}
~EdgeSelector_QEM()
{
......@@ -215,12 +215,12 @@ private:
typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<Quadric<REAL> > quadric ;
VertexAttribute<Utils::Quadric<REAL> > quadric ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
Approximator<PFP, typename PFP::VEC3, EDGE>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
......@@ -233,7 +233,7 @@ public:
m_positionApproximator(NULL)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
quadric = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
}
~EdgeSelector_QEMml()
{
......@@ -281,7 +281,7 @@ private:
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, VEC3,EDGE>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
......@@ -369,7 +369,7 @@ private:
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
Approximator<PFP, typename PFP::VEC3, EDGE>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
......@@ -416,13 +416,13 @@ private:
typedef NoMathIOAttribute<ColorNaiveedgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<Quadric<REAL> > m_quadric ;
VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
VertexAttribute<VEC3> m_pos, m_color ;
int m_approxindex_pos, m_attrindex_pos ;
int m_approxindex_color, m_attrindex_color ;
std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
std::vector<Approximator<PFP, typename PFP::VEC3, EDGE>* > m_approx ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
......@@ -441,7 +441,7 @@ public:
m_attrindex_color(-1)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
m_quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
m_quadric = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
}
~EdgeSelector_ColorNaive()
{
......@@ -479,13 +479,13 @@ private:
typedef NoMathIOAttribute<QEMextColorEdgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<Utils::QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<VEC3> m_pos, m_color ;
int m_approxindex_pos, m_attrindex_pos ;
int m_approxindex_color, m_attrindex_color ;
std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
std::vector<Approximator<PFP, typename PFP::VEC3, EDGE>* > m_approx ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
......@@ -504,7 +504,7 @@ public:
m_attrindex_color(-1)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
m_quadric = m.template addAttribute<QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ;
m_quadric = m.template addAttribute<Utils::QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ;
}
~EdgeSelector_QEMextColor()
{
......@@ -538,20 +538,22 @@ private:
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "QEMextColorEdgeInfo" ; }
} QEMextColorEdgeInfo ;
typedef NoMathIOAttribute<QEMextColorEdgeInfo> EdgeInfo ;
} LightfieldEdgeInfo ;
typedef NoMathIOAttribute<LightfieldEdgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<VEC3> m_pos, m_frameT, m_frameB, m_frameN ;
//VertexAttribute<VEC3> *m_HF ;
std::vector<VertexAttribute<VEC3> > m_HF ;
int m_approxindex_pos, m_attrindex_pos ;
int m_approxindex_FN, m_attrindex_FN ;
std::vector<unsigned int> m_approxindex_HF, m_attrindex_HF ;
unsigned int m_K ;
VertexAttribute<Quadric<REAL> > m_quadricGeom ;
VertexAttribute<QuadricHF<REAL> > m_quadricHF ;
VertexAttribute<Utils::Quadric<REAL> > m_quadricGeom ;
EdgeAttribute<Utils::QuadricHF<REAL> > m_quadricHF ;
std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
std::vector<Approximator<PFP, typename PFP::VEC3, EDGE>* > m_approx ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
......@@ -567,17 +569,17 @@ public:
m_approxindex_pos(-1),
m_attrindex_pos(-1),
m_approxindex_FN(-1),
m_attrindex_FN(-1)
m_attrindex_FN(-1),
m_K(0)
{
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
m_quadricGeom = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
m_quadricHF = m.template addAttribute<QuadricHF<REAL>, VERTEX>("HFquadric") ;
m_quadricGeom = m.template addAttribute<Utils::Quadric<REAL>, VERTEX>("QEMquadric") ;
m_quadricHF = m.template getAttribute<Utils::QuadricHF<REAL>, EDGE>("HFquadric") ;
}
~EdgeSelector_Lightfield()
{
this->m_map.removeAttribute(edgeInfo) ;
this->m_map.removeAttribute(m_quadricGeom) ;
this->m_map.removeAttribute(m_quadricHF) ;
}
SelectorType getType() { return S_Lightfield ; }
bool init() ;
......@@ -586,6 +588,25 @@ public:
void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse() { }
void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
{
assert(errors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ;
if (!errors->isValid())
std::cerr << "EdgeSelector::setColorMap requires valid edgeattribute argument" << std::endl ;
assert(edgeInfo.isValid()) ;
TraversorE<typename PFP::MAP> travE(this->m_map) ;
for(Dart d = travE.begin() ; d != travE.end() ; d = travE.next())
{
if (edgeInfo[d].valid)
{
(*errors)[d] = edgeInfo[d].it->first ;
}
else
(*errors)[d] = -1 ;
}
}
} ;
} // namespace Decimation
......
This diff is collapsed.
......@@ -37,7 +37,7 @@ namespace Decimation
{
template <typename PFP>
class Approximator_QEM : public Approximator<PFP, typename PFP::VEC3>
class Approximator_QEM : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
......@@ -45,11 +45,11 @@ public:
typedef typename PFP::REAL REAL ;
protected:
VertexAttribute<Quadric<REAL> > m_quadric ;
VertexAttribute<Utils::Quadric<REAL> > m_quadric ;
public:
Approximator_QEM(MAP& m, std::vector<VertexAttribute<VEC3>* > pos, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, pos, pred)
Approximator<PFP, VEC3, EDGE>(m, pos, pred)
{
assert(pos.size() > 0 || !"Approximator_QEM: attribute vector is empty") ;
}
......@@ -61,7 +61,7 @@ public:
} ;