traversor3.h 11.4 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 __TRAVERSOR3_H__
#define __TRAVERSOR3_H__

28 29
#include "Topology/generic/dart.h"
#include "Topology/generic/cellmarker.h"
30 31 32
#include "Topology/generic/traversor/traversorCell.h"
//#include "Topology/generic/traversor/traversorGen.h"
#include "Topology/generic/traversor/traversorDoO.h"
33

Pierre Kraemer's avatar
Pierre Kraemer committed
34 35
namespace CGoGN
{
Pierre Kraemer's avatar
Pierre Kraemer committed
36

37 38 39 40
/**
 * class Marker for Traversor usefull to combine
 * several TraversorXY
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
41
template <typename MAP, unsigned int ORBIT>
42
class MarkerForTraversor
Pierre Kraemer's avatar
Pierre Kraemer committed
43 44
{
private:
Sylvain Thery's avatar
Sylvain Thery committed
45
	const MAP& m_map ;
Pierre Kraemer's avatar
Pierre Kraemer committed
46 47
	DartMarkerStore<MAP>* m_dmark ;
	CellMarkerStore<MAP, ORBIT>* m_cmark ;
Pierre Kraemer's avatar
Pierre Kraemer committed
48
public:
Sylvain Thery's avatar
Sylvain Thery committed
49
	MarkerForTraversor(const MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
50
	~MarkerForTraversor();
Pierre Kraemer's avatar
Pierre Kraemer committed
51 52 53

	DartMarkerStore<MAP>* dmark();
	CellMarkerStore<MAP, ORBIT>* cmark();
54 55 56 57
	void mark(Dart d);
	void unmark(Dart d);
	bool isMarked(Dart d);
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
58

59 60 61 62
/**
 * Generic class Traversor (do not use directly)
 * Traverse all Y incident to X
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
63
template <typename MAP, unsigned int ORBX, unsigned int ORBY>
Sylvain Thery's avatar
Sylvain Thery committed
64
class Traversor3XY//: public Traversor<MAP>
65 66
{
private:
Sylvain Thery's avatar
Sylvain Thery committed
67
	const MAP& m_map ;
Pierre Kraemer's avatar
Pierre Kraemer committed
68 69
	DartMarkerStore<MAP>* m_dmark ;
	CellMarkerStore<MAP, ORBY>* m_cmark ;
70
	Dart m_current ;
Pierre Kraemer's avatar
Pierre Kraemer committed
71
	TraversorDartsOfOrbit<MAP, ORBX> m_tradoo;
Sylvain Thery's avatar
Sylvain Thery committed
72

Sylvain Thery's avatar
Sylvain Thery committed
73 74
	const std::vector<Dart>* m_QLT;
	std::vector<Dart>::const_iterator m_ItDarts;
Sylvain Thery's avatar
Sylvain Thery committed
75

76
	bool m_allocated;
77
	bool m_first;
78
public:
Sylvain Thery's avatar
Sylvain Thery committed
79 80
	Traversor3XY(const MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) ;
	Traversor3XY(const MAP& map, Dart dart, MarkerForTraversor<MAP, ORBY>& tmo, bool forceDartMarker = false, unsigned int thread = 0) ;
81
	~Traversor3XY();
Pierre Kraemer's avatar
Pierre Kraemer committed
82 83 84 85 86
	Dart begin() ;
	Dart end() ;
	Dart next() ;
} ;

87 88 89 90
/**
 * Generic class Traversor (do not use directly)
 * Traverse all X adjacent to X by an Y
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
91
template <typename MAP, unsigned int ORBX, unsigned int ORBY>
Sylvain Thery's avatar
Sylvain Thery committed
92
class Traversor3XXaY//: public Traversor<MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
93 94
{
private:
Sylvain Thery's avatar
Sylvain Thery committed
95
	const MAP& m_map ;
96 97
	std::vector<Dart> m_vecDarts;
	std::vector<Dart>::iterator m_iter;
Sylvain Thery's avatar
Sylvain Thery committed
98

Sylvain Thery's avatar
Sylvain Thery committed
99 100
	const std::vector<Dart>* m_QLT;
	std::vector<Dart>::const_iterator m_ItDarts;
101
public:
Sylvain Thery's avatar
Sylvain Thery committed
102
	Traversor3XXaY(const MAP& map, Dart dart, bool forceDartMarker = false, unsigned int thread = 0);
103 104 105 106 107 108 109 110 111 112

	Dart begin();
	Dart end();
	Dart next();
};

/**
 * Traverse vertices incident to volume
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
113
class Traversor3WV: public Traversor3XY<MAP, VOLUME, VERTEX>
114
{
Pierre Kraemer's avatar
Pierre Kraemer committed
115
public:
Sylvain Thery's avatar
Sylvain Thery committed
116
	Traversor3WV(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VOLUME, VERTEX>(m, dart, forceDartMarker, thread)	{}
117
};
Pierre Kraemer's avatar
Pierre Kraemer committed
118

119 120 121 122
/**
 * Traverse edges incident to volume
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
123
class Traversor3WE: public Traversor3XY<MAP, VOLUME, EDGE>
124 125
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
126
	Traversor3WE(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VOLUME, EDGE>(m, dart, forceDartMarker, thread)	{}
127
};
Pierre Kraemer's avatar
Pierre Kraemer committed
128

129 130 131
/**
 * Traverse faces incident to volume
 */
Pierre Kraemer's avatar
Pierre Kraemer committed
132
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
133
class Traversor3WF: public Traversor3XY<MAP, VOLUME, FACE>
Pierre Kraemer's avatar
Pierre Kraemer committed
134
{
135
public:
Sylvain Thery's avatar
Sylvain Thery committed
136
	Traversor3WF(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VOLUME, FACE>(m, dart, forceDartMarker, thread) {}
137 138 139 140 141 142
};

/**
 * Traverse vertices incident to face
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
143
class Traversor3FV: public Traversor3XY<MAP, FACE, VERTEX>
144
{
Pierre Kraemer's avatar
Pierre Kraemer committed
145
public:
Sylvain Thery's avatar
Sylvain Thery committed
146
	Traversor3FV(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, FACE, VERTEX>(m, dart, forceDartMarker, thread)	{}
147
};
Pierre Kraemer's avatar
Pierre Kraemer committed
148

149 150 151 152
/**
 * Traverse edges incident to face
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
153
class Traversor3FE: public Traversor3XY<MAP, FACE, EDGE>
154 155
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
156
	Traversor3FE(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, FACE, EDGE>(m, dart, forceDartMarker, thread)	{}
157
};
Pierre Kraemer's avatar
Pierre Kraemer committed
158

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

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

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

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

199 200 201 202
/**
 * Traverse edges incident to vertex
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
203
class Traversor3VE: public Traversor3XY<MAP, VERTEX, EDGE>
204
{
205
public:
Sylvain Thery's avatar
Sylvain Thery committed
206
	Traversor3VE(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VERTEX, EDGE>(m, dart, forceDartMarker, thread)	{}
207
};
208

209 210 211 212
/**
 * Traverse faces incident to vertex
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
213
class Traversor3VF: public Traversor3XY<MAP, VERTEX, FACE>
214
{
215
public:
Sylvain Thery's avatar
Sylvain Thery committed
216
	Traversor3VF(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VERTEX, FACE>(m, dart, forceDartMarker, thread)	{}
217
};
218

219 220 221 222
/**
 * Traverse volumes incident to vertex
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
223
class Traversor3VW: public Traversor3XY<MAP, VERTEX, VOLUME>
224 225
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
226
	Traversor3VW(const MAP& m, Dart dart, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XY<MAP, VERTEX, VOLUME>(m, dart, forceDartMarker, thread)	{}
227 228 229 230 231 232
};

/**
 * Traverse vertices adjacent to a vertex by an edge
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
233
class Traversor3VVaE: public Traversor3XXaY<MAP, VERTEX, EDGE>
234 235
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
236
	Traversor3VVaE(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VERTEX, EDGE>(m, d, forceDartMarker, thread)	{}
237 238 239 240 241 242
};

/**
 * Traverse vertices adjacent to a vertex by a face
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
243
class Traversor3VVaF: public Traversor3XXaY<MAP, VERTEX, FACE>
244 245
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
246
	Traversor3VVaF(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VERTEX, FACE>(m, d, forceDartMarker, thread)	{}
247 248 249 250 251 252
};

/**
 * Traverse vertices adjacent to a vertex by a volume
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
253
class Traversor3VVaW: public Traversor3XXaY<MAP, VERTEX, VOLUME>
254 255
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
256
	Traversor3VVaW(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VERTEX, VOLUME>(m, d, forceDartMarker, thread)	{}
257 258 259 260 261 262
};

/**
 * Traverse edges adjacent to an egde by a vertex
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
263
class Traversor3EEaV: public Traversor3XXaY<MAP, EDGE, VERTEX>
264 265
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
266
	Traversor3EEaV(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, EDGE, VERTEX>(m, d, forceDartMarker, thread)	{}
267 268 269 270 271 272
};

/**
 * Traverse edges adjacent to an egde by a face
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
273
class Traversor3EEaF: public Traversor3XXaY<MAP, EDGE, FACE>
274 275
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
276
	Traversor3EEaF(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, EDGE, FACE>(m, d, forceDartMarker, thread)	{}
277 278 279 280 281 282
};

/**
 * Traverse edges adjacent to an egde by a volume
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
283
class Traversor3EEaW: public Traversor3XXaY<MAP, EDGE, VOLUME>
284 285
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
286
	Traversor3EEaW(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, EDGE, VOLUME>(m, d, forceDartMarker, thread)	{}
287 288 289 290 291 292
};

/**
 * Traverse faces adjacent to a face by a vertex
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
293
class Traversor3FFaV: public Traversor3XXaY<MAP, FACE, VERTEX>
294 295
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
296
	Traversor3FFaV(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, FACE, VERTEX>(m, d, forceDartMarker, thread)	{}
297 298 299 300 301 302
};

/**
 * Traverse faces adjacent to a face by an edge
 */
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
303
class Traversor3FFaE: public Traversor3XXaY<MAP, FACE, EDGE>
304 305
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
306
	Traversor3FFaE(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, FACE, EDGE>(m, d, forceDartMarker, thread)	{}
307 308 309 310 311 312
};

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

319
/**
320
 * Traverse volumes adjacent to a volume by a vertex
321
 */
322
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
323
class Traversor3WWaV: public Traversor3XXaY<MAP, VOLUME, VERTEX>
324 325
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
326
	Traversor3WWaV(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VOLUME, VERTEX>(m, d, forceDartMarker, thread)	{}
327 328
};

329
/**
330
 * Traverse volumes adjacent to a volume by an edge
331
 */
332
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
333
class Traversor3WWaE: public Traversor3XXaY<MAP, VOLUME, EDGE>
334 335
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
336
	Traversor3WWaE(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VOLUME, EDGE>(m, d, forceDartMarker, thread)	{}
337 338
};

339
/**
340
 * Traverse volumes adjacent to a volume by a face
341
 */
342
template <typename MAP>
Pierre Kraemer's avatar
Pierre Kraemer committed
343
class Traversor3WWaF: public Traversor3XXaY<MAP, VOLUME, FACE>
344 345
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
346
	Traversor3WWaF(const MAP& m, Dart d, bool forceDartMarker = false, unsigned int thread = 0) : Traversor3XXaY<MAP, VOLUME, FACE>(m, d, forceDartMarker, thread)	{}
347 348
};

Pierre Kraemer's avatar
Pierre Kraemer committed
349 350
} // namespace CGoGN

351
#include "Topology/generic/traversor/traversor3.hpp"
Pierre Kraemer's avatar
Pierre Kraemer committed
352 353

#endif