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.

edgeSelector.h 4.28 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

namespace CGoGN
{

namespace Algo
{

15
16
17
namespace Volume
{

18
19
20
namespace DecimationVolumes
{

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

32
33
private:
	Dart cur ;
34
35

public:
36
37
	EdgeSelector_MapOrder(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
		Selector<PFP>(m, pos, approx)
38
	{}
39
40
41
42
43
44
45
46
47
48
49
	~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() { }
} ;
50
51


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

private:
64
65
66
67
68
	std::vector<Dart> darts ;
	unsigned int cur ;
	bool allSkipped ;

public:
69
70
	EdgeSelector_Random(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
		Selector<PFP>(m, pos, approx),
71
72
73
74
75
76
77
78
79
80
81
		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) ;
82

83
84
	void updateWithoutCollapse() { }
} ;
85

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * 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 ;
105

106
	EdgeAttribute<EdgeInfo> edgeInfo ;
107

108
109
	std::multimap<float,Dart> edges ;
	typename std::multimap<float,Dart>::iterator cur ;
110

111
112
113
	void initEdgeInfo(Dart d) ;
	void updateEdgeInfo(Dart d, bool recompute) ;
	void computeEdgeInfo(Dart d, EdgeInfo& einfo) ;
114
115

public:
116
117
	EdgeSelector_Length(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
		Selector<PFP>(m, pos, approx)
118
	{
119
		edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
120
	}
121
	~EdgeSelector_Length()
122
	{
123
		this->m_map.removeAttribute(edgeInfo) ;
124
	}
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	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 ;
146

147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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:
168
169
	EdgeSelector_SG98(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
		Selector<PFP>(m, pos, approx), m_positionApproximator(NULL)
untereiner's avatar
untereiner committed
170
171
172
	{
		edgeInfo = m.template addAttribute<EdgeInfo, EDGE>("edgeInfo") ;
	}
173
	~EdgeSelector_SG98()
untereiner's avatar
untereiner committed
174
175
176
	{
		this->m_map.removeAttribute(edgeInfo) ;
	}
177
178
179
180
181
182
183
184
	SelectorType getType() { return S_SG98 ; }
	bool init() ;
	bool nextEdge(Dart& d) ;
	void updateBeforeCollapse(Dart d);
	void updateAfterCollapse(Dart d2, Dart dd2) ;

	void updateWithoutCollapse() { }
} ;
185

186
187


188
189
190

} //end namespace DecimationVolumes

191
192
}

193
194
195
196
197
} //end namespace Algo

} //end namespace CGoGN


untereiner's avatar
untereiner committed
198
#include "Algo/DecimationVolumes/edgeSelector.hpp"
199
200

#endif