Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 912c8127 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey
Browse files

separation selecteurs en 2 fichiers (edgeSelector et halfEdgeSelector)

parent 223428d1
......@@ -25,7 +25,8 @@
#ifndef __DECIMATION_H__
#define __DECIMATION_H__
#include "Algo/Decimation/selector.h"
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/halfEdgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/lightfieldApproximator.h"
......
......@@ -122,18 +122,18 @@ void decimate(
case S_QEM :
selector = new EdgeSelector_QEM<PFP>(map, position, approximators) ;
break ;
case S_Lightfield :
selector = new EdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_LightfieldHalf :
selector = new HalfEdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
case S_Curvature :
selector = new EdgeSelector_Curvature<PFP>(map, position, approximators) ;
break ;
case S_MinDetail :
selector = new EdgeSelector_Random<PFP>(map, position, approximators) ;
break ;
case S_hLightfield :
selector = new HalfEdgeSelector_QEMml<PFP>(map, position, approximators) ;
break ;
case S_hQEMml :
selector = new HalfEdgeSelector_Lightfield<PFP>(map, position, approximators) ;
break ;
}
for(typename std::vector<ApproximatorGen<PFP>*>::iterator it = approximators.begin(); it != approximators.end(); ++it)
......
......@@ -49,8 +49,8 @@ enum SelectorType
S_QEMml,
S_MinDetail,
S_Curvature,
S_Lightfield,
S_LightfieldHalf
S_hQEMml,
S_hLightfield
} ;
......@@ -85,454 +85,11 @@ public:
virtual void updateAfterCollapse(Dart d2, Dart dd2) = 0 ;
} ;
template <typename PFP>
class EdgeSelector_MapOrder : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
Dart cur ;
public:
EdgeSelector_MapOrder(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{}
~EdgeSelector_MapOrder()
{}
SelectorType getType() { return S_MapOrder ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d)
{}
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_Random : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
std::vector<Dart> darts ;
unsigned int cur ;
bool allSkipped ;
public:
EdgeSelector_Random(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{}
~EdgeSelector_Random()
{}
SelectorType getType() { return S_Random ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d2)
{}
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_Length : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LengthEdgeInfo" ; }
} LengthEdgeInfo ;
typedef NoMathIOAttribute<LengthEdgeInfo> EdgeInfo ;
AttributeHandler<EdgeInfo> edgeInfo ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_Length(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
}
~EdgeSelector_Length()
{
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_EdgeLength ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_QEM : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; }
} QEMedgeInfo ;
typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo ;
AttributeHandler<EdgeInfo> edgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
Quadric<REAL> tmpQ ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_QEM(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
}
~EdgeSelector_QEM()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_QEM ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_QEMml : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "QEMedgeInfo" ; }
} QEMedgeInfo ;
typedef NoMathIOAttribute<QEMedgeInfo> EdgeInfo ;
AttributeHandler<EdgeInfo> edgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
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()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
}
~EdgeSelector_QEMml()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_QEM ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class HalfEdgeSelector_Lightfield : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef MATRIX33 FRAME ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
typedef MATRIX36 RGBFUNCTIONS ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LightfieldHalfEdgeInfo" ; }
} LightfieldHalfEdgeInfo ;
typedef NoMathIOAttribute<LightfieldHalfEdgeInfo> HalfEdgeInfo ;
AttributeHandler<FRAME > m_frame ;
AttributeHandler<HalfEdgeInfo> halfEdgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
AttributeHandler<QuadricRGBfunctions<REAL> > quadricRGBfunctions ;
std::multimap<float,Dart> halfEdges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, FRAME >* m_frameApproximator ;
Approximator<PFP, RGBFUNCTIONS >* m_RGBfunctionsApproximator ;
void initHalfEdgeInfo(Dart d) ;
void updateHalfEdgeInfo(Dart d, bool recompute) ;
void computeHalfEdgeInfo(Dart d, HalfEdgeInfo& einfo) ;
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()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<FRAME>(VERTEX_ORBIT, "frame") ;
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo>(DART_ORBIT, "halfEdgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
quadricRGBfunctions = m.template addAttribute<QuadricRGBfunctions<REAL> >(EDGE_ORBIT, "quadricRGBfunctions") ;
}
~HalfEdgeSelector_Lightfield()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(quadricRGBfunctions) ;
this->m_map.removeAttribute(halfEdgeInfo) ;
}
SelectorType getType() { return S_Lightfield ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_Lightfield : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
typedef Geom::Matrix<3,3,REAL> MATRIX33 ;
typedef MATRIX33 FRAME ;
typedef Geom::Matrix<3,6,REAL> MATRIX36 ;
typedef MATRIX36 RGBFUNCTIONS ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "LightfieldEdgeInfo" ; }
} LightfieldEdgeInfo ;
typedef NoMathIOAttribute<LightfieldEdgeInfo> EdgeInfo ;
AttributeHandler<FRAME > m_frame ;
AttributeHandler<EdgeInfo> edgeInfo ;
AttributeHandler<Quadric<REAL> > quadric ;
AttributeHandler<QuadricRGBfunctions<REAL> > quadricRGBfunctions ;
Quadric<REAL> tmpQ ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, VEC3>* m_positionApproximator ;
Approximator<PFP, FRAME >* m_frameApproximator ;
Approximator<PFP, RGBFUNCTIONS >* m_RGBfunctionsApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_Lightfield(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
m_frame = m.template getAttribute<FRAME>(VERTEX_ORBIT, "frame") ;
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
quadric = m.template addAttribute<Quadric<REAL> >(VERTEX_ORBIT, "QEMquadric") ;
quadricRGBfunctions = m.template addAttribute<QuadricRGBfunctions<REAL> >(EDGE_ORBIT, "quadricRGBfunctions") ;
}
~EdgeSelector_Lightfield()
{
this->m_map.removeAttribute(quadric) ;
this->m_map.removeAttribute(quadricRGBfunctions) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_Lightfield ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_Curvature : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "CurvatureEdgeInfo" ; }
} CurvatureEdgeInfo ;
typedef NoMathIOAttribute<CurvatureEdgeInfo> EdgeInfo ;
typename PFP::TVEC3 normal ;
AttributeHandler<EdgeInfo> edgeInfo ;
typename PFP::TREAL k1 ;
typename PFP::TREAL k2 ;
typename PFP::TVEC3 K1 ;
typename PFP::TVEC3 K2 ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_Curvature(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
normal = m.template getAttribute<VEC3>(VERTEX_ORBIT, "normal") ;
if(!normal.isValid())
{
normal = m.template addAttribute<VEC3>(VERTEX_ORBIT, "normal") ;
Algo::Geometry::computeNormalVertices<PFP>(m, pos, normal) ;
}
k1 = m.template getAttribute<REAL>(VERTEX_ORBIT, "k1") ;
k2 = m.template getAttribute<REAL>(VERTEX_ORBIT, "k2") ;
K1 = m.template getAttribute<VEC3>(VERTEX_ORBIT, "K1") ;
K2 = m.template getAttribute<VEC3>(VERTEX_ORBIT, "K2") ;
// as all these attributes are computed simultaneously by computeCurvatureVertices
// one can assume that if one of them is not valid, the others must be created too
if(!k1.isValid())
{
k1 = m.template addAttribute<REAL>(VERTEX_ORBIT, "k1") ;
k2 = m.template addAttribute<REAL>(VERTEX_ORBIT, "k2") ;
K1 = m.template addAttribute<VEC3>(VERTEX_ORBIT, "K1") ;
K2 = m.template addAttribute<VEC3>(VERTEX_ORBIT, "K2") ;
Algo::Geometry::computeCurvatureVertices<PFP>(m, this->m_position, normal, k1, k2, K1, K2) ;
}
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
}
~EdgeSelector_Curvature()
{
this->m_map.removeAttribute(k1) ;
this->m_map.removeAttribute(k2) ;
this->m_map.removeAttribute(K1) ;
this->m_map.removeAttribute(K2) ;
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_Curvature ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
template <typename PFP>
class EdgeSelector_MinDetail : public EdgeSelector<PFP>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
private:
typedef struct
{
typename std::multimap<float,Dart>::iterator it ;
bool valid ;
static std::string CGoGNnameOfType() { return "MinDetailEdgeInfo" ; }
} MinDetailEdgeInfo ;
typedef NoMathIOAttribute<MinDetailEdgeInfo> EdgeInfo ;
AttributeHandler<EdgeInfo> edgeInfo ;
std::multimap<float,Dart> edges ;
typename std::multimap<float,Dart>::iterator cur ;
Approximator<PFP, typename PFP::VEC3>* m_positionApproximator ;
void initEdgeInfo(Dart d) ;
void updateEdgeInfo(Dart d, bool recompute) ;
void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
public:
EdgeSelector_MinDetail(MAP& m, typename PFP::TVEC3& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = SelectorTrue()) :
EdgeSelector<PFP>(m, pos, approx, select)
{
edgeInfo = m.template addAttribute<EdgeInfo>(EDGE_ORBIT, "edgeInfo") ;
}
~EdgeSelector_MinDetail()
{
this->m_map.removeAttribute(edgeInfo) ;
}
SelectorType getType() { return S_MinDetail ; }
bool init() ;
bool nextEdge(Dart& d) ;
void updateBeforeCollapse(Dart d) ;
void updateAfterCollapse(Dart d2, Dart dd2) ;
} ;
} // namespace Decimation
} // namespace Algo
} // namespace CGoGN
#include "Algo/Decimation/selector.hpp"
#endif
This diff is collapsed.
......@@ -22,7 +22,6 @@
* *
*******************************************************************************/
namespace CGoGN
{
......@@ -66,6 +65,8 @@ bool SharedMemSeg<DATA>::initMaster(int key)
m_ptr1 = reinterpret_cast<DATA*>(m_ptr + 2);
m_ptr2 = m_ptr1+1;
*m_ptr = 0;
return true ;
}
template<typename DATA>
......@@ -88,6 +89,8 @@ bool SharedMemSeg<DATA>::initSlave(int key)
m_ptr1 = reinterpret_cast<DATA*>(m_ptr + 2);
m_ptr2 = m_ptr1+1;
*(int*)m_ptr = 0;
return true ;
}
......
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