Commit 68dfe535 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

some phi2 -> ph1 corrections

parent 969ec0fd
......@@ -39,7 +39,7 @@ namespace Decimation
enum ApproximatorType
{
A_QEM,
A_QEMhalf,
A_QEMhalfEdge,
A_MidEdge,
A_HalfCollapse,
A_CornerCutting,
......
......@@ -45,8 +45,8 @@ void decimate(
case A_QEM :
approximators.push_back(new Approximator_QEM<PFP>(map, position)) ;
break ;
case A_QEMhalf :
approximators.push_back(new Approximator_QEMhalf<PFP>(map, position)) ;
case A_QEMhalfEdge :
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, position)) ;
break ;
case A_MidEdge :
approximators.push_back(new Approximator_MidEdge<PFP>(map, position)) ;
......@@ -65,7 +65,7 @@ void decimate(
break ;
case A_LightfieldFull :
{
approximators.push_back(new Approximator_QEMhalf<PFP>(map, position)) ;
approximators.push_back(new Approximator_QEMhalfEdge<PFP>(map, position)) ;
/*
PFP::TVEC3 frame[3] ;
frame[0] = map.template getAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "frame_T") ; // Tangent
......@@ -148,8 +148,11 @@ void decimate(
while(!finished)
{
std::cout << "Countdown : " ;
std::cout << std::setprecision(8) << (nbVertices - nbWantedVertices) << "\r" << std::flush;
if(!selector->nextEdge(d)) {
std::cout << "out" << std::endl ;
std::cout << std::endl << "out" << std::endl ;
break ;
}
......@@ -175,7 +178,7 @@ void decimate(
if(nbVertices <= nbWantedVertices) {
finished = true ;
std::cout << "done" << std::endl ;
std::cout << std::endl << "done" << std::endl ;
}
}
......
......@@ -59,7 +59,7 @@ public:
} ;
template <typename PFP>
class Approximator_QEMhalf : public Approximator<PFP, typename PFP::VEC3>
class Approximator_QEMhalfEdge : public Approximator<PFP, typename PFP::VEC3>
{
public:
typedef typename PFP::MAP MAP ;
......@@ -70,12 +70,12 @@ protected:
AttributeHandler<Quadric<REAL> > m_quadric ;
public:
Approximator_QEMhalf(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
Approximator_QEMhalfEdge(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
{}
~Approximator_QEMhalf()
~Approximator_QEMhalfEdge()
{}
ApproximatorType getType() const { return A_QEMhalf ; }
ApproximatorType getType() const { return A_QEMhalfEdge ; }
bool init() ;
void approximate(Dart d) ;
} ;
......
......@@ -110,7 +110,7 @@ void Approximator_QEM<PFP>::approximate(Dart d)
************************************************************************************/
template <typename PFP>
bool Approximator_QEMhalf<PFP>::init()
bool Approximator_QEMhalfEdge<PFP>::init()
{
m_quadric = this->m_map.template getAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
......@@ -122,7 +122,7 @@ bool Approximator_QEMhalf<PFP>::init()
}
template <typename PFP>
void Approximator_QEMhalf<PFP>::approximate(Dart d)
void Approximator_QEMhalfEdge<PFP>::approximate(Dart d)
{
MAP& m = this->m_map ;
......@@ -166,6 +166,12 @@ void Approximator_QEMhalf<PFP>::approximate(Dart d)
this->m_approx[d] = this->m_attrV[d] ;
else
this->m_approx[d] = res ;
if (isnan((res[0]))) {
std::cout << "res(" << opt << ") = " << this->m_approx[d] << std::endl ;
std::cout << q1 << std::endl ;
std::cout << q2 << std::endl ;
}
}
/************************************************************************************
......
......@@ -159,11 +159,11 @@ void HalfEdgeSelector_QEMml<PFP>::recomputeQuadric(const Dart d, const bool reco
do {
// Make step
dBack = this->m_map.phi2(dFront) ;
dBack = this->m_map.phi1(dFront) ;
dFront = this->m_map.alpha1(dFront) ;
if (dBack != dFront) { // if dFront is no border
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[dBack]) ;
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi1(dFront)],this->m_position[dBack]) ;
}
if (recomputeNeighbors)
recomputeQuadric(dBack, false) ;
......@@ -404,11 +404,13 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
do {
// Make step
dBack = this->m_map.phi2(dFront) ;
dBack = this->m_map.phi1(dFront) ;
dFront = this->m_map.alpha1(dFront) ;
if (dBack != dFront) { // if dFront is no border
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[dBack]) ;
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi1(dFront)],this->m_position[dBack]) ;
if (isnan(this->m_position[d][0]))
std::cout << "NaaaaN" << std::endl ;
}
if (recomputeNeighbors)
recomputeQuadric(dBack, false) ;
......@@ -416,7 +418,6 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
} while(dFront != dInit) ;
}
template <typename PFP>
void HalfEdgeSelector_Lightfield<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
{
......
......@@ -264,15 +264,15 @@ void Approximator_RGBfunctions<PFP>::approximate(Dart d)
if (! m_quadricRGBfunctions[d].findOptimizedRGBfunctions(this->m_approx[d])) {
this->m_approx[d] = this->m_attrV[d]; // if fail take first one
}
// if (gamma2 < -1) {
// std::cout << "Approx of : " <<std::endl ;
// std::cout << "Frame1 : " << m_frame[d] << std::endl ;
// std::cout << "Function1 : "<< this->m_attrV[d] << std::endl ;
// std::cout << "Frame2 : " << m_frame[dd] << std::endl ;
// std::cout << "Function2 : "<< this->m_attrV[dd] << std::endl ;
// std::cout << "is " << std::endl ;
// std::cout << "Frame :" << m_approxFrame[d] << std::endl ;
// std::cout << "Function : " << this->m_approx[d] << std::endl << std::endl ;
// if (gamma2 < -3) {
// std::cout << "Approx of : " <<std::endl ;
// std::cout << "Frame1 : " << m_frame[d] << std::endl ;
// std::cout << "Function1 : "<< this->m_attrV[d] << std::endl ;
// std::cout << "Frame2 : " << m_frame[dd] << std::endl ;
// std::cout << "Function2 : "<< this->m_attrV[dd] << std::endl ;
// std::cout << "is " << std::endl ;
// std::cout << "Frame :" << m_approxFrame[d] << std::endl ;
// std::cout << "Function : " << this->m_approx[d] << std::endl << std::endl ;
// }
}
......
......@@ -308,7 +308,7 @@ void MapRender_VBO::initLines(typename PFP::MAP& map, const FunctorSelect& good,
if(!m.isMarked(d) && good(d))
{
tableIndices.push_back(map.getEmbedding(d, VERTEX_ORBIT));
tableIndices.push_back(map.getEmbedding(map.phi2(d), VERTEX_ORBIT));
tableIndices.push_back(map.getEmbedding(map.phi1(d), VERTEX_ORBIT));
m.markOrbit(EDGE_ORBIT, d);
}
}
......
......@@ -242,6 +242,8 @@ template <unsigned int DIM, typename T>
inline double Vector<DIM,T>::normalize()
{
double n = norm() ;
if(n==T(0.0))
n = T(0.0001) ;
for(unsigned int i = 0; i < DIM; ++i)
m_data[i] /= T(n) ;
return n ;
......
......@@ -153,6 +153,9 @@ private:
bool optimize(VEC4& v) const
{
if (isnan(A(0,0)))
return false ;
MATRIX44 A2(A) ;
for(int i = 0; i < 3; ++i)
A2(3,i) = 0.0f ;
......
......@@ -68,18 +68,19 @@ QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const QuadricRGBfunctions& q) {
template <typename REAL>
QuadricRGBfunctions<REAL>::QuadricRGBfunctions(const RGBFUNCTIONS& cf, const REAL gamma, const REAL alpha) {
MATRIX66 R1,R2_b,R2_c;
MATRIX66 R1,R2_b,R2_c ;
buildRotateMatrix(R1,gamma); // Rotation 1
R1.transpose() ;
buildIntegralMatrix_A(A,alpha); // Parameterized integral matrix A
buildIntegralMatrix_b(R2_b,alpha); // Parameterized integral matrix b
buildIntegralMatrix_c(R2_c,alpha); // Parameterized integral matrix c
// Quadric (A,b,c) => L*A*Lt - 2*b*Lt + c = ERROR
for (unsigned col = RED; col < BLUE+1; ++col) {
Geom::Vector<6,REAL> function; // get function coefficients
for (unsigned col = RED ; col < BLUE+1 ; ++col) {
Geom::Vector<6,REAL> function ; // get function coefficients
if (!cf.getSubVectorH(col,0,function))
assert(!"QuadricRGBfunctions::constructor") ;
......@@ -373,7 +374,6 @@ void QuadricRGBfunctions<REAL>::buildRotateMatrix(MATRIX66 &N, const REAL gamma)
N(5,3) = REAL(0);
N(5,4) = REAL(0);
N(5,5) = REAL(1);
}
template <typename REAL>
......
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