edgeSelector.h 4.27 KB
Newer Older
1 2 3 4 5
#ifndef __EDGE_SELECTOR_VOLUMES_H__
#define __EDGE_SELECTOR_VOLUMES_H__

#include "Container/fakeAttribute.h"
#include "Algo/DecimationVolumes/selector.h"
6 7
#include "Utils/qem.h"
#include "Topology/generic/traversorCell.h"
8 9 10 11 12 13 14 15 16 17

namespace CGoGN
{

namespace Algo
{

namespace DecimationVolumes
{

18 19 20
/*
 * Map Order
 */
21
template <typename PFP>
22
class EdgeSelector_MapOrder : public Selector<PFP>
23 24 25 26
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
27
	typedef typename PFP::REAL REAL ;
28

29 30
private:
	Dart cur ;
31 32

public:
33
	EdgeSelector_MapOrder(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
untereiner's avatar
untereiner committed
34
		Selector<PFP>(m, pos, approx, select)
35
	{}
36 37 38 39 40 41 42 43 44 45 46
	~EdgeSelector_MapOrder()
	{}
	SelectorType getType() { return S_MapOrder ; }
	bool init() ;
	bool nextEdge(Dart& d) ;
	void updateBeforeCollapse(Dart d)
	{}
	void updateAfterCollapse(Dart d2, Dart dd2) ;

	void updateWithoutCollapse() { }
} ;
47 48


49 50 51
/*
 * Random
 */
52
template <typename PFP>
53
class EdgeSelector_Random : public Selector<PFP>
54 55
{
public:
56 57 58
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;
59 60

private:
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
	std::vector<Dart> darts ;
	unsigned int cur ;
	bool allSkipped ;

public:
	EdgeSelector_Random(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
		Selector<PFP>(m, pos, approx, select),
		cur(0),
		allSkipped(false)
	{}
	~EdgeSelector_Random()
	{}
	SelectorType getType() { return S_Random ; }
	bool init() ;
	bool nextEdge(Dart& d) ;
	void updateBeforeCollapse(Dart d2)
	{}
	void updateAfterCollapse(Dart d2, Dart dd2) ;
79

80 81
	void updateWithoutCollapse() { }
} ;
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
/*
 * Edge Length
 */
template <typename PFP>
class EdgeSelector_Length : public Selector<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 ;
102

103
	EdgeAttribute<EdgeInfo> edgeInfo ;
104

105 106
	std::multimap<float,Dart> edges ;
	typename std::multimap<float,Dart>::iterator cur ;
107

108 109 110
	void initEdgeInfo(Dart d) ;
	void updateEdgeInfo(Dart d, bool recompute) ;
	void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
111 112

public:
113 114
	EdgeSelector_Length(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
		Selector<PFP>(m, pos, approx, select)
115
	{
116
		edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
117
	}
118
	~EdgeSelector_Length()
119
	{
120
		this->m_map.removeAttribute(edgeInfo) ;
121
	}
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
	SelectorType getType() { return S_EdgeLength ; }
	bool init() ;
	bool nextEdge(Dart& d) ;
	void updateBeforeCollapse(Dart d) ;
	void updateAfterCollapse(Dart d2, Dart dd2) ;

	void updateWithoutCollapse() { }
} ;


/*
 * Progressive Tetrahedralizations [SG98]
 * Oliver Staadt && Markus Gross
 */
template <typename PFP>
class EdgeSelector_SG98 : public Selector<PFP>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;
143

144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
private:
	typedef	struct
	{
		typename std::multimap<float,Dart>::iterator it ;
		bool valid ;
		static std::string CGoGNnameOfType() { return "SG98edgeInfo" ; }
	} SG98edgeInfo ;
	typedef NoMathIOAttribute<SG98edgeInfo> EdgeInfo ;

	EdgeAttribute<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_SG98(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select) :
		Selector<PFP>(m, pos, approx, select)
	{}
	~EdgeSelector_SG98()
	{}
	SelectorType getType() { return S_SG98 ; }
	bool init() ;
	bool nextEdge(Dart& d) ;
	void updateBeforeCollapse(Dart d);
	void updateAfterCollapse(Dart d2, Dart dd2) ;

	void updateWithoutCollapse() { }
} ;
178

179 180


181 182 183 184 185 186 187 188

} //end namespace DecimationVolumes

} //end namespace Algo

} //end namespace CGoGN


untereiner's avatar
untereiner committed
189
#include "Algo/DecimationVolumes/edgeSelector.hpp"
190 191

#endif