Commit 60bae45d authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Add functionalities to decimation :

 - multiple approximators
 - multiple attributes per approximator
parent 0372a0c8
...@@ -134,7 +134,7 @@ IF(WIN32) ...@@ -134,7 +134,7 @@ IF(WIN32)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE) # set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32) ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fpic")
add_subdirectory(Release) add_subdirectory(Release)
add_subdirectory(Debug) add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps) add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
...@@ -70,8 +70,9 @@ public: ...@@ -70,8 +70,9 @@ public:
virtual ~ApproximatorGen() virtual ~ApproximatorGen()
{} {}
virtual const std::string& getApproximatedAttributeName(unsigned int index = 0) const = 0 ; virtual const std::string& getApproximatedAttributeName(unsigned int index = 0) const = 0 ;
virtual std::vector<std::string> getApproximatedAttributeNames() const = 0 ; // virtual std::vector<std::string> getApproximatedAttributeNames() const = 0 ;
virtual ApproximatorType getType() const = 0 ; virtual ApproximatorType getType() const = 0 ;
virtual unsigned int getNbApproximated() const = 0 ;
virtual bool init() = 0 ; virtual bool init() = 0 ;
virtual void approximate(Dart d) = 0 ; virtual void approximate(Dart d) = 0 ;
virtual void saveApprox(Dart d) = 0 ; virtual void saveApprox(Dart d) = 0 ;
...@@ -101,13 +102,14 @@ public: ...@@ -101,13 +102,14 @@ public:
Approximator(MAP& m, std::vector<VertexAttribute<T>* > va, Predictor<PFP, T> * predictor) : Approximator(MAP& m, std::vector<VertexAttribute<T>* > va, Predictor<PFP, T> * predictor) :
ApproximatorGen<PFP>(m), m_predictor(predictor), m_attrV(va) ApproximatorGen<PFP>(m), m_predictor(predictor), m_attrV(va)
{ {
assert(m_attrV.size() > 0 || !"Approximator: no attributes provided") ; const unsigned int& size = m_attrV.size() ;
assert(size > 0 || !"Approximator: no attributes provided") ;
m_approx.resize(m_attrV.size()) ; m_approx.resize(size) ;
m_detail.resize(m_attrV.size()) ; m_detail.resize(size) ;
m_app.resize(m_attrV.size()) ; m_app.resize(size) ;
for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) for (unsigned int i = 0 ; i < size ; ++i)
{ {
if (!m_attrV[i]->isValid()) if (!m_attrV[i]->isValid())
std::cerr << "Approximator Warning: attribute number " << i << " is not valid" << std::endl ; std::cerr << "Approximator Warning: attribute number " << i << " is not valid" << std::endl ;
...@@ -129,6 +131,7 @@ public: ...@@ -129,6 +131,7 @@ public:
{ {
for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
{ {
std::cout << "delete " << m_approx[i].name() << std::endl ;
this->m_map.template removeAttribute(m_approx[i]) ; this->m_map.template removeAttribute(m_approx[i]) ;
if(m_predictor) if(m_predictor)
this->m_map.template removeAttribute(m_detail[i]) ; this->m_map.template removeAttribute(m_detail[i]) ;
...@@ -140,14 +143,19 @@ public: ...@@ -140,14 +143,19 @@ public:
return m_attrV[index]->name() ; return m_attrV[index]->name() ;
} }
std::vector<std::string> getApproximatedAttributeNames() const // std::vector<std::string> getApproximatedAttributeNames() const
{ // {
std::vector<std::string> names ; // std::vector<std::string> names ;
names.resize(m_attrV.size()) ; // names.resize(m_attrV.size()) ;
for (unsigned int i = 0 ; i < m_attrV.size() ; ++i) // for (unsigned int i = 0 ; i < m_attrV.size() ; ++i)
names[i] = m_attrV[i]->name() ; // names[i] = m_attrV[i]->name() ;
//
// return names ;
// }
return names ; unsigned int getNbApproximated() const
{
return m_attrV.size() ;
} }
void saveApprox(Dart d) void saveApprox(Dart d)
......
...@@ -41,74 +41,112 @@ void decimate( ...@@ -41,74 +41,112 @@ void decimate(
std::vector<ApproximatorGen<PFP>*> approximators ; std::vector<ApproximatorGen<PFP>*> approximators ;
EdgeSelector<PFP>* selector = NULL ; EdgeSelector<PFP>* selector = NULL ;
std::vector<VertexAttribute<typename PFP::VEC3>* > v_pos ; std::vector<VertexAttribute<typename PFP::VEC3>* > *v_approx = NULL ;
v_pos.push_back(&position) ;
switch(a) switch(a)
{ {
case A_QEM : case A_QEM :
approximators.push_back(new Approximator_QEM<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_QEM<PFP>(map, v_approx[0])) ;
break ; break ;
case A_MidEdge : case A_MidEdge :
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_approx[0])) ;
break ; break ;
case A_CornerCutting : case A_CornerCutting :
approximators.push_back(new Approximator_CornerCutting<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_CornerCutting<PFP>(map, v_approx[0])) ;
break ; break ;
case A_TangentPredict1 : case A_TangentPredict1 :
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_approx[0])) ;
break ; break ;
case A_TangentPredict2 : case A_TangentPredict2 :
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_MidEdge<PFP>(map, v_approx[0])) ;
break ; break ;
case A_hHalfCollapse : case A_hHalfCollapse :
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_approx[0])) ;
break ; break ;
case A_ColorNaive : case A_ColorNaive :
{ {
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[2] ;
// pos // pos
approximators.push_back(new Approximator_QEM<PFP>(map, v_pos)) ; v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_QEM<PFP>(map, v_approx[0])) ;
// col // col
std::vector<VertexAttribute<typename PFP::VEC3>* > v_col ; VertexAttribute<typename PFP::VEC3> *colors = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ; *colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
v_col.push_back(&colors) ; v_approx[1].push_back(colors) ;
approximators.push_back(new Approximator_ColorNaive<PFP>(map, v_col)) ; approximators.push_back(new Approximator_ColorNaive<PFP>(map, v_approx[1])) ;
} }
break ; break ;
case A_ColorQEMext : case A_ColorQEMext :
{ {
// pos+col v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
std::vector<VertexAttribute<typename PFP::VEC3>* > v_poscol ;
v_poscol.push_back(&position) ; // pos // pos + col
VertexAttribute<typename PFP::VEC3> colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ; v_approx[0].push_back(&position) ; // pos
v_poscol.push_back(&colors) ; // col VertexAttribute<typename PFP::VEC3> *colors = new VertexAttribute<typename PFP::VEC3>() ;
approximators.push_back(new Approximator_ColorQEMext<PFP>(map, v_poscol)) ; *colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
v_approx[0].push_back(colors) ; // col
approximators.push_back(new Approximator_ColorQEMext<PFP>(map, v_approx[0])) ;
} }
break; break;
case A_hQEM : case A_hQEM :
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, v_pos)) ; v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
// pos
v_approx[0].push_back(&position) ;
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, v_approx[0])) ;
break ; break ;
case A_hLightfieldHalf : case A_hLightfieldHalf :
{ {
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
// pos // pos
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_pos)) ; v_approx[0].push_back(&position) ;
// frame // frame
std::vector<VertexAttribute<typename PFP::VEC3>* > v_frame ; VertexAttribute<typename PFP::VEC3> *FT = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> FT = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameT") ; VertexAttribute<typename PFP::VEC3> *FB = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> FB = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameB") ; VertexAttribute<typename PFP::VEC3> *FN = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> FN = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameN") ; *FT = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameT") ;
v_frame.push_back(&FT) ; *FB = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameB") ;
v_frame.push_back(&FB) ; *FN = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameN") ;
v_frame.push_back(&FN) ; v_approx[0].push_back(FT) ;
approximators.push_back(new Approximator_FrameHalf<PFP>(map, v_frame)) ; v_approx[0].push_back(FB) ;
v_approx[0].push_back(FN) ;
// TODO
// // function coefs // function coefs
// std::vector<VertexAttribute<typename PFP::VEC3>* > v_coefs ; unsigned int k = 0 ;
// VertexAttribute<typename PFP::VEC3> coefs = map.template getAttribute<typename PFP::VEC3, VERTEX>("SLFcoefs_0") ; do
// v_frame.push_back(&coefs) ; {
// approximators.push_back(new Approximator_LFcoefs<PFP>(map, v_coefs)) ; std::stringstream s ; s << "PBcoefs" << k ;
VertexAttribute<typename PFP::VEC3> *attr = new VertexAttribute<typename PFP::VEC3>() ;
*attr = map.template getAttribute<typename PFP::VEC3, VERTEX>(s.str()) ;
v_approx[0].push_back(attr) ;
} while(v_approx[0][4 + k++]->isValid()) ;
v_approx[0].pop_back() ; --k ;
// const bool& sh = v_all.size() < 5 ; // sh or pb
do
{
std::stringstream s ; s << "SHcoefs" << k ;
VertexAttribute<typename PFP::VEC3> *attr = new VertexAttribute<typename PFP::VEC3>() ;
*attr = map.template getAttribute<typename PFP::VEC3, VERTEX>(s.str()) ;
v_approx[0].push_back(attr) ;
} while(v_approx[0][4 + k++]->isValid()) ;
v_approx[0].pop_back() ;
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_approx[0])) ;
} }
break ; break ;
/*case A_LightfieldHalf: /*case A_LightfieldHalf:
...@@ -230,7 +268,17 @@ void decimate( ...@@ -230,7 +268,17 @@ void decimate(
(*it)->init() ; (*it)->init() ;
if(!selector->init()) if(!selector->init())
{
delete selector ;
delete[] v_approx ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
delete (*it) ;
return ; return ;
}
unsigned int nbVertices = map.template getNbOrbits<VERTEX>() ; unsigned int nbVertices = map.template getNbOrbits<VERTEX>() ;
bool finished = false ; bool finished = false ;
...@@ -274,6 +322,9 @@ void decimate( ...@@ -274,6 +322,9 @@ void decimate(
} }
delete selector ; delete selector ;
delete[] v_approx ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it) for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
delete (*it) ; delete (*it) ;
} }
......
...@@ -460,14 +460,19 @@ private: ...@@ -460,14 +460,19 @@ private:
typedef NoMathIOAttribute<QEMextColorEdgeInfo> EdgeInfo ; typedef NoMathIOAttribute<QEMextColorEdgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ; EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<VEC3> m_color ;
VertexAttribute<QuadricNd<REAL,6> > m_quadric ; VertexAttribute<QuadricNd<REAL,6> > m_quadric ;
VertexAttribute<VEC3> m_pos, m_color ;
//VertexAttribute<VEC3> *m_HF ;
int m_approxindex_pos, m_attrindex_pos ;
int m_approxindex_color, m_attrindex_color ;
// Approximator<PFP, typename PFP::VEC3>* m_poscolApproximator ;
std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
std::multimap<float,Dart> edges ; std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ; typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_poscolApproximator ;
void initEdgeInfo(Dart d) ; void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ; void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d,EdgeInfo& einfo) ; void computeEdgeInfo(Dart d,EdgeInfo& einfo) ;
...@@ -476,13 +481,14 @@ private: ...@@ -476,13 +481,14 @@ private:
public: public:
EdgeSelector_QEMextColor(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) : EdgeSelector_QEMextColor(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select), EdgeSelector<PFP>(m, pos, approx, select),
m_poscolApproximator(NULL) // m_poscolApproximator(NULL),
m_approxindex_pos(-1),
m_attrindex_pos(-1),
m_approxindex_color(-1),
m_attrindex_color(-1)
{ {
edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ; edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
m_quadric = m.template addAttribute<QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ; m_quadric = m.template addAttribute<QuadricNd<REAL,6>, VERTEX>("QEMext-quadric") ;
m_color = m.template getAttribute<VEC3, VERTEX>("color") ;
assert(m_color.isValid() || !"EdgeSelector_ColorNaive: Color atrribute to select is not valid") ;
} }
~EdgeSelector_QEMextColor() ~EdgeSelector_QEMextColor()
{ {
......
...@@ -1351,25 +1351,42 @@ bool EdgeSelector_QEMextColor<PFP>::init() ...@@ -1351,25 +1351,42 @@ bool EdgeSelector_QEMextColor<PFP>::init()
MAP& m = this->m_map ; MAP& m = this->m_map ;
// Verify availability of required approximators // Verify availability of required approximators
bool ok = false ; unsigned int ok = 0 ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin(); for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
it != this->m_approximators.end();
++it)
{ {
// constraint : 2 approximators in specific order bool saved = false ;
if((*it)->getApproximatedAttributeName(0) == "position" && (*it)->getApproximatedAttributeName(1) == "color") for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
{ {
m_poscolApproximator = reinterpret_cast<Approximator<PFP, VEC3>* >(*it) ; // pos + col // constraint : 2 approximators in specific order
// check incompatibilities if(ok == 0 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "position")
assert(m_poscolApproximator->getType() != A_hQEM || !"Approximator(hQEM) and selector (ColorNaive) are not compatible") ; {
assert(m_poscolApproximator->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (ColorNaive) are not compatible") ; ++ok ;
assert(m_poscolApproximator->getType() != A_hLightfieldHalf || !"Approximator(hLightfieldHalf) and selector (ColorNaive) are not compatible") ; m_approxindex_pos = approxindex ;
m_attrindex_pos = attrindex ;
ok = true ; m_pos = this->m_position ;
if (!saved)
{
m_approx.push_back(reinterpret_cast<Approximator<PFP, VEC3>* >(this->m_approximators[approxindex])) ;
saved = true ;
}
}
else if(ok == 1 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "color")
{
++ok ;
m_approxindex_color = approxindex ;
m_attrindex_color = attrindex ;
m_color = m.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
assert(m_color.isValid() || !"EdgeSelector_QEMextColor: color attribute is not valid") ;
if (!saved)
{
m_approx.push_back(reinterpret_cast<Approximator<PFP, VEC3>* >(this->m_approximators[approxindex])) ;
saved = true ;
}
}
} }
} }
if(!ok) if(ok != 2)
return false ; return false ;
TraversorV<MAP> travV(m); TraversorV<MAP> travV(m);
...@@ -1585,9 +1602,20 @@ void EdgeSelector_QEMextColor<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo) ...@@ -1585,9 +1602,20 @@ void EdgeSelector_QEMextColor<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
quad += m_quadric[d] ; // compute the sum of the quad += m_quadric[d] ; // compute the sum of the
quad += m_quadric[dd] ; // two vertices quadrics quad += m_quadric[dd] ; // two vertices quadrics
this->m_poscolApproximator->approximate(d) ; // sets newPos // compute all approximated attributes
VEC3 newPos = this->m_poscolApproximator->getApprox(d,0) ; // get newPos for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin() ;
VEC3 newCol = this->m_poscolApproximator->getApprox(d,1) ; // get newCol it != this->m_approximators.end() ;
++it)
{
(*it)->approximate(d) ;
}
// get pos
const VEC3& newPos = this->m_approx[m_approxindex_pos]->getApprox(d,m_attrindex_pos) ; // get newPos
// get col
const VEC3& newCol = this->m_approx[m_approxindex_color]->getApprox(d,m_attrindex_color) ; // get newPos
// compute error
VEC6 newEmb ; VEC6 newEmb ;
for (unsigned int i = 0 ; i < 3 ; ++i) for (unsigned int i = 0 ; i < 3 ; ++i)
{ {
......
...@@ -246,7 +246,8 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d) ...@@ -246,7 +246,8 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
{ {
MAP& m = this->m_map ; MAP& m = this->m_map ;
this->m_approx[0][d] = this->m_attrV[0]->operator[](d) ; for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i)
this->m_approx[i][d] = this->m_attrV[i]->operator[](d) ;
if(this->m_predictor) if(this->m_predictor)
{ {
...@@ -259,11 +260,17 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d) ...@@ -259,11 +260,17 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
// temporary edge collapse // temporary edge collapse
m.extractTrianglePair(d) ; m.extractTrianglePair(d) ;
unsigned int newV = m.template embedNewCell<VERTEX>(d2) ; unsigned int newV = m.template embedNewCell<VERTEX>(d2) ;
this->m_attrV[0]->operator[](newV) = this->m_approx[0][d] ; for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i)
{
this->m_attrV[i]->operator[](newV) = this->m_approx[i][d] ;
}
// compute the detail vector // compute the detail vector
this->m_predictor->predict(d2, dd2) ; this->m_predictor->predict(d2, dd2) ;
this->m_detail[0][d] = v2 - this->m_predictor->getPredict(1) ; for (unsigned int i = 0 ; i < this->m_attrV.size() ; ++i)
{
this->m_detail[i][d] = v2 - this->m_predictor->getPredict(1) ;
}
// vertex split to reset the initial connectivity and embeddings // vertex split to reset the initial connectivity and embeddings
m.insertTrianglePair(d, d2, dd2) ; m.insertTrianglePair(d, d2, dd2) ;
......
...@@ -110,15 +110,19 @@ private: ...@@ -110,15 +110,19 @@ private:
typedef NoMathIOAttribute<QEMhalfEdgeInfo> HalfEdgeInfo ; typedef NoMathIOAttribute<QEMhalfEdgeInfo> HalfEdgeInfo ;
DartAttribute<HalfEdgeInfo> halfEdgeInfo ; DartAttribute<HalfEdgeInfo> halfEdgeInfo ;
VertexAttribute<VEC3> m_frameT, m_frameB, m_frameN ;
VertexAttribute<Quadric<REAL> > m_quadric ; VertexAttribute<VEC3> m_pos, m_frameT, m_frameB, m_frameN ;
//VertexAttribute<VEC3> *m_HF ;
int m_approxindex_pos, m_attrindex_pos ;
int m_approxindex_FN, m_attrindex_FN ;
VertexAttribute<Quadric<REAL> > m_quadricGeom ;
VertexAttribute<QuadricHF<REAL> > m_quadricHF ;
std::multimap<float,Dart> halfEdges ; std::multimap<float,Dart> halfEdges ;
typename std::multimap<float,Dart>::iterator cur ; typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ; std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
Approximator<PFP, typename PFP::VEC3>* m_frameApproximator ;
// Approximator<PFP, typename PFP::VEC3>* m_lfcoefsApproximator ;
void initHalfEdgeInfo(Dart d) ; void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ; void updateHalfEdgeInfo(Dart d, bool recompute) ;
...@@ -128,23 +132,27 @@ private: ...@@ -128,23 +132,27 @@ private:
public: public:
HalfEdgeSelector_Lightfield(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) : HalfEdgeSelector_Lightfield(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select), EdgeSelector<PFP>(m, pos, approx, select),
m_positionApproximator(NULL), // m_positionApproximator(NULL),
m_frameApproximator(NULL) // m_frameApproximator(NULL),
// m_hfcoefsApproximator(NULL),
// m_pos(NULL),
// m_frameB(NULL),
// m_frameN(NULL),
// m_frameT(NULL),
m_approxindex_pos(-1),
m_attrindex_pos(-1),
m_approxindex_FN(-1),
m_attrindex_FN(-1)
{ {
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ; halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ;
m_quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ; m_quadricGeom = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
m_quadricHF = m.template addAttribute<QuadricHF<REAL>, VERTEX>("HFquadric") ;
m_frameT = m.template getAttribute<VEC3, VERTEX>("frameT") ;
m_frameB = m.template getAttribute<VEC3, VERTEX>("frameB") ;
m_frameN = m.template getAttribute<VEC3, VERTEX>("frameN") ;
assert(m_frameT.isValid() || !"HalfEdgeSelector_Lightfield: frameT atrribute to select is not valid") ;
assert(m_frameB.isValid() || !"HalfEdgeSelector_Lightfield: frameT atrribute to select is not valid") ;
assert(m_frameN.isValid() || !"HalfEdgeSelector_Lightfield: frameT atrribute to select is not valid") ;
} }
~HalfEdgeSelector_Lightfield() ~HalfEdgeSelector_Lightfield()
{ {
this->m_map.removeAttribute(halfEdgeInfo) ; this->m_map.removeAttribute(halfEdgeInfo) ;
this->m_map.removeAttribute(m_quadric) ; this->m_map.removeAttribute(m_quadricGeom) ;
this->m_map.removeAttribute(m_quadricHF) ;
} }
SelectorType getType() { return S_hLightfield ; } SelectorType getType() { return S_hLightfield ; }
bool init() ; bool init() ;
......
...@@ -287,29 +287,68 @@ bool HalfEdgeSelector_Lightfield<PFP>::init() ...@@ -287,29 +287,68 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
MAP& m = this->m_map ; MAP& m = this->m_map ;
// Verify availability of required approximators // Verify availability of required approximators
char ok = 0 ; unsigned int ok = 0 ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin(); for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
it != this->m_approximators.end();
++it)
{ {
// constraint : 2 approximators in specific order bool saved = false ;