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.

ihm3.h 9.42 KB
Newer Older
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
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.u-strasbg.fr/                                         *
21
22
23
24
25
26
27
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__

28
#include "Topology/map/embeddedMap3.h"
29
30
31
32
33
34
35

namespace CGoGN
{

namespace Algo
{

untereiner's avatar
untereiner committed
36
namespace IHM
37
38
{

39
template<typename T> class AttributeHandler_IHM ;
40

41
class ImplicitHierarchicalMap3 : public EmbeddedMap3
42
{
43
	template<typename T> friend class AttributeHandler_IHM ;
44
45
46
47
48
49
50
51
52
53
54

public:
	unsigned int m_curLevel ;
	unsigned int m_maxLevel ;
	unsigned int m_edgeIdCount ;
	unsigned int m_faceIdCount;

	AttributeHandler<unsigned int> m_dartLevel ;
	AttributeHandler<unsigned int> m_edgeId ;
	AttributeHandler<unsigned int> m_faceId ;

Sylvain Thery's avatar
Sylvain Thery committed
55
	AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
56
57
58
59
60
61

public:
	ImplicitHierarchicalMap3() ;

	~ImplicitHierarchicalMap3() ;

62
63
64
65
66

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

69
70
71
72
	//!
	/*!
	 *
	 */
73
74
	void init() ;

75
76
77
	/*! @name Attributes Management
	 *  To handles Attributes for each level of an implicit 3-map
	 *************************************************************************/
78

79
80
81
82
83
84
85
	//@{
	//!
	/*!
	 *
	 */
	template <typename T>
	AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
untereiner's avatar
untereiner committed
86

87
88
89
90
91
92
93
	//!
	/*!
	 *
	 */
	template <typename T>
	AttributeHandler_IHM<T> getAttribute(unsigned int orbit, const std::string& nameAttr) ;
	//@}
untereiner's avatar
untereiner committed
94

95
96
97
	/*! @name Basic Topological Operators
	 *  Redefinition of the basic topological operators
	 *************************************************************************/
98

99
	//@{
100
101
102
103
104
105
	virtual Dart newDart() ;

	Dart phi1(Dart d) ;

	Dart phi_1(Dart d) ;

106
107
	Dart phi2(Dart d) ;

108
109
110
111
112
113
114
115
116
117
118
119
120
private:
	Dart phi2bis(Dart d) ;

public:
	Dart phi3(Dart d);

	Dart alpha0(Dart d);

	Dart alpha1(Dart d);

	Dart alpha2(Dart d);

	Dart alpha_2(Dart d);
121
	//@}
122

untereiner's avatar
untereiner committed
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
	/*! @name Topological Operators with Cells id management
	 *  Topological operations on Hierarchical Implicit 3-maps
	 *************************************************************************/

	//@{
	//!
	/*!
	 *
	 */
	Dart beginSplittingPath(Dart d, DartMarker& m);

	//!
	/*!
	 *
	 */
	void constructSplittingPath(Dart d, std::vector<Dart>& v, DartMarker& m);

140
141
142
143
144
145
	//!
	/*!
	 *
	 */
	void swapEdges(Dart d, Dart e);

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
//	//!
//	/*!
//	 *
//	 */
//	virtual Dart cutEdge(Dart d);
//
//	//!
//	/*!
//	 *
//	 */
//	virtual bool uncutEdge(Dart d);
//
//	//!
//	/*!
//	 *
//	 */
//	virtual void splitFace(Dart d, Dart e);
//
//	//!
//	/*!
//	 *
//	 */
//	virtual void sewVolumes(Dart d, Dart e, bool withBoundary = true);
//
//	//!
//	/*!
//	 *
//	 */
//	virtual void splitVolume(std::vector<Dart>& vd);
untereiner's avatar
untereiner committed
175
	//@}
176
177
178
179
180
181
182
183
184
185

	/*! @name Levels Management
	 *  Operations to manage the levels of an Implicit Hierarchical 3-map
	 *************************************************************************/

	//@{
	//!
	/*!
	 *
	 */
186
187
	unsigned int getCurrentLevel() ;

188
189
190
191
	//!
	/*!
	 *
	 */
192
193
	void setCurrentLevel(unsigned int l) ;

194
195
196
197
	//!
	/*!
	 *
	 */
198
199
	unsigned int getMaxLevel() ;

200
201
202
203
	//!
	/*!
	 *
	 */
204
205
	unsigned int getDartLevel(Dart d) ;

206
207
208
209
	//!
	/*!
	 *
	 */
210
	void setDartLevel(Dart d, unsigned int i) ;
211
	//@}
212

213
214
215
	/*! @name Id Management
	 * Operations to manage the ids of edges and faces
	 *************************************************************************/
216

217
218
219
	//@{
	//! Give a new unique id to all the edges of the map
	/*!
220
221
222
	 */
	void initEdgeId() ;

223
224
	//! Return the next available edge id
	/*!
225
226
227
	 */
	unsigned int getNewEdgeId() ;

228
229
	//! Return the id of the edge of d
	/*!
230
	 */
231
232
	unsigned int getEdgeId(Dart d) ;

233
234
	//! Set an edge id to all darts from an orbit of d
	/*!
235
	 */
236
237
	void setEdgeId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer
	void setEdgeId(Dart d, unsigned int i);
238

239
240
	//! Give a new unique id to all the faces of the map
	/*!
241
	 */
242
243
	void initFaceId() ;

244
245
	//! Return the next available face id
	/*!
246
247
248
	 */
	unsigned int getNewFaceId() ;

249
250
	//! Return the id of the face of d
	/*!
251
	 */
252
253
	unsigned int getFaceId(Dart d) ;

254
255
	//! Set a face id to all darts from an orbit of d
	/*!
256
	 */
257
	void setFaceId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer
258
	void setFaceId(unsigned int orbit, Dart d);
259
	//@}
260

261
262
263
	/*! @name Cells Information
	 * Operations to manage the cells informations :
	 *************************************************************************/
264

265
266
267
	//@{
	//! Return the level of insertion of the vertex of d
	/*!
268
269
270
	 */
	unsigned int vertexInsertionLevel(Dart d) ;

271
272
	//! Return the level of the edge of d in the current level map
	/*!
273
274
275
	 */
	unsigned int edgeLevel(Dart d) ;

276
277
	//! Return the level of the face of d in the current level map
	/*!
278
279
280
	 */
	unsigned int faceLevel(Dart d);

281
282
	//! Return the level of the volume of d in the current level map
	/*!
283
284
285
	 */
	unsigned int volumeLevel(Dart d);

286
287
	//! Return the oldest dart of the face of d in the current level map
	/*!
288
289
290
	 */
	Dart faceOldestDart(Dart d);

291
292
	//! Return the oldest dart of the volume of d in the current level map
	/*!
293
294
295
	 */
	Dart volumeOldestDart(Dart d);

296
297
298
	//! Return true if the edge of d in the current level map
	//! has already been subdivided to the next level
	/*!
299
300
301
	 */
	bool edgeIsSubdivided(Dart d) ;

302
303
304
	//! Return true if the face of d in the current level map
	//! has already been subdivided to the next level
	/*!
305
306
307
	 */
	bool faceIsSubdivided(Dart d) ;

308
309
310
	//! Return true if the volume of d in the current level map
	//! has already been subdivided to the next level
	/*!
311
312
	 */
	bool volumeIsSubdivided(Dart d);
untereiner's avatar
untereiner committed
313

314
315
316
317
318
	//! 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
	/*!
untereiner's avatar
untereiner committed
319
320
321
	 */
	bool edgeCanBeCoarsened(Dart d);

322
323
	//!
	/*!
324
325
326
	 */
	bool faceCanBeCoarsened(Dart d);

327
328
	//!
	/*!
untereiner's avatar
untereiner committed
329
330
331
	 */
	bool faceIsSubdividedOnce(Dart d);

332
333
	//!
	/*!
untereiner's avatar
untereiner committed
334
335
336
	 */
	bool volumeIsSubdividedOnce(Dart d);

337
338
	//!
	/*!
339
340
	 */
	bool neighborhoodLevelDiffersByOne(Dart d);
untereiner's avatar
untereiner committed
341

342
343
	//! wired !!!
	/*!
344
345
	 */
	bool coarsenNeighborhoodLevelDiffersByOne(Dart d);
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
	//@}

	/*! @name Cell Functors
	 * Redefition of the 3-maps map traversor
	 *************************************************************************/

	//@{
	virtual Dart begin() ;

	virtual Dart end() ;

	virtual void next(Dart& d) ;

	virtual bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0) ;

	virtual bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0) ;

	bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0);
	virtual bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0) ;

	bool foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread = 0);
	virtual bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0) ;

	virtual bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0) ;
untereiner's avatar
untereiner committed
370
371
372
373
374
375
376


	virtual bool foreach_dart_of_vertex2(Dart d, FunctorType& f, unsigned int thread = 0);

	virtual bool foreach_dart_of_edge2(Dart d, FunctorType& f, unsigned int thread = 0);

	virtual bool foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread = 0);
377
378
379
	//@}


380
381
} ;

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
template <typename T>
class AttributeHandler_IHM : public AttributeHandler<T>
{
public:
	typedef T DATA_TYPE ;

	AttributeHandler_IHM() : AttributeHandler<T>()
	{}

	AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T>(m, amv)
	{}

	AttributeMultiVector<T>* getDataVector() const
	{
		return AttributeHandler<T>::getDataVector() ;
	}

	bool isValid() const
	{
		return AttributeHandler<T>::isValid() ;
	}

	T& operator[](Dart d) ;

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

	T& operator[](unsigned int a)
	{
		return AttributeHandler<T>::operator[](a) ;
	}

	const T& operator[](unsigned int a) const
	{
		return AttributeHandler<T>::operator[](a) ;
	}
} ;
418
419
420
421
422
423
424
425
426
427

} //namespace IHM

} //namespace Algo

} //namespace CGoGN

#include "Algo/ImplicitHierarchicalMesh/ihm3.hpp"

#endif