Commit eff8a62f authored by Kenneth Vanhoey's avatar Kenneth Vanhoey
Browse files

add idleFunc in glutwin atb dark

parent baa0cb37
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define __LIGHTFIELD_APPROXIMATOR_H__ #define __LIGHTFIELD_APPROXIMATOR_H__
#include "Algo/Decimation/approximator.h" #include "Algo/Decimation/approximator.h"
#include "Topology/generic/mapBrowser.h"
namespace CGoGN namespace CGoGN
{ {
......
...@@ -258,8 +258,7 @@ private: ...@@ -258,8 +258,7 @@ private:
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) ;
void recomputeQuadric(const Dart d, const bool neighbours = false) ; void recomputeQuadric(const Dart d, const bool recomputeNeighbors = false) ;
Dart rewind(const Dart d) ;
public: public:
EdgeSelector_QEMml(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) : EdgeSelector_QEMml(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
...@@ -318,8 +317,7 @@ private: ...@@ -318,8 +317,7 @@ private:
void initHalfEdgeInfo(Dart d) ; void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ; void updateHalfEdgeInfo(Dart d, bool recompute) ;
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ; void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
void recomputeQuadric(const Dart d, const bool neighbors) ; void recomputeQuadric(const Dart d, const bool recomputeNeighbors) ;
Dart rewind(const Dart d) ;
public: public:
HalfEdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) : HalfEdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
......
...@@ -582,23 +582,6 @@ void EdgeSelector_QEMml<PFP>::updateBeforeCollapse(Dart d) ...@@ -582,23 +582,6 @@ void EdgeSelector_QEMml<PFP>::updateBeforeCollapse(Dart d)
if(edgeE.valid) if(edgeE.valid)
edges.erase(edgeE.it) ; edges.erase(edgeE.it) ;
} }
}
/**
* rewind until border (if any)
*/
// TODO : check & optimize
template <typename PFP>
Dart EdgeSelector_QEMml<PFP>::rewind(const Dart d) {
Dart dInit = d ;
do {
if (dInit == this->m_map.phi2(dInit)) // if border
break ; // stop
dInit = this->m_map.alpha_1(dInit) ;
} while (dInit != d) ;
return dInit ;
} }
/** /**
...@@ -608,29 +591,27 @@ Dart EdgeSelector_QEMml<PFP>::rewind(const Dart d) { ...@@ -608,29 +591,27 @@ Dart EdgeSelector_QEMml<PFP>::rewind(const Dart d) {
* @param dart d * @param dart d
*/ */
template <typename PFP> template <typename PFP>
void EdgeSelector_QEMml<PFP>::recomputeQuadric(const Dart d, const bool neighbours) { void EdgeSelector_QEMml<PFP>::recomputeQuadric(const Dart d, const bool recomputeNeighbors) {
Dart dFront,dBack; Dart dFront,dBack ;
Dart dInit = rewind(d) ; // rewind until border (if any) Dart dInit = d ;
// Init Front // Init Front
dFront = dInit; dFront = dInit ;
quadric[d].zero(); quadric[d].zero() ;
do { do {
// Make step // Make step
dBack = dFront ; dBack = this->m_map.phi2(dFront) ;
dFront = this->m_map.alpha1(dFront); dFront = this->m_map.alpha1(dFront) ;
if (neighbours) 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]) ;
}
if (recomputeNeighbors)
recomputeQuadric(this->m_map.phi2(dFront), false) ; recomputeQuadric(this->m_map.phi2(dFront), false) ;
if (dFront == this->m_map.phi2(dFront)) } while(dFront != dInit) ;
break ;
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[this->m_map.phi2(dBack)]);
} while(dFront != dInit);
} }
...@@ -849,21 +830,6 @@ void HalfEdgeSelector_Lightfield<PFP>::updateBeforeCollapse(Dart d) ...@@ -849,21 +830,6 @@ void HalfEdgeSelector_Lightfield<PFP>::updateBeforeCollapse(Dart d)
} }
} }
/**
* rewind until border (if any)
*/
template <typename PFP>
Dart HalfEdgeSelector_Lightfield<PFP>::rewind(const Dart d) {
Dart dInit = d ;
do {
if (dInit == this->m_map.phi2(dInit)) // if border
break ; // stop
dInit = this->m_map.alpha_1(dInit) ;
} while (dInit != d) ;
return dInit ;
}
/** /**
* Update quadric of a vertex * Update quadric of a vertex
* Discards quadrics of d and assigns freshly calculated * Discards quadrics of d and assigns freshly calculated
...@@ -871,9 +837,9 @@ Dart HalfEdgeSelector_Lightfield<PFP>::rewind(const Dart d) { ...@@ -871,9 +837,9 @@ Dart HalfEdgeSelector_Lightfield<PFP>::rewind(const Dart d) {
* @param dart d * @param dart d
*/ */
template <typename PFP> template <typename PFP>
void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool neighbors) { void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool recomputeNeighbors) {
Dart dFront,dBack ; Dart dFront,dBack ;
Dart dInit = rewind(d) ; // rewind until border (if any) Dart dInit = d ;
// Init Front // Init Front
dFront = dInit ; dFront = dInit ;
...@@ -882,20 +848,19 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool ...@@ -882,20 +848,19 @@ void HalfEdgeSelector_Lightfield<PFP>::recomputeQuadric(const Dart d, const bool
do { do {
// Make step // Make step
dBack = dFront ; dBack = this->m_map.phi2(dFront) ;
dFront = this->m_map.alpha1(dFront) ; dFront = this->m_map.alpha1(dFront) ;
if (neighbors) 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]) ;
}
if (recomputeNeighbors)
recomputeQuadric(this->m_map.phi2(dFront), false) ; recomputeQuadric(this->m_map.phi2(dFront), false) ;
if (dFront == this->m_map.phi2(dFront))
break ;
quadric[d] += Quadric<REAL>(this->m_position[d],this->m_position[this->m_map.phi2(dFront)],this->m_position[this->m_map.phi2(dBack)]) ;
} while(dFront != dInit) ; } while(dFront != dInit) ;
} }
template <typename PFP> template <typename PFP>
void HalfEdgeSelector_Lightfield<PFP>::updateAfterCollapse(Dart d2, Dart dd2) void HalfEdgeSelector_Lightfield<PFP>::updateAfterCollapse(Dart d2, Dart dd2)
{ {
......
...@@ -75,6 +75,7 @@ protected: ...@@ -75,6 +75,7 @@ protected:
// internal callbacks // internal callbacks
static void redraw() ; static void redraw() ;
static void idleFunc() ;
static void recalcModelView() ; static void recalcModelView() ;
static void motion(int x, int y) ; static void motion(int x, int y) ;
static void mouse(int button, int state, int x, int y) ; static void mouse(int button, int state, int x, int y) ;
...@@ -82,6 +83,7 @@ protected: ...@@ -82,6 +83,7 @@ protected:
static void keyboard(unsigned char keycode, int x, int y) ; static void keyboard(unsigned char keycode, int x, int y) ;
protected: protected:
virtual void myIdleFunc() {}
virtual void myKeyboard(unsigned char, int, int) {} virtual void myKeyboard(unsigned char, int, int) {}
virtual void myMouse(int, int, int, int) {} virtual void myMouse(int, int, int, int) {}
virtual void myMotion(int, int) {} virtual void myMotion(int, int) {}
......
...@@ -49,7 +49,7 @@ GlutWin_ATBdark::GlutWin_ATBdark(int* argc, char **argv, int winX, int winY) ...@@ -49,7 +49,7 @@ GlutWin_ATBdark::GlutWin_ATBdark(int* argc, char **argv, int winX, int winY)
glutDisplayFunc(redraw) ; glutDisplayFunc(redraw) ;
glutReshapeFunc(reshape) ; glutReshapeFunc(reshape) ;
glutIdleFunc(NULL) ; glutIdleFunc(idleFunc) ;
glutMouseFunc(mouse) ; glutMouseFunc(mouse) ;
glutPassiveMotionFunc(passive_mouse) ; glutPassiveMotionFunc(passive_mouse) ;
glutMotionFunc(motion) ; glutMotionFunc(motion) ;
...@@ -106,6 +106,11 @@ void GlutWin_ATBdark::reshape(int w, int h) ...@@ -106,6 +106,11 @@ void GlutWin_ATBdark::reshape(int w, int h)
TwWindowSize(W, H) ; TwWindowSize(W, H) ;
} }
void GlutWin_ATBdark::idleFunc()
{
instance->myIdleFunc() ;
}
void GlutWin_ATBdark::recalcModelView() void GlutWin_ATBdark::recalcModelView()
{ {
GLfloat m[4][4] ; GLfloat m[4][4] ;
......
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