traversor3.h 10.7 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-2011, 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.u-strasbg.fr/                                         *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __TRAVERSOR3_H__
#define __TRAVERSOR3_H__

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

namespace CGoGN
{
33
34
35
36
37
38
/**
 * class Marker for Traversor usefull to combine
 * several TraversorXY
 */
template <typename MAP, unsigned int ORBIT>
class MarkerForTraversor
Pierre Kraemer's avatar
Pierre Kraemer committed
39
40
{
private:
41
42
43
	MAP& m_map ;
	DartMarkerStore* m_dmark ;
	CellMarkerStore* m_cmark ;
Pierre Kraemer's avatar
Pierre Kraemer committed
44
public:
45
46
47
48
49
50
51
52
	MarkerForTraversor(MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
	~MarkerForTraversor();
	DartMarkerStore* dmark();
	CellMarkerStore* cmark();
	void mark(Dart d);
	void unmark(Dart d);
	bool isMarked(Dart d);
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
53

54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
 * Generic class Traversor (do not use directly)
 * Traverse all Y incident to X
 */
template <typename MAP, unsigned int ORBIT_X, unsigned int ORBIT_Y>
class Traversor3XY
{
private:
	MAP& m_map ;
	DartMarkerStore* m_dmark ;
	CellMarkerStore* m_cmark ;
	Dart m_current ;
	TraversorDartsOfOrbit<MAP> m_tradoo;
	bool m_allocated;
68
	bool m_first;
69
70
71
72
public:
	Traversor3XY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ;
	Traversor3XY(MAP& map, Dart dart, MarkerForTraversor<MAP,ORBIT_Y>& tmo, bool forceDartMarker = false, unsigned int thread = 0) ;
	~Traversor3XY();
Pierre Kraemer's avatar
Pierre Kraemer committed
73
74
75
76
77
	Dart begin() ;
	Dart end() ;
	Dart next() ;
} ;

78
79
80
81
82
83
84

/**
 * Generic class Traversor (do not use directly)
 * Traverse all X adjacent to X by an Y
 */
template <typename MAP, unsigned int ORB_X, unsigned int ORB_Y>
class Traversor3XXaY
Pierre Kraemer's avatar
Pierre Kraemer committed
85
86
{
private:
87
88
89
90
91
92
93
	MAP& m_map ;
	std::vector<Dart> m_vecDarts;
	std::vector<Dart>::iterator m_iter;
public:
	Traversor3XXaY(MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0);

	Dart begin();
Pierre Kraemer's avatar
Pierre Kraemer committed
94

95
96
97
98
99
100
101
102
103
104
105
106
107
108
	Dart end();

	Dart next();
};




/**
 * Traverse vertices incident to volume
 */
template <typename MAP>
class Traversor3WV: public Traversor3XY<MAP,VOLUME,VERTEX>
{
Pierre Kraemer's avatar
Pierre Kraemer committed
109
public:
110
111
	Traversor3WV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
112

113
114
115
116
117
118
119
120
121
/**
 * Traverse edges incident to volume
 */
template <typename MAP>
class Traversor3WE: public Traversor3XY<MAP,VOLUME,EDGE>
{
public:
	Traversor3WE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,EDGE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
122

123
124
125
/**
 * Traverse faces incident to volume
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
126
template <typename MAP>
127
class Traversor3WF: public Traversor3XY<MAP,VOLUME,FACE>
Pierre Kraemer's avatar
Pierre Kraemer committed
128
{
129
130
131
132
public:
	Traversor3WF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VOLUME,FACE>(m, dart, forceDartMarker, thread) {}
};

Pierre Kraemer's avatar
Pierre Kraemer committed
133

134
135
136
137
138
139
/**
 * Traverse vertices incident to face
 */
template <typename MAP>
class Traversor3FV: public Traversor3XY<MAP,FACE,VERTEX>
{
Pierre Kraemer's avatar
Pierre Kraemer committed
140
public:
141
142
	Traversor3FV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
143

144
145
146
147
148
149
150
151
152
/**
 * Traverse edges incident to face
 */
template <typename MAP>
class Traversor3FE: public Traversor3XY<MAP,FACE,EDGE>
{
public:
	Traversor3FE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,EDGE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
153

154
155
156
157
158
159
160
161
162
/**
 * Traverse volumes incident to face
 */
template <typename MAP>
class Traversor3FW: public Traversor3XY<MAP,FACE,VOLUME>
{
public:
	Traversor3FW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,FACE,VOLUME>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
163
164


165
166
167
168
169
170
171
172
173
/**
 * Traverse vertices incident to edge
 */
template <typename MAP>
class Traversor3EV: public Traversor3XY<MAP,EDGE,VERTEX>
{
public:
	Traversor3EV(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VERTEX>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
174

175
176
177
178
179
180
181
182
183
/**
 * Traverse faces incident to edge
 */
template <typename MAP>
class Traversor3EF: public Traversor3XY<MAP,EDGE,FACE>
{
public:
	Traversor3EF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,FACE>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
184

185
186
187
188
189
190
191
192
193
/**
 * Traverse volumes incident to edge
 */
template <typename MAP>
class Traversor3EW: public Traversor3XY<MAP,EDGE,VOLUME>
{
public:
	Traversor3EW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,EDGE,VOLUME>(m, dart, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
194
195


196
197
198
199
200
201

/**
 * Traverse edges incident to vertex
 */
template <typename MAP>
class Traversor3VE: public Traversor3XY<MAP,VERTEX,EDGE>
202
{
203
204
205
public:
	Traversor3VE(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,EDGE>(m, dart, forceDartMarker, thread)	{}
};
206

207
208
209
210
211
212
/**
 * Traverse faces incident to vertex
 */
template <typename MAP>
class Traversor3VF: public Traversor3XY<MAP,VERTEX,FACE>
{
213
public:
214
215
	Traversor3VF(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,FACE>(m, dart, forceDartMarker, thread)	{}
};
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/**
 * Traverse volumes incident to vertex
 */
template <typename MAP>
class Traversor3VW: public Traversor3XY<MAP,VERTEX,VOLUME>
{
public:
	Traversor3VW(MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP,VERTEX,VOLUME>(m, dart, forceDartMarker, thread)	{}
};



/**
 * Traverse vertices adjacent to a vertex by an edge
 */
template <typename MAP>
class Traversor3VVaE: public Traversor3XXaY<MAP,VERTEX,EDGE>
{
public:
	Traversor3VVaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,EDGE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse vertices adjacent to a vertex by a face
 */
template <typename MAP>
class Traversor3VVaF: public Traversor3XXaY<MAP,VERTEX,FACE>
{
public:
	Traversor3VVaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,FACE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse vertices adjacent to a vertex by a volume
 */
template <typename MAP>
class Traversor3VVaW: public Traversor3XXaY<MAP,VERTEX,VOLUME>
{
public:
	Traversor3VVaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VERTEX,VOLUME>(m, d, forceDartMarker, thread)	{}
};


/**
 * Traverse edges adjacent to an egde by a vertex
 */
template <typename MAP>
class Traversor3EEaV: public Traversor3XXaY<MAP,EDGE,VERTEX>
{
public:
	Traversor3EEaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VERTEX>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse edges adjacent to an egde by a face
 */
template <typename MAP>
class Traversor3EEaF: public Traversor3XXaY<MAP,EDGE,FACE>
{
public:
	Traversor3EEaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,FACE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse edges adjacent to an egde by a volume
 */
template <typename MAP>
class Traversor3EEaW: public Traversor3XXaY<MAP,EDGE,VOLUME>
{
public:
	Traversor3EEaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,EDGE,VOLUME>(m, d, forceDartMarker, thread)	{}
};


/**
 * Traverse faces adjacent to a face by a vertex
 */
template <typename MAP>
class Traversor3FFaV: public Traversor3XXaY<MAP,FACE,VERTEX>
{
public:
	Traversor3FFaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VERTEX>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse faces adjacent to a face by an edge
 */
template <typename MAP>
class Traversor3FFaE: public Traversor3XXaY<MAP,FACE,EDGE>
{
public:
	Traversor3FFaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,EDGE>(m, d, forceDartMarker, thread)	{}
};

/**
 * Traverse faces adjacent to a face by a volume
 */
template <typename MAP>
class Traversor3FFaW: public Traversor3XXaY<MAP,FACE,VOLUME>
{
public:
	Traversor3FFaW(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,FACE,VOLUME>(m, d, forceDartMarker, thread)	{}
};
Pierre Kraemer's avatar
Pierre Kraemer committed
320
321


322
323
324
/**
 * Traverse volumes adjacent to a volumee by a vertex
 */
325
template <typename MAP>
326
class Traversor3WWaV: public Traversor3XXaY<MAP,VOLUME,VERTEX>
327
328
{
public:
329
	Traversor3WWaV(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,VERTEX>(m, d, forceDartMarker, thread)	{}
330
331
};

332
333
334
/**
 * Traverse volumes adjacent to a volumee by an edge
 */
335
template <typename MAP>
336
class Traversor3WWaE: public Traversor3XXaY<MAP,VOLUME,EDGE>
337
338
{
public:
339
	Traversor3WWaE(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,EDGE>(m, d, forceDartMarker, thread)	{}
340
341
};

342
343
344
/**
 * Traverse volumes adjacent to a volumee by a face
 */
345
template <typename MAP>
346
class Traversor3WWaF: public Traversor3XXaY<MAP,VOLUME,FACE>
347
348
{
public:
349
	Traversor3WWaF(MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP,VOLUME,FACE>(m, d, forceDartMarker, thread)	{}
350
351
};

Pierre Kraemer's avatar
Pierre Kraemer committed
352
353
354
355
356
357

} // namespace CGoGN

#include "Topology/generic/traversor3.hpp"

#endif