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.

ihm.h 7.5 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __IMPLICIT_HIERARCHICAL_MAP__
#define __IMPLICIT_HIERARCHICAL_MAP__

28
#include "Topology/map/embeddedMap2.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
29
30
31
32
33
34

namespace CGoGN
{

namespace Algo
{
35
36
namespace Surface
{
Pierre Kraemer's avatar
Pierre Kraemer committed
37
38
39
namespace IHM
{

Pierre Kraemer's avatar
Pierre Kraemer committed
40
template<typename T, unsigned int ORBIT> class AttributeHandler_IHM ;
Pierre Kraemer's avatar
Pierre Kraemer committed
41

42
class ImplicitHierarchicalMap : public EmbeddedMap2
Pierre Kraemer's avatar
Pierre Kraemer committed
43
{
Pierre Kraemer's avatar
Pierre Kraemer committed
44
	template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
Pierre Kraemer's avatar
Pierre Kraemer committed
45
46
47
48
49
50

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

51
52
	DartAttribute<unsigned int> m_dartLevel ;
	DartAttribute<unsigned int> m_edgeId ;
Pierre Kraemer's avatar
Pierre Kraemer committed
53

54
	AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
Pierre Kraemer's avatar
Pierre Kraemer committed
55
56
57
58
59
60

public:
	ImplicitHierarchicalMap() ;

	~ImplicitHierarchicalMap() ;

61
62
	static const unsigned int DIMENSION = 2 ;

untereiner's avatar
untereiner committed
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	//!
	/*!
	 *
	 */
	void update_topo_shortcuts();


	void initImplicitProperties() ;

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

Pierre Kraemer's avatar
Pierre Kraemer committed
78
79
80
81
82

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

Pierre Kraemer's avatar
Pierre Kraemer committed
83
84
	template <typename T, unsigned int ORBIT>
	AttributeHandler_IHM<T, ORBIT> addAttribute(const std::string& nameAttr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
85

Pierre Kraemer's avatar
Pierre Kraemer committed
86
87
	template <typename T, unsigned int ORBIT>
	AttributeHandler_IHM<T, ORBIT> getAttribute(const std::string& nameAttr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
88

Pierre Kraemer's avatar
Pierre Kraemer committed
89
90
91
92
93
94
95
96
97
98
99
100
	/***************************************************
	 *                 MAP TRAVERSAL                   *
	 ***************************************************/

	virtual Dart newDart() ;

	Dart phi1(Dart d) ;

	Dart phi_1(Dart d) ;

	Dart phi2(Dart d) ;

101
	Dart alpha0(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
102

103
	Dart alpha1(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
104

105
	Dart alpha_1(Dart d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
106

107
	virtual Dart begin() const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
108

109
	virtual Dart end() const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
110

111
	virtual void next(Dart& d) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
112

113
	virtual bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
114

115
	virtual bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
116

117
	virtual bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0) ;
118
	virtual bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
119

120
	virtual bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread = 0) ;
121
	virtual bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
122

123
	virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
124

125
126
127
128
129
130
	/***************************************************
	 *               MAP MANIPULATION                  *
	 ***************************************************/

	void splitFace(Dart d, Dart e) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	/***************************************************
	 *              LEVELS MANAGEMENT                  *
	 ***************************************************/

	unsigned int getCurrentLevel() ;

	void setCurrentLevel(unsigned int l) ;

	unsigned int getMaxLevel() ;

	unsigned int getDartLevel(Dart d) ;

	void setDartLevel(Dart d, unsigned int i) ;

145

Pierre Kraemer's avatar
Pierre Kraemer committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	/***************************************************
	 *             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) ;

164
165
	unsigned int getMaxEdgeId();

Pierre Kraemer's avatar
Pierre Kraemer committed
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
	/***************************************************
	 *               CELLS INFORMATION                 *
	 ***************************************************/

	/**
	 * Return the level of insertion of the vertex of d
	 */
	unsigned int vertexInsertionLevel(Dart d) ;

	/**
	 * 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) ;

185
186
187
188
189
190
	/**
	 * Given the face of d in the current level map,
	 * return a level 0 dart of its origin face
	 */
	Dart faceOrigin(Dart d) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
191
192
193
194
195
196
197
198
199
200
201
	/**
	 * 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) ;

202
203
204
205
206
207
208
209
	/**
	 * 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) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
210
211
212
213
214
215
216
217
218
	/**
	 * 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
219
	 * and none of its resulting faces is in turn subdivided to the next level
Pierre Kraemer's avatar
Pierre Kraemer committed
220
221
222
223
	 */
	bool faceIsSubdividedOnce(Dart d) ;
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
224
225
template <typename T, unsigned int ORBIT>
class AttributeHandler_IHM : public AttributeHandler<T, ORBIT>
Pierre Kraemer's avatar
Pierre Kraemer committed
226
227
228
229
{
public:
	typedef T DATA_TYPE ;

Pierre Kraemer's avatar
Pierre Kraemer committed
230
	AttributeHandler_IHM() : AttributeHandler<T, ORBIT>()
Pierre Kraemer's avatar
Pierre Kraemer committed
231
232
	{}

Pierre Kraemer's avatar
Pierre Kraemer committed
233
	AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, ORBIT>(m, amv)
Pierre Kraemer's avatar
Pierre Kraemer committed
234
235
	{}

236
	AttributeMultiVector<T>* getDataVector() const
Pierre Kraemer's avatar
Pierre Kraemer committed
237
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
238
		return AttributeHandler<T, ORBIT>::getDataVector() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
239
240
241
242
	}

	bool isValid() const
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
243
		return AttributeHandler<T, ORBIT>::isValid() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
244
245
246
247
248
249
250
251
	}

	T& operator[](Dart d) ;

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

	T& operator[](unsigned int a)
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
252
		return AttributeHandler<T, ORBIT>::operator[](a) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
253
254
255
256
	}

	const T& operator[](unsigned int a) const
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
257
		return AttributeHandler<T, ORBIT>::operator[](a) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
258
259
260
261
	}
} ;

} //namespace IHM
262
} // Surface
Pierre Kraemer's avatar
Pierre Kraemer committed
263
264
265
266
267
268
269
} //namespace Algo

} //namespace CGoGN

#include "Algo/ImplicitHierarchicalMesh/ihm.hpp"

#endif