traversor2.hpp 15.3 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
28
29
30
31
32
33
34
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

/*******************************************************************************
					VERTEX CENTERED TRAVERSALS
*******************************************************************************/

// Traversor2VE

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
35
Traversor2VE<MAP>::Traversor2VE(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Sylvain Thery's avatar
Sylvain Thery committed
36
{
Sylvain Thery's avatar
Sylvain Thery committed
37
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<VERTEX,EDGE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
38
39
40
41
42
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
	}
}
Pierre Kraemer's avatar
Pierre Kraemer committed
43
44
45
46

template <typename MAP>
Dart Traversor2VE<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
47
48
49
50
51
52
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
53
54
55
56
57
58
59
60
61
62
63
64
65
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2VE<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2VE<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
66
67
68
69
70
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
71
72
	if(current != NIL)
	{
Sylvain Thery's avatar
Sylvain Thery committed
73
74
//		current = m.alpha1(current) ;
		current = m.phi2(m.phi_1(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
75
76
77
78
79
80
81
82
83
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2VF

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
84
Traversor2VF<MAP>::Traversor2VF(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
85
{
Sylvain Thery's avatar
Sylvain Thery committed
86
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<VERTEX,FACE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
87
88
89
90
91
92
93
94
95
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
	}
	else
	{
		if(m.isBoundaryMarked2(start)) // jump over a boundary face
			start = m.phi2(m.phi_1(start)) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
96
97
98
99
100
}

template <typename MAP>
Dart Traversor2VF<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
101
102
103
104
105
106
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
107
108
109
110
111
112
113
114
115
116
117
118
119
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2VF<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2VF<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
120
121
122
123
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
124
125
	if(current != NIL)
	{
Sylvain Thery's avatar
Sylvain Thery committed
126
		current = m.phi2(m.phi_1(current)) ;
Thery Sylvain's avatar
Thery Sylvain committed
127
		if(m.isBoundaryMarked2(current)) // jump over a boundary face
Sylvain Thery's avatar
Sylvain Thery committed
128
			current = m.phi2(m.phi_1(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
129
130
131
132
133
134
135
136
137
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2VVaE

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
138
Traversor2VVaE<MAP>::Traversor2VVaE(const MAP& map, Dart dart) : m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
139
{
Sylvain Thery's avatar
Sylvain Thery committed
140
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<VERTEX,EDGE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
141
142
143
144
145
146
147
148
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
	}
	else
	{
		start = m.phi2(dart) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
149
150
151
152
153
}

template <typename MAP>
Dart Traversor2VVaE<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
154
155
156
157
158
159
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
160
161
162
163
164
165
166
167
168
169
170
171
172
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2VVaE<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2VVaE<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
173
174
175
176
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
177
178
179
180
181
182
183
184
185
186
187
188
	if(current != NIL)
	{
		current = m.phi_1(m.phi2(current)) ;
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2VVaF

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
189
Traversor2VVaF<MAP>::Traversor2VVaF(const MAP& map, Dart dart) : m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
190
{
Sylvain Thery's avatar
Sylvain Thery committed
191
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<VERTEX,FACE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
192
193
194
195
196
197
198
199
200
201
202
203
204
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<VERTEX>(dart)));
	}
	else
	{
		if(m.isBoundaryMarked2(dart))
			dart = m.phi2(m.phi_1(dart)) ;
		start = m.phi1(m.phi1(dart)) ;
		if(start == dart)
			start = m.phi1(dart) ;
		stop = dart ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
205
206
207
208
209
}

template <typename MAP>
Dart Traversor2VVaF<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
210
211
212
213
214
215
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
216
217
218
219
220
221
222
223
224
225
226
227
228
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2VVaF<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2VVaF<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
229
230
231
232
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
233
234
235
236
237
	if(current != NIL)
	{
		current = m.phi1(current) ;
		if(current == stop)
		{
Sylvain Thery's avatar
Sylvain Thery committed
238
			Dart d = m.phi2(m.phi_1(current)) ;
Thery Sylvain's avatar
Thery Sylvain committed
239
			if(m.isBoundaryMarked2(d)) // jump over a boundary face
240
			{
Sylvain Thery's avatar
Sylvain Thery committed
241
				d = m.phi2(m.phi_1(d)) ;
242
243
244
245
				current = m.phi1(d);
			}
			else
				current = m.phi1(m.phi1(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
			if(current == d)
				current = m.phi1(d) ;
			stop = d ;
		}
		if(current == start)
			current = NIL ;
	}
	return current ;
}

/*******************************************************************************
					EDGE CENTERED TRAVERSALS
*******************************************************************************/

// Traversor2EV

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
263
264
265
Traversor2EV<MAP>::Traversor2EV(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
{
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<EDGE,VERTEX>() ;
Sylvain Thery's avatar
Sylvain Thery committed
266
267
268
269
270
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
	}
}
Pierre Kraemer's avatar
Pierre Kraemer committed
271
272
273
274

template <typename MAP>
Dart Traversor2EV<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
275
276
277
278
279
280
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
281
282
283
284
285
286
287
288
289
290
291
292
293
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2EV<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2EV<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
294
295
296
297
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
298
299
300
301
302
303
304
305
306
307
308
309
	if(current != NIL)
	{
		current = m.phi2(current) ;
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2EF

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
310
Traversor2EF<MAP>::Traversor2EF(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
311
{
Sylvain Thery's avatar
Sylvain Thery committed
312
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<EDGE,FACE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
313
314
315
316
317
318
319
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
	}
	else
	{
		if(m.isBoundaryMarked2(start))
Sylvain Thery's avatar
Sylvain Thery committed
320
			start = m.phi2(start) ;
Sylvain Thery's avatar
Sylvain Thery committed
321
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
322
323
324
325
326
}

template <typename MAP>
Dart Traversor2EF<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
327
328
329
330
331
332
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
333
334
335
336
337
338
339
340
341
342
343
344
345
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2EF<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2EF<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
346
347
348
349
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
350
351
352
	if(current != NIL)
	{
		current = m.phi2(current) ;
Thery Sylvain's avatar
Thery Sylvain committed
353
		if(current == start || m.isBoundaryMarked2(current)) // do not consider a boundary face
Pierre Kraemer's avatar
Pierre Kraemer committed
354
355
356
357
358
359
360
361
			current = NIL ;
	}
	return current ;
}

// Traversor2EEaV

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
362
Traversor2EEaV<MAP>::Traversor2EEaV(const MAP& map, Dart dart) : m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
363
{
Sylvain Thery's avatar
Sylvain Thery committed
364
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<EDGE,VERTEX>() ;
Sylvain Thery's avatar
Sylvain Thery committed
365
366
367
368
369
370
371
372
373
374
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
	}
	else
	{
		start = m.phi2(m.phi_1(dart)) ;
		stop1 = dart ;
		stop2 = m.phi2(dart) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
375
376
377
378
379
}

template <typename MAP>
Dart Traversor2EEaV<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
380
381
382
383
384
385
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
386
387
388
389
390
391
392
393
394
395
396
397
398
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2EEaV<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2EEaV<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
399
400
401
402
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
403
404
	if(current != NIL)
	{
Sylvain Thery's avatar
Sylvain Thery committed
405
		current = m.phi2(m.phi_1(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
406
		if(current == stop1)
Sylvain Thery's avatar
Sylvain Thery committed
407
			current = m.phi2(m.phi_1(stop2)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
408
409
410
411
412
413
414
415
416
		else if(current == stop2)
			current = NIL ;
	}
	return current ;
}

// Traversor2EEaF

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
417
418
Traversor2EEaF<MAP>::Traversor2EEaF(const MAP& map, Dart dart) :
	m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
419
{
Sylvain Thery's avatar
Sylvain Thery committed
420
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<EDGE,FACE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
421
422
423
424
425
426
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<EDGE>(dart)));
	}
	else
	{
Sylvain Thery's avatar
Sylvain Thery committed
427
428
429
430
431
432
		if (m.isBoundaryMarked2(dart))
			stop1 = m.phi2(dart);
		else
			stop1 = dart;
		stop2 = m.phi2(stop1) ;
		start = m.phi1(stop1);
Sylvain Thery's avatar
Sylvain Thery committed
433
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
434
435
436
437
438
}

template <typename MAP>
Dart Traversor2EEaF<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
439
440
441
442
443
444
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
445
446
447
448
449
450
451
452
453
454
455
456
457
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2EEaF<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2EEaF<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
458
459
460
461
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
462
463
464
	if(current != NIL)
	{
		current = m.phi1(current) ;
Sylvain Thery's avatar
Sylvain Thery committed
465
466
467
468
469
470
471
472
		if (current == stop1)
		{
			if (!m.isBoundaryMarked2(stop2))
				current = m.phi1(stop2) ;
			else
				current=NIL;
		}
		else if (current == stop2)
Pierre Kraemer's avatar
Pierre Kraemer committed
473
			current = NIL ;
Sylvain Thery's avatar
Sylvain Thery committed
474

Pierre Kraemer's avatar
Pierre Kraemer committed
475
476
477
478
479
480
481
482
483
484
485
	}
	return current ;
}

/*******************************************************************************
					FACE CENTERED TRAVERSALS
*******************************************************************************/

// Traversor2FV

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
486
Traversor2FV<MAP>::Traversor2FV(const MAP& map, Dart dart) : m(map), start(dart),m_QLT(NULL)
Sylvain Thery's avatar
Sylvain Thery committed
487
{
Sylvain Thery's avatar
Sylvain Thery committed
488
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickIncidentTraversal<FACE,VERTEX>() ;
Sylvain Thery's avatar
Sylvain Thery committed
489
490
491
492
493
	if (quickTraversal != NULL)
	{
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<FACE>(dart)));
	}
}
Pierre Kraemer's avatar
Pierre Kraemer committed
494
495
496
497

template <typename MAP>
Dart Traversor2FV<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
498
499
500
501
502
503
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
504
505
506
507
508
509
510
511
512
513
514
515
516
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2FV<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2FV<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
517
	if(m_QLT != NULL)
518
    {
Sylvain Thery's avatar
Sylvain Thery committed
519
520
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
521
	if(current != NIL)
522
    {
Pierre Kraemer's avatar
Pierre Kraemer committed
523
524
525
526
527
528
529
530
531
532
		current = m.phi1(current) ;
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2FFaV

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
533
Traversor2FFaV<MAP>::Traversor2FFaV(const MAP& map, Dart dart) : m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
534
{
Sylvain Thery's avatar
Sylvain Thery committed
535
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<FACE,VERTEX>() ;
Sylvain Thery's avatar
Sylvain Thery committed
536
	if (quickTraversal != NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
537
	{
Sylvain Thery's avatar
Sylvain Thery committed
538
539
540
541
542
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<FACE>(dart)));
	}
	else
	{
		start = m.phi2(m.phi_1(m.phi2(m.phi_1(dart)))) ;
thery's avatar
thery committed
543
		while (start == dart)
Sylvain Thery's avatar
Sylvain Thery committed
544
		{
thery's avatar
thery committed
545
546
			dart = m.phi1(dart);
			start = m.phi2(m.phi_1(m.phi2(m.phi_1(dart)))) ;
Sylvain Thery's avatar
Sylvain Thery committed
547
		}
thery's avatar
thery committed
548
		current = start ;
Sylvain Thery's avatar
Sylvain Thery committed
549
550
551
		stop = dart ;
		if(m.isBoundaryMarked2(start))
			start = next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
552
553
554
555
556
557
	}
}

template <typename MAP>
Dart Traversor2FFaV<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
558
559
560
561
562
563
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
564
565
566
567
568
569
570
571
572
573
574
575
576
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2FFaV<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2FFaV<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
577
578
579
580
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
581
582
	if(current != NIL)
	{
Sylvain Thery's avatar
Sylvain Thery committed
583
		current = m.phi2(m.phi_1(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
584
585
586
		if(current == stop)
		{
			Dart d = m.phi1(current) ;
Sylvain Thery's avatar
Sylvain Thery committed
587
			current = m.phi2(m.phi_1(m.phi2(m.phi_1(d)))) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
588
589
			if(current == d)
			{
thery's avatar
thery committed
590
591
				stop = m.phi1(d);
				current = m.phi2(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
592
593
594
				return next() ;
			}
			stop = d ;
thery's avatar
thery committed
595
596
597
598
		}
		if(m.isBoundaryMarked2(current))
		{
			return next() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
599
600
601
602
603
604
605
606
607
608
		}
		if(current == start)
			current = NIL ;
	}
	return current ;
}

// Traversor2FFaE

template <typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
609
Traversor2FFaE<MAP>::Traversor2FFaE(const MAP& map, Dart dart) : m(map),m_QLT(NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
610
{
Sylvain Thery's avatar
Sylvain Thery committed
611
	const AttributeMultiVector<NoTypeNameAttribute<std::vector<Dart> > >* quickTraversal = map.template getQuickAdjacentTraversal<FACE,EDGE>() ;
Sylvain Thery's avatar
Sylvain Thery committed
612
	if (quickTraversal != NULL)
Pierre Kraemer's avatar
Pierre Kraemer committed
613
	{
Sylvain Thery's avatar
Sylvain Thery committed
614
615
616
617
618
619
620
621
622
623
624
		m_QLT  = &(quickTraversal->operator[](map.template getEmbedding<FACE>(dart)));
	}
	else
	{
		start = m.phi2(dart) ;
		while(start != NIL && m.isBoundaryMarked2(start))
		{
			start = m.phi2(m.phi1(m.phi2(start))) ;
			if(start == m.phi2(dart))
				start = NIL ;
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
625
626
627
628
629
630
	}
}

template <typename MAP>
Dart Traversor2FFaE<MAP>::begin()
{
Sylvain Thery's avatar
Sylvain Thery committed
631
632
633
634
635
636
	if(m_QLT != NULL)
	{
		m_ItDarts = m_QLT->begin();
		return *m_ItDarts++;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
637
638
639
640
641
642
643
644
645
646
647
648
649
	current = start ;
	return current ;
}

template <typename MAP>
Dart Traversor2FFaE<MAP>::end()
{
	return NIL ;
}

template <typename MAP>
Dart Traversor2FFaE<MAP>::next()
{
Sylvain Thery's avatar
Sylvain Thery committed
650
651
652
653
	if(m_QLT != NULL)
	{
		return *m_ItDarts++;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
654
655
656
657
658
	if(current != NIL)
	{
		do
		{
			current = m.phi2(m.phi1(m.phi2(current))) ;
Thery Sylvain's avatar
Thery Sylvain committed
659
		} while(m.isBoundaryMarked2(current)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
660
661
662
663
664
665
		if(current == start)
			current = NIL ;
	}
	return current ;
}

Sylvain Thery's avatar
Sylvain Thery committed
666

667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
//
//template<typename MAP>
//Traversor2<MAP>* Traversor2<MAP>::createIncident(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY)
//{
//	int code = 0x100*(orbX-VERTEX) + orbY-VERTEX;
//
//	switch(code)
//	{
//	case 0x0001:
//		return new Traversor2VE<MAP>(map,dart);
//		break;
//	case 0x0002:
//		return new Traversor2VF<MAP>(map,dart);
//		break;
//	case 0x0100:
//		return new Traversor2EV<MAP>(map,dart);
//		break;
//	case 0x0102:
//		return new Traversor2EF<MAP>(map,dart);
//		break;
//	case 0x0200:
//		return new Traversor2FV<MAP>(map,dart);
//		break;
//	case 0x0201:
//		return new Traversor2FE<MAP>(map,dart);
//		break;
//	default:
//		return NULL;
//		break;
//	}
//	return NULL;
//}
//
//template<typename MAP>
//Traversor2<MAP>* Traversor2<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int orbX, unsigned int orbY)
//{
//	int code = 0x100*(orbX-VERTEX) + orbY-VERTEX;
//	switch(code)
//	{
//	case 0x0001:
//		return new Traversor2VVaE<MAP>(map,dart);
//		break;
//	case 0x0002:
//		return new Traversor2VVaF<MAP>(map,dart);
//		break;
//	case 0x0100:
//		return new Traversor2EEaV<MAP>(map,dart);
//		break;
//	case 0x0102:
//		return new Traversor2EEaF<MAP>(map,dart);
//		break;
//	case 0x0200:
//		return new Traversor2FFaV<MAP>(map,dart);
//		break;
//	case 0x0201:
//		return new Traversor2FFaE<MAP>(map,dart);
//		break;
//	default:
//		return NULL;
//		break;
//	}
//	return NULL;
//}
Sylvain Thery's avatar
Sylvain Thery committed
730

Pierre Kraemer's avatar
Pierre Kraemer committed
731
} // namespace CGoGN