Commit eff8a62f authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

add idleFunc in glutwin atb dark

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