Commit 4ae28bc3 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Template for edgeSelector.

edgeSelector considers approximated data on ORBITs instead of only
edges.
parent 666d7fcf
...@@ -67,6 +67,7 @@ public: ...@@ -67,6 +67,7 @@ public:
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse() { } void updateWithoutCollapse() { }
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -143,6 +144,24 @@ public: ...@@ -143,6 +144,24 @@ public:
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse() { } 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())
{
(*errors)[d] = -1 ;
if (edgeInfo[d].valid)
{
(*errors)[d] = edgeInfo[d].it->first ;
}
}
}
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -518,6 +537,24 @@ public: ...@@ -518,6 +537,24 @@ public:
void updateAfterCollapse(Dart d2, Dart dd2) ; void updateAfterCollapse(Dart d2, Dart dd2) ;
void updateWithoutCollapse() { } 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())
{
(*errors)[d] = -1 ;
if (edgeInfo[d].valid)
{
(*errors)[d] = edgeInfo[d].it->first ;
}
}
}
} ; } ;
/***************************************************************************************************************** /*****************************************************************************************************************
......
...@@ -290,6 +290,9 @@ bool EdgeSelector_QEM<PFP>::init() ...@@ -290,6 +290,9 @@ bool EdgeSelector_QEM<PFP>::init()
{ {
if((*it)->getApproximatedAttributeName() == "position") if((*it)->getApproximatedAttributeName() == "position")
{ {
assert((*it)->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_QEM) are not compatible") ;
assert((*it)->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_QEM) are not compatible") ;
assert((*it)->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (EdgeSelector_QEM) are not compatible") ;
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ; m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ;
ok = true ; ok = true ;
} }
...@@ -507,6 +510,9 @@ bool EdgeSelector_QEMml<PFP>::init() ...@@ -507,6 +510,9 @@ bool EdgeSelector_QEMml<PFP>::init()
{ {
if((*it)->getApproximatedAttributeName() == "position") if((*it)->getApproximatedAttributeName() == "position")
{ {
assert((*it)->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_QEMml) are not compatible") ;
assert((*it)->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_QEMml) are not compatible") ;
assert((*it)->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (EdgeSelector_QEMml) are not compatible") ;
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ; m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ;
ok = true ; ok = true ;
} }
...@@ -737,6 +743,9 @@ bool EdgeSelector_Curvature<PFP>::init() ...@@ -737,6 +743,9 @@ bool EdgeSelector_Curvature<PFP>::init()
{ {
if((*it)->getApproximatedAttributeName() == "position") if((*it)->getApproximatedAttributeName() == "position")
{ {
assert((*it)->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_Curvature) are not compatible") ;
assert((*it)->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_Curvature) are not compatible") ;
assert((*it)->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (EdgeSelector_Curvature) are not compatible") ;
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ; m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ;
ok = true ; ok = true ;
} }
...@@ -948,6 +957,9 @@ bool EdgeSelector_MinDetail<PFP>::init() ...@@ -948,6 +957,9 @@ bool EdgeSelector_MinDetail<PFP>::init()
{ {
if((*it)->getApproximatedAttributeName() == "position" && (*it)->getPredictor()) if((*it)->getApproximatedAttributeName() == "position" && (*it)->getPredictor())
{ {
assert((*it)->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_MinDetail) are not compatible") ;
assert((*it)->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_MinDetail) are not compatible") ;
assert((*it)->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (EdgeSelector_MinDetail) are not compatible") ;
m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ; m_positionApproximator = reinterpret_cast<Approximator<PFP, VEC3,EDGE>* >(*it) ;
ok = true ; ok = true ;
} }
...@@ -1116,14 +1128,14 @@ bool EdgeSelector_ColorNaive<PFP>::init() ...@@ -1116,14 +1128,14 @@ bool EdgeSelector_ColorNaive<PFP>::init()
{ {
MAP& m = this->m_map ; MAP& m = this->m_map ;
assert(this->m_approximators[0]->getType() != A_hQEM || !"Approximator(hQEM) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[0]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[0]->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (ColorNaive) are not compatible") ;
// Verify availability of required approximators // Verify availability of required approximators
unsigned int ok = 0 ; unsigned int ok = 0 ;
for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex) for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
{ {
assert(this->m_approximators[approxindex]->getType() != A_hQEM || !"Approximator(hQEM) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_Lightfield || !"Approximator(hLightfield) and selector (ColorNaive) are not compatible") ;
bool saved = false ; bool saved = false ;
for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex) for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
{ {
...@@ -1383,13 +1395,14 @@ bool EdgeSelector_QEMextColor<PFP>::init() ...@@ -1383,13 +1395,14 @@ bool EdgeSelector_QEMextColor<PFP>::init()
{ {
MAP& m = this->m_map ; MAP& m = this->m_map ;
assert(this->m_approximators[0]->getType() != A_hQEM || !"Approximator(hQEM) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[0]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (ColorNaive) are not compatible") ;
// Verify availability of required approximators // Verify availability of required approximators
unsigned int ok = 0 ; unsigned int ok = 0 ;
for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex) for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
{ {
assert(this->m_approximators[approxindex]->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_QEMextColor) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_QEMextColor) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_hLightfieldHalf || !"Approximator(hLightfieldHalf) and selector (EdgeSelector_QEMextColor) are not compatible") ;
bool saved = false ; bool saved = false ;
for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex) for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
{ {
...@@ -1681,13 +1694,14 @@ bool EdgeSelector_Lightfield<PFP>::init() ...@@ -1681,13 +1694,14 @@ bool EdgeSelector_Lightfield<PFP>::init()
{ {
MAP& m = this->m_map ; MAP& m = this->m_map ;
assert(this->m_approximators[0]->getType() != A_hQEM || !"Approximator(hQEM) and selector (ColorNaive) are not compatible") ;
assert(this->m_approximators[0]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (ColorNaive) are not compatible") ;
// Verify availability of required approximators // Verify availability of required approximators
unsigned int ok = 0 ; unsigned int ok = 0 ;
for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex) for (unsigned int approxindex = 0 ; approxindex < this->m_approximators.size() ; ++approxindex)
{ {
assert(this->m_approximators[approxindex]->getType() != A_hQEM || !"Approximator(hQEM) and selector (EdgeSelector_Lightfield) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_hHalfCollapse || !"Approximator(hHalfCollapse) and selector (EdgeSelector_Lightfield) are not compatible") ;
assert(this->m_approximators[approxindex]->getType() != A_hLightfieldHalf || !"Approximator(hLightfieldHalf) and selector (EdgeSelector_Lightfield) are not compatible") ;
unsigned int k = 0 ; unsigned int k = 0 ;
bool saved = false ; bool saved = false ;
for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex) for (unsigned int attrindex = 0 ; attrindex < this->m_approximators[approxindex]->getNbApproximated() ; ++ attrindex)
...@@ -2004,18 +2018,16 @@ void EdgeSelector_Lightfield<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo) ...@@ -2004,18 +2018,16 @@ void EdgeSelector_Lightfield<PFP>::computeEdgeInfo(Dart d, EdgeInfo& einfo)
//std::cout << quadGeom(newPos) << " vs " << alpha/M_PI << " vs " << quadHF(newHF) << std::endl ; //std::cout << quadGeom(newPos) << " vs " << alpha/M_PI << " vs " << quadHF(newHF) << std::endl ;
// sum of QEM metric and frame orientation difference // sum of QEM metric and frame orientation difference
const REAL& err = const REAL& errG = quadGeom(newPos) ; // geom
quadGeom(newPos) // geom const REAL& errAngle = alpha / M_PI ; // frame
+ alpha / M_PI // frame const REAL& errLF = quadHF(newHF) ; // function coefficients
+ quadHF(newHF) // function coefficients
;
// Check if errated values appear // Check if errated values appear
if (err < -1e-6) if (errG < -1e-10 || errAngle < -1e-10 || errLF < -1e-10)
einfo.valid = false ; einfo.valid = false ;
else else
{ {
einfo.it = edges.insert(std::make_pair(std::max(err,REAL(0)), d)) ; einfo.it = edges.insert(std::make_pair(std::max(errG + errAngle + errLF, REAL(0)), d)) ;
einfo.valid = true ; einfo.valid = true ;
} }
} }
......
...@@ -84,16 +84,7 @@ public: ...@@ -84,16 +84,7 @@ public:
virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors) virtual void getEdgeErrors(EdgeAttribute<typename PFP::REAL> *errors)
{ {
// assert(colors != NULL || !"EdgeSelector::setColorMap requires non null vertexattribute argument") ; std::cout << "WARNING:: getEdgeErrors was not overridden" << std::endl ;
// if (!colors->isValid())
// std::cerr << "EdgeSelector::setColorMap requires valid vertexattribute argument" << std::endl ;
//
// TraversorV<typename PFP::MAP> travV(map);
// for(Dart d = travV.begin() ; d != travV.end() ; d = travV.next())
// {
// REAL scaled = scale_to_0_1(error,edges.begin()->first,edges.rbegin()->first) ;
// (*colors)[d] = color_map_blue_green_red(scaled) ;
// }
} }
} ; } ;
......
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