ihm2.h 8.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
* Web site: http://cgogn.unistra.fr/                                           *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __IMPLICIT_HIERARCHICAL_MAP2__
#define __IMPLICIT_HIERARCHICAL_MAP2__

#include "Topology/map/embeddedMap2.h"

Sylvain Thery's avatar
Sylvain Thery committed
30
#include "Topology/dll.h"
Sylvain Thery's avatar
Sylvain Thery committed
31

32
33
34
35
36
namespace CGoGN
{

template<typename T, unsigned int ORBIT> class AttributeHandler_IHM ;

Pierre Kraemer's avatar
Pierre Kraemer committed
37

Sylvain Thery's avatar
Sylvain Thery committed
38
class CGoGN_TOPO_API ImplicitHierarchicalMap2 : public EmbeddedMap2
39
40
{
	template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
41
	typedef EmbeddedMap2::TOPO_MAP TOPO_MAP;
42
43
44
45
46
47

private:
	unsigned int m_curLevel ;
	unsigned int m_maxLevel ;
	unsigned int m_idCount ;

48
49
	DartAttribute<unsigned int, ImplicitHierarchicalMap2> m_dartLevel ;
	DartAttribute<unsigned int, ImplicitHierarchicalMap2> m_edgeId ;
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

	AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;

public:
	ImplicitHierarchicalMap2() ;

	~ImplicitHierarchicalMap2() ;

	//!
	/*!
	 *
	 */
	void update_topo_shortcuts();

	//!
	/*!
	 *
	 */
68
	void initImplicitProperties();
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

	/**
	 * clear the map
	 * @param remove attrib remove attribute (not only clear the content)
	 */
	void clear(bool removeAttrib);

	/***************************************************
	 *             ATTRIBUTES MANAGEMENT               *
	 ***************************************************/

	template <typename T, unsigned int ORBIT>
	AttributeHandler_IHM<T, ORBIT> addAttribute(const std::string& nameAttr) ;

	template <typename T, unsigned int ORBIT>
	AttributeHandler_IHM<T, ORBIT> getAttribute(const std::string& nameAttr) ;

	/***************************************************
	 *                 MAP TRAVERSAL                   *
	 ***************************************************/

90
	inline Dart newDart() ;
91

92
	inline Dart phi1(Dart d) const ;
93

94
	inline Dart phi_1(Dart d) const ;
95

96
	inline Dart phi2(Dart d) const ;
97

98
	inline Dart alpha0(Dart d) const ;
99

100
	inline Dart alpha1(Dart d) const ;
101

102
	inline Dart alpha_1(Dart d) const ;
103

104
	inline Dart begin() const ;
105

106
	inline Dart end() const ;
107

108
	inline void next(Dart& d) const ;
109

110
//	template <unsigned int ORBIT, typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
111
//	void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC f) const ;
112
	template <unsigned int ORBIT, typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
113
	void foreach_dart_of_orbit(Cell<ORBIT> c, const FUNC& f) const ;
114

115
	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
116
	void foreach_dart_of_vertex(Dart d, FUNC& f) const;
117

118
	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
119
	void foreach_dart_of_edge(Dart d, FUNC& f) const ;
120

121
	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
122
	void foreach_dart_of_oriented_face(Dart d, FUNC& f) const ;
123

124
	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
125
	void foreach_dart_of_face(Dart d, FUNC& f)  const;
126
127

	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
128
	void foreach_dart_of_oriented_volume(Dart d, FUNC& f) const ;
129
130

	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
131
	void foreach_dart_of_volume(Dart d, FUNC& f) const ;
132
133

	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
134
	void foreach_dart_of_vertex1(Dart d, FUNC& f) const;
135
136

	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
137
	void foreach_dart_of_edge1(Dart d, FUNC& f) const;
138
139

	template <typename FUNC>
Sylvain Thery's avatar
Sylvain Thery committed
140
	void foreach_dart_of_cc(Dart d, FUNC& f) const ;
141
142
143
144
145
146
147

	/***************************************************
	 *               MAP MANIPULATION                  *
	 ***************************************************/

	void splitFace(Dart d, Dart e) ;

Lionel Untereiner's avatar
Lionel Untereiner committed
148
	unsigned int vertexDegree(Dart d);
149

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
	/***************************************************
	 *              LEVELS MANAGEMENT                  *
	 ***************************************************/

	unsigned int getCurrentLevel() ;

	void setCurrentLevel(unsigned int l) ;

	void incCurrentLevel();

	void decCurrentLevel();

	unsigned int getMaxLevel() ;

	unsigned int getDartLevel(Dart d) ;

	void setDartLevel(Dart d, unsigned int i) ;

168
169
	void setMaxLevel(unsigned int l);

170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
	/***************************************************
	 *             EDGE ID MANAGEMENT                  *
	 ***************************************************/

	/**
	 * Give a new unique id to all the edges of the map
	 */
	void initEdgeId() ;

	/**
	 * Return the next available edge id
	 */
	unsigned int getNewEdgeId() ;

	unsigned int getEdgeId(Dart d) ;

	void setEdgeId(Dart d, unsigned int i) ;

188
189
190
191
	unsigned int getTriRefinementEdgeId(Dart d);

	unsigned int getQuadRefinementEdgeId(Dart d);

192
193
194
195
	/***************************************************
	 *               CELLS INFORMATION                 *
	 ***************************************************/

196
197
198
199
200
201
202
    /**
     * @brief faceDegree
     * @param d
     * @return
     */
    unsigned int faceDegree(Dart d);

203
204
205
206
207
	/**
	 * Return the level of insertion of the vertex of d
	 */
	unsigned int vertexInsertionLevel(Dart d) ;

208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
//	/**
//	 * Return the level of the edge of d in the current level map
//	 */
//	unsigned int edgeLevel(Dart d) ;

//	/**
//	 * Return the level of the face of d in the current level map
//	 */
//	unsigned int faceLevel(Dart d) ;

//	/**
//	 * Given the face of d in the current level map,
//	 * return a level 0 dart of its origin face
//	 */
//	Dart faceOrigin(Dart d) ;

//	/**
//	 * Return the oldest dart of the face of d in the current level map
//	 */
//	Dart faceOldestDart(Dart d) ;

//	/**
//	 * Return true if the edge of d in the current level map
//	 * has already been subdivided to the next level
//	 */
//	bool edgeIsSubdivided(Dart d) ;

//	/**
//	 * Return true if the edge of d in the current level map
//	 * is subdivided to the next level,
//	 * none of its resulting edges is in turn subdivided to the next level
//	 * and the middle vertex is of degree 2
//	 */
//	bool edgeCanBeCoarsened(Dart d) ;

//	/**
//	 * Return true if the face of d in the current level map
//	 * has already been subdivided to the next level
//	 */
//	bool faceIsSubdivided(Dart d) ;

//	/**
//	 * Return true if the face of d in the current level map
//	 * is subdivided to the next level
//	 * and none of its resulting faces is in turn subdivided to the next level
//	 */
//	bool faceIsSubdividedOnce(Dart d) ;
255
256
257
} ;

template <typename T, unsigned int ORBIT>
258
class AttributeHandler_IHM : public AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>
259
260
261
262
{
public:
	typedef T DATA_TYPE ;

263
	AttributeHandler_IHM() : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>()
264
265
	{}

266
	AttributeHandler_IHM(ImplicitHierarchicalMap2* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>(m, amv)
267
268
269
270
	{}

	AttributeMultiVector<T>* getDataVector() const
	{
271
		return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>::getDataVector() ;
272
273
274
275
	}

	bool isValid() const
	{
276
		return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>::isValid() ;
277
278
279
280
281
282
283
284
	}

	T& operator[](Dart d) ;

	const T& operator[](Dart d) const ;

	T& operator[](unsigned int a)
	{
285
		return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>::operator[](a) ;
286
287
288
289
	}

	const T& operator[](unsigned int a) const
	{
290
		return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap2>::operator[](a) ;
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
	}
} ;

template <typename T>
class VertexAttribute_IHM : public AttributeHandler_IHM<T, VERTEX>
{
public:
	VertexAttribute_IHM() : AttributeHandler_IHM<T, VERTEX>() {}
	VertexAttribute_IHM(const AttributeHandler_IHM<T, VERTEX>& ah) : AttributeHandler_IHM<T, VERTEX>(ah) {}
	VertexAttribute_IHM<T>& operator=(const AttributeHandler_IHM<T, VERTEX>& ah) { this->AttributeHandler_IHM<T, VERTEX>::operator=(ah); return *this; }
};


} //namespace CGoGN

#include "Topology/ihmap/ihm2.hpp"

#endif