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)
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)
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fpic")
add_subdirectory(Release)
add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
......@@ -70,8 +70,9 @@ public:
virtual ~ApproximatorGen()
{}
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 unsigned int getNbApproximated() const = 0 ;
virtual bool init() = 0 ;
virtual void approximate(Dart d) = 0 ;
virtual void saveApprox(Dart d) = 0 ;
......@@ -101,13 +102,14 @@ public:
Approximator(MAP& m, std::vector<VertexAttribute<T>* > va, Predictor<PFP, T> * predictor) :
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_detail.resize(m_attrV.size()) ;
m_app.resize(m_attrV.size()) ;
m_approx.resize(size) ;
m_detail.resize(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())
std::cerr << "Approximator Warning: attribute number " << i << " is not valid" << std::endl ;
......@@ -129,6 +131,7 @@ public:
{
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]) ;
if(m_predictor)
this->m_map.template removeAttribute(m_detail[i]) ;
......@@ -140,14 +143,19 @@ 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() ;
// 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 ;
// }
return names ;
unsigned int getNbApproximated() const
{
return m_attrV.size() ;
}
void saveApprox(Dart d)
......
......@@ -41,74 +41,112 @@ void decimate(
std::vector<ApproximatorGen<PFP>*> approximators ;
EdgeSelector<PFP>* selector = NULL ;
std::vector<VertexAttribute<typename PFP::VEC3>* > v_pos ;
v_pos.push_back(&position) ;
std::vector<VertexAttribute<typename PFP::VEC3>* > *v_approx = NULL ;
switch(a)
{
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 ;
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 ;
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 ;
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 ;
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 ;
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 ;
case A_ColorNaive :
{
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[2] ;
// 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
std::vector<VertexAttribute<typename PFP::VEC3>* > v_col ;
VertexAttribute<typename PFP::VEC3> colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
v_col.push_back(&colors) ;
approximators.push_back(new Approximator_ColorNaive<PFP>(map, v_col)) ;
VertexAttribute<typename PFP::VEC3> *colors = new VertexAttribute<typename PFP::VEC3>() ;
*colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
v_approx[1].push_back(colors) ;
approximators.push_back(new Approximator_ColorNaive<PFP>(map, v_approx[1])) ;
}
break ;
case A_ColorQEMext :
{
// pos+col
std::vector<VertexAttribute<typename PFP::VEC3>* > v_poscol ;
v_poscol.push_back(&position) ; // pos
VertexAttribute<typename PFP::VEC3> colors = map.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
v_poscol.push_back(&colors) ; // col
approximators.push_back(new Approximator_ColorQEMext<PFP>(map, v_poscol)) ;
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
// pos + col
v_approx[0].push_back(&position) ; // pos
VertexAttribute<typename PFP::VEC3> *colors = new VertexAttribute<typename PFP::VEC3>() ;
*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;
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 ;
case A_hLightfieldHalf :
{
v_approx = new std::vector<VertexAttribute<typename PFP::VEC3>* >[1] ;
// pos
approximators.push_back(new Approximator_HalfCollapse<PFP>(map, v_pos)) ;
v_approx[0].push_back(&position) ;
// frame
std::vector<VertexAttribute<typename PFP::VEC3>* > v_frame ;
VertexAttribute<typename PFP::VEC3> FT = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameT") ;
VertexAttribute<typename PFP::VEC3> FB = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameB") ;
VertexAttribute<typename PFP::VEC3> FN = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameN") ;
v_frame.push_back(&FT) ;
v_frame.push_back(&FB) ;
v_frame.push_back(&FN) ;
approximators.push_back(new Approximator_FrameHalf<PFP>(map, v_frame)) ;
// TODO
// // function coefs
// std::vector<VertexAttribute<typename PFP::VEC3>* > v_coefs ;
// VertexAttribute<typename PFP::VEC3> coefs = map.template getAttribute<typename PFP::VEC3, VERTEX>("SLFcoefs_0") ;
// v_frame.push_back(&coefs) ;
// approximators.push_back(new Approximator_LFcoefs<PFP>(map, v_coefs)) ;
VertexAttribute<typename PFP::VEC3> *FT = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> *FB = new VertexAttribute<typename PFP::VEC3>() ;
VertexAttribute<typename PFP::VEC3> *FN = new VertexAttribute<typename PFP::VEC3>() ;
*FT = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameT") ;
*FB = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameB") ;
*FN = map.template getAttribute<typename PFP::VEC3, VERTEX>("frameN") ;
v_approx[0].push_back(FT) ;
v_approx[0].push_back(FB) ;
v_approx[0].push_back(FN) ;
// function coefs
unsigned int k = 0 ;
do
{
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 ;
/*case A_LightfieldHalf:
......@@ -230,7 +268,17 @@ void decimate(
(*it)->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 ;
}
unsigned int nbVertices = map.template getNbOrbits<VERTEX>() ;
bool finished = false ;
......@@ -274,6 +322,9 @@ void decimate(
}
delete selector ;
delete[] v_approx ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
delete (*it) ;
}
......
......@@ -460,14 +460,19 @@ private:
typedef NoMathIOAttribute<QEMextColorEdgeInfo> EdgeInfo ;
EdgeAttribute<EdgeInfo> edgeInfo ;
VertexAttribute<VEC3> m_color ;
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 ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_poscolApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d,EdgeInfo& einfo) ;
......@@ -476,13 +481,14 @@ private:
public:
EdgeSelector_QEMextColor(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
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") ;
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()
{
......
......@@ -1351,25 +1351,42 @@ bool EdgeSelector_QEMextColor<PFP>::init()
MAP& m = this->m_map ;
// Verify availability of required approximators
bool ok = false ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin();
it != this->m_approximators.end();
++it)
unsigned int ok = 0 ;
for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
{
// constraint : 2 approximators in specific order
if((*it)->getApproximatedAttributeName(0) == "position" && (*it)->getApproximatedAttributeName(1) == "color")
bool saved = false ;
for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
{
m_poscolApproximator = reinterpret_cast<Approximator<PFP, VEC3>* >(*it) ; // pos + col
// check incompatibilities
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") ;
assert(m_poscolApproximator->getType() != A_hLightfieldHalf || !"Approximator(hLightfieldHalf) and selector (ColorNaive) are not compatible") ;
ok = true ;
// constraint : 2 approximators in specific order
if(ok == 0 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "position")
{
++ok ;
m_approxindex_pos = approxindex ;
m_attrindex_pos = attrindex ;
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 ;
TraversorV<MAP> travV(m);
......@@ -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[dd] ; // two vertices quadrics
this->m_poscolApproximator->approximate(d) ; // sets newPos
VEC3 newPos = this->m_poscolApproximator->getApprox(d,0) ; // get newPos
VEC3 newCol = this->m_poscolApproximator->getApprox(d,1) ; // get newCol
// compute all approximated attributes
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin() ;
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 ;
for (unsigned int i = 0 ; i < 3 ; ++i)
{
......
......@@ -246,7 +246,8 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
{
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)
{
......@@ -259,11 +260,17 @@ void Approximator_HalfCollapse<PFP>::approximate(Dart d)
// temporary edge collapse
m.extractTrianglePair(d) ;
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
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
m.insertTrianglePair(d, d2, dd2) ;
......
......@@ -110,15 +110,19 @@ private:
typedef NoMathIOAttribute<QEMhalfEdgeInfo> 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 ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
Approximator<PFP, typename PFP::VEC3>* m_frameApproximator ;
// Approximator<PFP, typename PFP::VEC3>* m_lfcoefsApproximator ;
std::vector<Approximator<PFP, typename PFP::VEC3>* > m_approx ;
void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ;
......@@ -128,23 +132,27 @@ private:
public:
HalfEdgeSelector_Lightfield(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select),
m_positionApproximator(NULL),
m_frameApproximator(NULL)
// m_positionApproximator(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") ;
m_quadric = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
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") ;
m_quadricGeom = m.template addAttribute<Quadric<REAL>, VERTEX>("QEMquadric") ;
m_quadricHF = m.template addAttribute<QuadricHF<REAL>, VERTEX>("HFquadric") ;
}
~HalfEdgeSelector_Lightfield()
{
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 ; }
bool init() ;
......
......@@ -287,29 +287,68 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
MAP& m = this->m_map ;
// Verify availability of required approximators
char ok = 0 ;
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = this->m_approximators.begin();
it != this->m_approximators.end();
++it)
unsigned int ok = 0 ;
for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
{
// constraint : 2 approximators in specific order
if(ok == 0 && (*it)->getApproximatedAttributeName(0) == "position")
bool saved = false ;
for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
{
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3>* >(*it) ; // 1) position
assert(m_positionApproximator->getType() != A_QEM) ; // A_QEM is not compatible for half-edge crit
++ok ;
// constraint : 2 approximators in specific order
if(ok == 0 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "position")
{
++ok ;
m_approxindex_pos = approxindex ;
m_attrindex_pos = attrindex ;
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) == "frameT")
{
++ok ;
// m_approxindex_FT = approxindex ;
// m_attrindex_FT = attrindex ;
m_frameT = m.template getAttribute<typename PFP::VEC3, VERTEX>("frameT") ;
if (!saved)
{
m_approx.push_back(reinterpret_cast<Approximator<PFP, VEC3>* >(this->m_approximators[approxindex])) ;
assert(m_frameT.isValid() || !"EdgeSelector_QEMextColor: frameT attribute is not valid") ;
saved = true ;
}
}
else if(ok == 2 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "frameB")
{
++ok ;
// m_approxindex_FB = approxindex ;
// m_attrindex_FB = attrindex ;
m_frameB = m.template getAttribute<typename PFP::VEC3, VERTEX>("frameB") ;
assert(m_frameB.isValid() || !"EdgeSelector_QEMextColor: frameB attribute is not valid") ;
if (!saved)
{
m_approx.push_back(reinterpret_cast<Approximator<PFP, VEC3>* >(this->m_approximators[approxindex])) ;
saved = true ;
}
}
else if(ok == 3 && this->m_approximators[approxindex]->getApproximatedAttributeName(attrindex) == "frameN")
{
++ok ;
m_approxindex_FN = approxindex ;
m_attrindex_FN = attrindex ;
m_frameN = m.template getAttribute<typename PFP::VEC3, VERTEX>("frameN") ;
assert(m_frameN.isValid() || !"EdgeSelector_QEMextColor: frameN attribute is not valid") ;
if (!saved)
{
m_approx.push_back(reinterpret_cast<Approximator<PFP, VEC3>* >(this->m_approximators[approxindex])) ;
saved = true ;
}
}
}
else
if( ok == 1 && (*it)->getApproximatedAttributeName(0) == "frameT")
if( ok == 1 && (*it)->getApproximatedAttributeName(1) == "frameB")
if( ok == 1 && (*it)->getApproximatedAttributeName(2) == "frameN")
{
m_frameApproximator = reinterpret_cast<Approximator<PFP, VEC3>* >(*it) ; // 2) frame (needs position)
++ok ;
}
}
if(ok != 2)
if(ok != 4)
return false ;
// Set quadric per vertex
......@@ -319,7 +358,7 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
if(!vMark.isMarked(d))
{
Quadric<REAL> q ; // create one quadric
m_quadric[d] = q ; // per vertex
m_quadricGeom[d] = q ; // per vertex
vMark.mark(d) ;
}
}
......@@ -334,9 +373,9 @@ bool HalfEdgeSelector_Lightfield<PFP>::init()
Dart d1 = m.phi1(d) ; // for each triangle,
Dart d_1 = m.phi_1(d) ; // initialize the quadric of the triangle
Quadric<REAL> q(this->m_position[d], this->m_position[d1], this->m_position[d_1]) ;
m_quadric[d] += q ; // and add the contribution of
m_quadric[d1] += q ; // this quadric to the ones
m_quadric[d_1] += q ; // of the 3 incident vertices
m_quadricGeom[d] += q ; // and add the contribution of
m_quadricGeom[d1] += q ; // this quadric to the ones
m_quadricGeom[d_1] += q ; // of the 3 incident vertices
mark.markOrbit<FACE>(d) ;
}
}
......@@ -412,7 +451,7 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
// Init Front
dFront = dInit ;
m_quadric[d].zero() ;
m_quadricGeom[d].zero() ;
do
{
......@@ -422,7 +461,7 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
if (dBack != dFront)
{ // if dFront is no border
m_quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi1(dFront)],this->m_position[dBack]) ;
m_quadricGeom[d] += Quadric<REAL>(m_pos[d],m_pos[this->m_map.phi1(dFront)],m_pos[dBack]) ;
}
if (recomputeNeighbors)
recomputeQuadric(dBack, false) ;
......@@ -520,41 +559,53 @@ void HalfEdgeSelector_Lightfield<PFP>::updateHalfEdgeInfo(Dart d, bool recompute
template