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.

mapMulti.h 7.92 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
/*******************************************************************************
* 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 __MAP_MULTI__
#define __MAP_MULTI__

Pierre Kraemer's avatar
Pierre Kraemer committed
28
#include "Topology/generic/genericmap.h"
29
30
31
32

namespace CGoGN
{

Pierre Kraemer's avatar
Pierre Kraemer committed
33
class MapMulti : public GenericMap
34
{
35
	template<typename MAP> friend class DartMarkerTmpl ;
Pierre Kraemer's avatar
Pierre Kraemer committed
36
	template<typename MAP> friend class DartMarkerStore ;
37

38
39
40
41
42
public:
	MapMulti()
	{
		initMR();
	}
43

Pierre Kraemer's avatar
Pierre Kraemer committed
44
	inline virtual void clear(bool removeAttrib);
45
46

protected:
47
48
49
	// protected copy constructor to prevent the copy of map
	MapMulti(const MapMulti& m): GenericMap(m) {}

Pierre Kraemer's avatar
Pierre Kraemer committed
50
	std::vector<AttributeMultiVector<Dart>*> m_involution;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
	std::vector<AttributeMultiVector<Dart>*> m_permutation;
	std::vector<AttributeMultiVector<Dart>*> m_permutation_inv;

	/**
	 * container for multiresolution darts
	 */
	AttributeContainer m_mrattribs ;

	/**
	 * pointers to attributes of m_mrattribs that store indices of m_attribs[DART]
	 * (one for each level)
	 */
	std::vector< AttributeMultiVector<unsigned int>* > m_mrDarts ;

	/**
	 * pointer to attribute of m_mrattribs that stores darts insertion levels
	 */
	AttributeMultiVector<unsigned int>* m_mrLevels ;

	/**
	 * vector that stores the number of darts inserted on each resolution level
	 */
	std::vector<unsigned int> m_mrNbDarts ;

	/**
	 * current level in multiresolution map
	 */
	unsigned int m_mrCurrentLevel ;

	/**
	 * stack for current level temporary storage
	 */
	std::vector<unsigned int> m_mrLevelStack ;

	/****************************************
	 *          DARTS MANAGEMENT            *
	 ****************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
88

Pierre Kraemer's avatar
Pierre Kraemer committed
89
	inline Dart newDart();
90
91
92

	inline virtual void deleteDart(Dart d);

Pierre Kraemer's avatar
Pierre Kraemer committed
93
public:
Pierre Kraemer's avatar
Pierre Kraemer committed
94
95
96
	inline unsigned int dartIndex(Dart d) const;

	inline Dart indexDart(unsigned int index) const;
97
98
99
100

	/**
	 * get the number of darts inserted in the given leveldart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
101
	inline unsigned int getNbInsertedDarts(unsigned int level) const;
102
103
104
105

	/**
	 * get the number of darts that define the map of the given leveldart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	inline unsigned int getNbDarts(unsigned int level) const;
107
108
109
110

	/**
	 * @return the number of darts in the map
	 */
111
	inline unsigned int getNbDarts() const;
112

113
114
	inline AttributeContainer& getDartContainer();

115
116
117
	/**
	 * get the insertion level of a dart
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
118
	inline unsigned int getDartLevel(Dart d) const;
119

120
protected:
121
122
123
	/**
	 *
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
124
	inline void incDartLevel(Dart d) const ;
125
126
127
128

	/**
	 * duplicate a dart starting from current level
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
129
	inline void duplicateDart(Dart d) ;
130

Pierre Kraemer's avatar
Pierre Kraemer committed
131
	inline void duplicateDartAtOneLevel(Dart d, unsigned int level) ;
132
133
134
135
136
137
138
139

	/****************************************
	 *        RELATIONS MANAGEMENT          *
	 ****************************************/

	inline void addInvolution();
	inline void addPermutation();

Pierre Kraemer's avatar
Pierre Kraemer committed
140
141
142
143
	inline AttributeMultiVector<Dart>* getInvolutionAttribute(unsigned int i);
	inline AttributeMultiVector<Dart>* getPermutationAttribute(unsigned int i);
	inline AttributeMultiVector<Dart>* getPermutationInvAttribute(unsigned int i);

Pierre Kraemer's avatar
Pierre Kraemer committed
144
145
146
	virtual unsigned int getNbInvolutions() const = 0;
	virtual unsigned int getNbPermutations() const = 0;

147
148
149
150
151
152
153
154
155
156
	template <int I>
	inline Dart getInvolution(Dart d) const;

	template <int I>
	inline Dart getPermutation(Dart d) const;

	template <int I>
	inline Dart getPermutationInv(Dart d) const;

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
157
	inline void involutionSew(Dart d, Dart e);
158
159

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
160
	inline void involutionUnsew(Dart d);
161

162
	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
163
	inline void permutationSew(Dart d, Dart e);
164
165

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
166
	inline void permutationUnsew(Dart d);
167

Sylvain Thery's avatar
Sylvain Thery committed
168
	virtual void compactTopo();
169

170
171
172
	/****************************************
	 *      MR CONTAINER MANAGEMENT         *
	 ****************************************/
173
public:
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
	/**
	 * get the MR attribute container
	 */
	AttributeContainer& getMRAttributeContainer() ;

	/**
	 * get the MR attribute container
	 */
	AttributeMultiVector<unsigned int>* getMRDartAttributeVector(unsigned int level) ;
	AttributeMultiVector<unsigned int>* getMRLevelAttributeVector();

	/****************************************
	 *     RESOLUTION LEVELS MANAGEMENT     *
	 ****************************************/

	void printMR() ;

	/**
	 * initialize the multiresolution attribute container
	 */
	void initMR() ;

	/**
	 * get the current resolution level
	 */
	unsigned int getCurrentLevel() ;

	/**
	 * set the current resolution level
	 */
	void setCurrentLevel(unsigned int l) ;

	/**
	 * increment the current resolution level
	 */
	void incCurrentLevel() ;

	/**
	 * decrement the current resolution level
	 */
	void decCurrentLevel() ;

	/**
	 * store current resolution level on a stack
	 */
	void pushLevel() ;

	/**
	 * set as current the resolution level of the top of the stack
	 */
	void popLevel() ;

	/**
	 * get the maximum resolution level
	 */
	unsigned int getMaxLevel() ;

	/**
	 * add a resolution level in the back of the level table
	 */
	void addLevelBack() ;

	/**
	 * add a resolution level in the front of the level table
	 */
	void addLevelFront();

	/**
	 * remove last resolution level
	 */
	void removeLevelBack() ;

	/**
	 * remove first resolution level
	 */
	void removeLevelFront();

	/**
	 * copy MRDarts from level-1 to level
	 */
	void copyLevel(unsigned int level);

	/**
	 * duplicate darts from level-1 to level
	 */
	void duplicateDarts(unsigned int newlevel);

	/****************************************
	 *           DARTS TRAVERSALS           *
	 ****************************************/

	/**
	 * Begin of map
	 * @return the first dart of the map
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
269
	inline Dart begin() const;
270
271
272
273
274

	/**
	 * End of map
	 * @return the end iterator (next of last) of the map
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
275
	inline Dart end() const;
276
277
278
279
280
281

	/**
	 * allow to go from a dart to the next
	 * in the order of storage
	 * @param d reference to the dart to be modified
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
282
283
284
285
	inline void next(Dart& d) const;

	/**
	 * Apply a functor on each dart of the map
Pierre Kraemer's avatar
Pierre Kraemer committed
286
	 * @param f a callable taking a Dart parameter
Pierre Kraemer's avatar
Pierre Kraemer committed
287
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
288
289
290
291
292
	template <typename FUNC>
	void foreach_dart(FUNC f) ;

	template <typename FUNC>
	void foreach_dart(FUNC& f) ;
293
294
295
296
297
298
299
300
301
302

	/****************************************
	 *             SAVE & LOAD              *
	 ****************************************/

	bool saveMapBin(const std::string& filename) const;

	bool loadMapBin(const std::string& filename);

	bool copyFrom(const GenericMap& map);
Pierre Kraemer's avatar
Pierre Kraemer committed
303
304

	void restore_topo_shortcuts();
305
} ;
306
307
308

} //namespace CGoGN

309
#include "Topology/generic/mapImpl/mapMulti.hpp"
310

311
#endif