From 68dfe535100cc0263cca5ea879e1431b44d3dbd4 Mon Sep 17 00:00:00 2001 From: Kenneth Vanhoey Date: Mon, 21 Mar 2011 19:04:38 +0100 Subject: [PATCH] some phi2 -> ph1 corrections --- include/Algo/Decimation/approximator.h | 2 +- include/Algo/Decimation/decimation.hpp | 13 ++++++++----- include/Algo/Decimation/geometryApproximator.h | 8 ++++---- .../Algo/Decimation/geometryApproximator.hpp | 10 ++++++++-- include/Algo/Decimation/halfEdgeSelector.hpp | 11 ++++++----- .../Algo/Decimation/lightfieldApproximator.hpp | 18 +++++++++--------- include/Algo/Render/vbo_MapRender.hpp | 2 +- include/Geometry/vector_gen.hpp | 2 ++ include/Utils/qem.h | 3 +++ include/Utils/quadricRGBfunctions.hpp | 8 ++++---- 10 files changed, 46 insertions(+), 31 deletions(-) diff --git a/include/Algo/Decimation/approximator.h b/include/Algo/Decimation/approximator.h index 5a533562..2255ba79 100644 --- a/include/Algo/Decimation/approximator.h +++ b/include/Algo/Decimation/approximator.h @@ -39,7 +39,7 @@ namespace Decimation enum ApproximatorType { A_QEM, - A_QEMhalf, + A_QEMhalfEdge, A_MidEdge, A_HalfCollapse, A_CornerCutting, diff --git a/include/Algo/Decimation/decimation.hpp b/include/Algo/Decimation/decimation.hpp index 188c1c34..41be4051 100644 --- a/include/Algo/Decimation/decimation.hpp +++ b/include/Algo/Decimation/decimation.hpp @@ -45,8 +45,8 @@ void decimate( case A_QEM : approximators.push_back(new Approximator_QEM(map, position)) ; break ; - case A_QEMhalf : - approximators.push_back(new Approximator_QEMhalf(map, position)) ; + case A_QEMhalfEdge : + approximators.push_back(new Approximator_QEMhalfEdge(map, position)) ; break ; case A_MidEdge : approximators.push_back(new Approximator_MidEdge(map, position)) ; @@ -65,7 +65,7 @@ void decimate( break ; case A_LightfieldFull : { - approximators.push_back(new Approximator_QEMhalf(map, position)) ; + approximators.push_back(new Approximator_QEMhalfEdge(map, position)) ; /* PFP::TVEC3 frame[3] ; frame[0] = map.template getAttribute(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 ; } } diff --git a/include/Algo/Decimation/geometryApproximator.h b/include/Algo/Decimation/geometryApproximator.h index 4b7218da..3c1f3467 100644 --- a/include/Algo/Decimation/geometryApproximator.h +++ b/include/Algo/Decimation/geometryApproximator.h @@ -59,7 +59,7 @@ public: } ; template -class Approximator_QEMhalf : public Approximator +class Approximator_QEMhalfEdge : public Approximator { public: typedef typename PFP::MAP MAP ; @@ -70,12 +70,12 @@ protected: AttributeHandler > m_quadric ; public: - Approximator_QEMhalf(MAP& m, AttributeHandler& pos, Predictor* pred = NULL) : + Approximator_QEMhalfEdge(MAP& m, AttributeHandler& pos, Predictor* pred = NULL) : Approximator(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) ; } ; diff --git a/include/Algo/Decimation/geometryApproximator.hpp b/include/Algo/Decimation/geometryApproximator.hpp index d929e142..3b5fe234 100644 --- a/include/Algo/Decimation/geometryApproximator.hpp +++ b/include/Algo/Decimation/geometryApproximator.hpp @@ -110,7 +110,7 @@ void Approximator_QEM::approximate(Dart d) ************************************************************************************/ template -bool Approximator_QEMhalf::init() +bool Approximator_QEMhalfEdge::init() { m_quadric = this->m_map.template getAttribute >(VERTEX_ORBIT, "QEMquadric") ; @@ -122,7 +122,7 @@ bool Approximator_QEMhalf::init() } template -void Approximator_QEMhalf::approximate(Dart d) +void Approximator_QEMhalfEdge::approximate(Dart d) { MAP& m = this->m_map ; @@ -166,6 +166,12 @@ void Approximator_QEMhalf::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 ; + } } /************************************************************************************ diff --git a/include/Algo/Decimation/halfEdgeSelector.hpp b/include/Algo/Decimation/halfEdgeSelector.hpp index b98860e5..8cf50f3f 100644 --- a/include/Algo/Decimation/halfEdgeSelector.hpp +++ b/include/Algo/Decimation/halfEdgeSelector.hpp @@ -159,11 +159,11 @@ void HalfEdgeSelector_QEMml::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(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[dBack]) ; + quadric[d] += Quadric(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::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(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[dBack]) ; + quadric[d] += Quadric(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::recomputeQuadric(const Dart d, const bool } while(dFront != dInit) ; } - template void HalfEdgeSelector_Lightfield::updateAfterCollapse(Dart d2, Dart dd2) { diff --git a/include/Algo/Decimation/lightfieldApproximator.hpp b/include/Algo/Decimation/lightfieldApproximator.hpp index 08bf8d89..c6f21765 100644 --- a/include/Algo/Decimation/lightfieldApproximator.hpp +++ b/include/Algo/Decimation/lightfieldApproximator.hpp @@ -264,15 +264,15 @@ void Approximator_RGBfunctions::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 : " <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 : " <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 ; // } } diff --git a/include/Algo/Render/vbo_MapRender.hpp b/include/Algo/Render/vbo_MapRender.hpp index f41396b5..97b5c509 100644 --- a/include/Algo/Render/vbo_MapRender.hpp +++ b/include/Algo/Render/vbo_MapRender.hpp @@ -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); } } diff --git a/include/Geometry/vector_gen.hpp b/include/Geometry/vector_gen.hpp index a0fb66f3..5c52a8ca 100644 --- a/include/Geometry/vector_gen.hpp +++ b/include/Geometry/vector_gen.hpp @@ -242,6 +242,8 @@ template inline double Vector::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 ; diff --git a/include/Utils/qem.h b/include/Utils/qem.h index ded6899b..d6974a2a 100644 --- a/include/Utils/qem.h +++ b/include/Utils/qem.h @@ -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 ; diff --git a/include/Utils/quadricRGBfunctions.hpp b/include/Utils/quadricRGBfunctions.hpp index a044a592..64b0d502 100644 --- a/include/Utils/quadricRGBfunctions.hpp +++ b/include/Utils/quadricRGBfunctions.hpp @@ -68,18 +68,19 @@ QuadricRGBfunctions::QuadricRGBfunctions(const QuadricRGBfunctions& q) { template QuadricRGBfunctions::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::buildRotateMatrix(MATRIX66 &N, const REAL gamma) N(5,3) = REAL(0); N(5,4) = REAL(0); N(5,5) = REAL(1); - } template -- GitLab