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.

mapCommon.h 8.01 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
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
/*******************************************************************************
* 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_COMMON__
#define __MAP_COMMON__

#include "Topology/generic/attributeHandler.h"
Sylvain Thery's avatar
Sylvain Thery committed
29
#include "Topology/generic/cells.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30
31
32
33

namespace CGoGN
{

Pierre Kraemer's avatar
Pierre Kraemer committed
34
template <typename MAP_IMPL>
Pierre Kraemer's avatar
Pierre Kraemer committed
35
36
37
38
class MapCommon : public MAP_IMPL
{
	typedef MAP_IMPL IMPL;

39
40
41
42
43
44
protected:
	// protected copy constructor to prevent the copy of map
	MapCommon(const MapCommon<MAP_IMPL>& m) : MAP_IMPL(m) {}
public:
	MapCommon() {}

Pierre Kraemer's avatar
Pierre Kraemer committed
45
46
47
48
49
50
51
52
53
54
55
	/****************************************
	 *           DARTS TRAVERSALS           *
	 ****************************************/
public:

	//! For an orbit of a given dimension, return the number of incident cells of an other given dimension
	/*! @param d a dart
	 */
	template <unsigned int ORBIT, unsigned int INCIDENT>
	unsigned int degree(Dart d) const;

Sylvain Thery's avatar
Sylvain Thery committed
56
	template <unsigned int ORBIT>
Pierre Kraemer's avatar
Pierre Kraemer committed
57
	bool sameOrbit(Cell<ORBIT> c1, Cell<ORBIT> c2, unsigned int thread = 0) const;
Sylvain Thery's avatar
Sylvain Thery committed
58

Pierre Kraemer's avatar
Pierre Kraemer committed
59
60
61
62
63
64
65
66
67
	/****************************************
	 *         EMBEDDING MANAGEMENT         *
	 ****************************************/

	/**
	 * get the cell index of the given dimension associated to dart d
	 * @return EMBNULL if the orbit of d is not attached to any cell
	 */
	template<unsigned int ORBIT>
Pierre Kraemer's avatar
Pierre Kraemer committed
68
	inline unsigned int getEmbedding(Cell<ORBIT> d) const;
Pierre Kraemer's avatar
Pierre Kraemer committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

	/**
	 * Set the cell index of the given dimension associated to dart d
	 */
	template <unsigned int ORBIT>
	void setDartEmbedding(Dart d, unsigned int emb) ;

	/**
	 * Set the cell index of the given dimension associated to dart d
	 * !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding) !!! WARNING !!!
	 */
	template <unsigned int ORBIT>
	void initDartEmbedding(Dart d, unsigned int emb) ;

	/**
	 * Copy the index of the cell associated to a dart over an other dart
	 * @param orbit the id of orbit embedding
	 * @param dest the dart to overwrite
	 * @param src the dart to copy
	 */
	template <unsigned int ORBIT>
	inline void copyDartEmbedding(Dart dest, Dart src) ;

	/****************************************
	 *         BOUNDARY MANAGEMENT          *
	 ****************************************/
95

Pierre Kraemer's avatar
Pierre Kraemer committed
96
97
98
	/**
	 * mark a dart as  belonging to boundary
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
99
	template <unsigned int DIM>
Pierre Kraemer's avatar
Pierre Kraemer committed
100
101
102
103
104
	void boundaryMark(Dart d) ;

	/**
	 * unmark a dart from the boundary
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
105
	template <unsigned int DIM>
Pierre Kraemer's avatar
Pierre Kraemer committed
106
107
	void boundaryUnmark(Dart d) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
108
109
110
111
112
113
	/**
	 * clear all boundary markers
	 */
	template<unsigned int DIM>
	void boundaryUnmarkAll() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
114
115
116
	/**
	 * test if a dart belong to the boundary
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
117
118
	template <unsigned int DIM>
	inline bool isBoundaryMarked(Dart d) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
119

Pierre Kraemer's avatar
Pierre Kraemer committed
120
121
122
	inline bool isBoundaryMarkedCurrent(Dart d) const ;

	inline bool isBoundaryMarked(unsigned int dim, Dart d) const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
123
124
125
126
127
128
129
130
131
132

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

	/**
	* Create an attribute for a given orbit
	* @param nameAttr attribute name
	* @return an AttributeHandler
	*/
133
134
	template <typename T, unsigned int ORBIT, typename MAP>
	inline AttributeHandler<T, ORBIT, MAP> addAttribute(const std::string& nameAttr = "") ;
Pierre Kraemer's avatar
Pierre Kraemer committed
135
136
137
138
139
140

	/**
	 * remove an attribute
	 * @param attr a handler to the attribute to remove
	 * @return true if remove succeed else false
	 */
141
142
	template <typename T, unsigned int ORBIT, typename MAP>
	inline bool removeAttribute(AttributeHandler<T, ORBIT, MAP>& attr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
143
144
145
146
147
148

	/**
	* search an attribute for a given orbit
	* @param nameAttr attribute name
	* @return an AttributeHandler
	*/
149
150
	template <typename T, unsigned int ORBIT, typename MAP>
	inline AttributeHandler<T, ORBIT, MAP> getAttribute(const std::string& nameAttr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
151

152
153
154
155
156
157
158
159
160
	/**
	 * @brief get attribute type code
	 * @param nameAttr name of attribute
	 * @return code enum
	 */
	template <unsigned int ORBIT>
	inline CGoGNCodeType getAttributeTypeCode(const std::string& nameAttr);


Pierre Kraemer's avatar
Pierre Kraemer committed
161
162
163
164
165
	/**
	* check if an attribute exist ( get, test if valid and add if necessary)
	* @param nameAttr attribute name
	* @return an AttributeHandler
	*/
166
167
	template <typename T, unsigned int ORBIT, typename MAP>
	AttributeHandler<T, ORBIT, MAP> checkAttribute(const std::string& nameAttr) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
168
169
170
171

	/**
	 * swap the content of two attributes (efficient, only swap pointers)
	 */
172
173
	template <typename T, unsigned int ORBIT, typename MAP>
	bool swapAttributes(AttributeHandler<T, ORBIT, MAP>& attr1, AttributeHandler<T, ORBIT, MAP>& attr2) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
174
175
176
177

	/**
	 * copy the content of src attribute to dst attribute
	 */
178
179
	template <typename T, unsigned int ORBIT, typename MAP>
	bool copyAttribute(AttributeHandler<T, ORBIT, MAP>& dst, AttributeHandler<T, ORBIT, MAP>& src) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
180

181
182
183
184
//	/**
//	 * get a DartAttribute to an involution of the map
//	 */
//	inline DartAttribute<Dart, MAP_IMPL> getInvolution(unsigned int i);
Pierre Kraemer's avatar
Pierre Kraemer committed
185

186
187
188
189
//	/**
//	 * get a DartAttribute to a permutation of the map
//	 */
//	inline DartAttribute<Dart, MAP_IMPL> getPermutation(unsigned int i);
Pierre Kraemer's avatar
Pierre Kraemer committed
190

191
192
193
194
//	/**
//	 * get a DartAttribute to a permutation of the map
//	 */
//	inline DartAttribute<Dart, MAP_IMPL> getPermutationInv(unsigned int i);
Pierre Kraemer's avatar
Pierre Kraemer committed
195
196
197
198
199

	/****************************************
	 *     QUICK TRAVERSAL MANAGEMENT       *
	 ****************************************/

200
	template <typename MAP, unsigned int ORBIT>
Pierre Kraemer's avatar
Pierre Kraemer committed
201
202
	void enableQuickTraversal() ;

203
	template <typename MAP, unsigned int ORBIT>
Pierre Kraemer's avatar
Pierre Kraemer committed
204
205
206
207
208
209
210
211
	void updateQuickTraversal() ;

	template <unsigned int ORBIT>
	const AttributeMultiVector<Dart>* getQuickTraversal() const;

	template <unsigned int ORBIT>
	void disableQuickTraversal() ;

212
	template <typename MAP, unsigned int ORBIT, unsigned int INCI>
Pierre Kraemer's avatar
Pierre Kraemer committed
213
214
	void enableQuickIncidentTraversal();

215
	template <typename MAP, unsigned int ORBIT, unsigned int INCI>
Pierre Kraemer's avatar
Pierre Kraemer committed
216
217
218
219
220
221
222
223
	void updateQuickIncidentTraversal();

	template <unsigned int ORBIT, unsigned int INCI>
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* getQuickIncidentTraversal() const;

	template <unsigned int ORBIT, unsigned int INCI>
	void disableQuickIncidentTraversal();

224
	template <typename MAP, unsigned int ORBIT, unsigned int ADJ>
Pierre Kraemer's avatar
Pierre Kraemer committed
225
226
	void enableQuickAdjacentTraversal();

227
	template <typename MAP, unsigned int ORBIT, unsigned int ADJ>
Pierre Kraemer's avatar
Pierre Kraemer committed
228
229
230
231
232
233
234
	void updateQuickAdjacentTraversal();

	template <unsigned int ORBIT, unsigned int INCI>
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* getQuickAdjacentTraversal() const;

	template <unsigned int ORBIT, unsigned int ADJ>
	void disableQuickAdjacentTraversal();
Pierre Kraemer's avatar
Pierre Kraemer committed
235
236
237
238
239
240
241
};

} //namespace CGoGN

#include "Topology/generic/mapCommon.hpp"

#endif