map3.cpp 15 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-2011, 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.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
28
29
30
31
32
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/map/map3.h"

namespace CGoGN
{

/*! @name Generator and Deletor
 *  To generate or delete volumes in a 3-map
 *************************************************************************/
33
34

void Map3::deleteVolume(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
35
36
37
38
{
	DartMarkerStore mark(*this);		// Lock a marker

	std::vector<Dart> visitedFaces;		// Faces that are traversed
39
	visitedFaces.reserve(512);
Pierre Kraemer's avatar
Pierre Kraemer committed
40
41
	visitedFaces.push_back(d);			// Start with the face of d

42
	mark.markOrbit(FACE, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
43

44
	for(std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
Pierre Kraemer's avatar
Pierre Kraemer committed
45
46
47
48
49
50
51
52
53
54
55
	{
		Dart e = *face ;

		unsewVolumes(e);

		do	// add all face neighbours to the table
		{
			Dart ee = phi2(e) ;
			if(!mark.isMarked(ee)) // not already marked
			{
				visitedFaces.push_back(ee) ;
56
				mark.markOrbit(FACE, ee) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
57
58
59
60
61
62
63
			}
			e = phi1(e) ;
		} while(e != *face) ;
	}


	// delete every visited face
64
	for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
65
		Map2::deleteOrientedFace(*face);
Pierre Kraemer's avatar
Pierre Kraemer committed
66
67
68
69
70
71
}

/*! @name Topological Operators
 *  Topological operations on 3-maps
 *************************************************************************/

72
bool Map3::deleteVertex(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
73
{
untereiner's avatar
untereiner committed
74
75
76
77
78
79
80
81
82
83
84
85
	//Save the darts around the vertex
	//(one dart per face should be enough)
	std::vector<Dart> fstoretmp;
	fstoretmp.reserve(100);
	FunctorStore fs(fstoretmp);
	foreach_dart_of_vertex(d, fs);

	//just one dart per face
	std::vector<Dart> fstore;
	fstore.reserve(100);
	DartMarker mf(*this);
	for(std::vector<Dart>::iterator it = fstoretmp.begin() ; it != fstoretmp.end() ; ++it)
Pierre Kraemer's avatar
Pierre Kraemer committed
86
	{
untereiner's avatar
untereiner committed
87
		if(!mf.isMarked(*it))
88
		{
untereiner's avatar
untereiner committed
89
90
91
			mf.markOrbit(FACE, *it);
			fstore.push_back(*it);
		}
92
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
93

untereiner's avatar
untereiner committed
94

untereiner's avatar
untereiner committed
95
96
97
98
99
	for(std::vector<Dart>::iterator it = fstore.begin() ; it != fstore.end() ; ++it)
	{
		if(!mergeVolumes(*it))
			return false;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
100

untereiner's avatar
untereiner committed
101

102
	return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
103
104
105
106
}

void Map3::cutEdge(Dart d)
{
untereiner's avatar
untereiner committed
107
	if(isBoundaryFace(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
		d = phi2(d);

	Dart prev = d;
	Dart dd = alpha2(d);
	Map2::cutEdge(d);

	while (dd!=d)
	{
		prev = dd;
		dd = alpha2(dd);

		Map2::cutEdge(prev);

		if (phi3(prev) != prev)
		{
			Dart d3 = phi3(prev);
			phi3unsew(prev);
			phi3sew(prev, phi1(d3));
			phi3sew(d3, phi1(prev));
		}
	}

untereiner's avatar
untereiner committed
130
	if(!isBoundaryFace(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
131
132
133
134
135
136
137
138
	{
		Dart d3 = phi3(d);
		phi3unsew(d);
		phi3sew(d, phi1(d3));
		phi3sew(d3, phi1(d));
	}
}

untereiner's avatar
untereiner committed
139
void Map3::uncutEdge(Dart d)
untereiner's avatar
untereiner committed
140
{
untereiner's avatar
untereiner committed
141
	if(isBoundaryFace(d))
untereiner's avatar
untereiner committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
		d = phi_1(phi2(d));

	Dart prev = d;
	Dart dd = alpha2(d);

	Map2::uncutEdge(prev);

	if(phi3(dd) != dd)
		phi3sew(dd,phi2(prev));

	while (dd!=d)
	{
		prev = dd;
		dd = alpha2(dd);

		Map2::uncutEdge(prev);

		phi3sew(dd, phi2(prev));
	}
untereiner's avatar
untereiner committed
161
162
163

}

164
void Map3::splitFace(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
165
{
166
	Map2::splitFace(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
167

untereiner's avatar
untereiner committed
168
	if(!isBoundaryFace(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
169
	{
170
171
		Dart dd = phi1(phi3(d));
		Dart ee = phi1(phi3(e));
Pierre Kraemer's avatar
Pierre Kraemer committed
172

173
		Map2::splitFace(dd,ee);
Pierre Kraemer's avatar
Pierre Kraemer committed
174

175
176
		phi3sew(phi_1(d), phi_1(ee));
		phi3sew(phi_1(e), phi_1(dd));
Pierre Kraemer's avatar
Pierre Kraemer committed
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
void Map3::sewVolumes(Dart d, Dart e)
{
	assert(faceDegree(d) == faceDegree(e));

	Dart fitD = d ;
	Dart fitE = e ;
	do
	{
		phi3sew(fitD,fitE);
		fitD = phi1(fitD) ;
		fitE = phi_1(fitE) ;
	} while(fitD != d) ;
}

void Map3::unsewVolumes(Dart d)
{
	Dart fitD = d;
	do
	{
		phi3unsew(fitD);
		fitD = phi1(fitD);
	} while(fitD != d);
}

bool Map3::mergeVolumes(Dart d)
{
untereiner's avatar
untereiner committed
206
	if(!isBoundaryFace(d))
207
	{
untereiner's avatar
untereiner committed
208
209
		Dart e = phi3(d);
		Map3::unsewVolumes(d);
210
211
212
213
214
215
		Map2::mergeVolumes(d, e); // merge the two volumes along common face
		return true ;
	}
	return false ;
}

untereiner's avatar
untereiner committed
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
void Map3::splitVolume(std::vector<Dart>& vd)
{
	Dart e = vd.front();
	Dart e2 = phi2(e);

	//unsew the edge path
	for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
		Map2::unsewFaces(*it);

	//close the two holes
	Map2::closeHole(e);
	Map2::closeHole(e2);

	//sew the two connexe componnents
	Map3::sewVolumes(phi2(e), phi2(e2));
}

233
234
235
236
237
/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/

bool Map3::sameOrientedVertex(Dart d, Dart e)
238
{
untereiner's avatar
untereiner committed
239
	return sameVertex(d,e);
240
241
242
}

bool Map3::sameVertex(Dart d, Dart e)
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
{
	DartMarkerStore mv(*this);	// Lock a marker

	std::list<Dart> darts_list;			//Darts that are traversed
	darts_list.push_back(d);			//Start with the dart d
	mv.mark(d);

	for(std::list<Dart>::iterator darts = darts_list.begin();darts != darts_list.end() ; ++darts)
	{
		Dart dc = *darts;

		if(dc==e)
			return true;

		//add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(dc);
		if(d2 != dc)
		{
			Dart d21 = phi1(d2); // turn in volume
			Dart d23 = phi3(d2); // change volume

			if(!mv.isMarked(d21))
			{
				darts_list.push_back(d21);
				mv.mark(d21);
			}

			if((d23!=d2) && !mv.isMarked(d23))
			{
				darts_list.push_back(d23);
				mv.mark(d23);
			}
		}
	}

	return false;
}

untereiner's avatar
untereiner committed
281
282
unsigned int Map3::vertexDegree(Dart d)
{
untereiner's avatar
untereiner committed
283
	unsigned int count = 0;
untereiner's avatar
untereiner committed
284
285
	DartMarkerStore mv(*this);	// Lock a marker

286
287
288
	std::list<Dart> darts_list;			//Darts that are traversed
	darts_list.push_back(d);			//Start with the dart d
	std::list<Dart>::iterator darts;
untereiner's avatar
untereiner committed
289
290
291

	mv.mark(d);

292
	for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
untereiner's avatar
untereiner committed
293
	{
294
		Dart dc = *darts;
untereiner's avatar
untereiner committed
295
296
297
298
299
300
301
302

		//add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(dc);
		Dart d21 = phi1(d2); // turn in volume
		Dart d23 = phi3(d2); // change volume

		if(!mv.isMarked(d21))
		{
303
			darts_list.push_back(d21);
untereiner's avatar
untereiner committed
304
305
306
307
308
			mv.mark(d21);
		}

		if((d23!=d2) && !mv.isMarked(d23))
		{
309
			darts_list.push_back(d23);
untereiner's avatar
untereiner committed
310
311
312
313
314
315
			mv.mark(d23);
		}
	}

	DartMarkerStore me(*this);

316
	for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
untereiner's avatar
untereiner committed
317
	{
318
		if(!me.isMarked(*darts))
untereiner's avatar
untereiner committed
319
320
		{
			++count;
321
			me.markOrbit(EDGE, *darts);
untereiner's avatar
untereiner committed
322
323
324
325
326
327
		}
	}

	return count;
}

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
bool Map3::isBoundaryVertex(Dart d)
{
	DartMarkerStore mv(*this);			// Lock a marker
	bool found = false;					// Last functor return value

	std::list<Dart> darts_list;			//Darts that are traversed
	darts_list.push_back(d);			//Start with the dart d
	std::list<Dart>::iterator darts;

	mv.mark(d);

	for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
	{
		Dart dc = *darts;

		//add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(dc);
		Dart d21 = phi1(d2); // turn in volume
		Dart d23 = phi3(d2); // change volume

		if(!mv.isMarked(d21))
		{
			darts_list.push_back(d21);
			mv.mark(d21);
		}

		if((d23!=d2) && !mv.isMarked(d23))
		{
			darts_list.push_back(d23);
			mv.mark(d23);
		}

		found = phi3(dc) == dc;
	}

	return found;
}

bool Map3::sameOrientedEdge(Dart d, Dart e)
{
untereiner's avatar
untereiner committed
368
	return sameEdge(d,e);
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
}

bool Map3::sameEdge(Dart d, Dart e)
{
	Dart dd = d;
	do
	{
		if(dd==e || phi2(dd)==e)
			return true;

		dd = alpha2(dd);
	} while (dd!=d);

	return false;
}

untereiner's avatar
untereiner committed
385
unsigned int Map3::edgeDegree(Dart d)
386
{
untereiner's avatar
untereiner committed
387
	unsigned int deg = 0;
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
	Dart e = d;

	do
	{
		deg++;
		e = alpha2(e);
	} while(e != d);

	return deg;
}

bool Map3::sameFace(Dart d, Dart e)
{
	if(phi3(d) != d)
		if(Map2::sameOrientedFace(phi3(d), e))
			return true;

	return Map2::sameOrientedFace(d,e);
}

bool Map3::isBoundaryFace(Dart d)
{
	return (phi3(d) == d);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
413
414
415
416
417
418
419
420
bool Map3::isBoundaryVolume(Dart d)
{
	bool isBoundary = false;
	DartMarkerStore mark(*this);		// Lock a marker

	std::vector<Dart> visitedFaces ;
	visitedFaces.reserve(100) ;
	visitedFaces.push_back(d) ;
421
	mark.markOrbit(FACE, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439

	for(std::vector<Dart>::iterator face = visitedFaces.begin(); !isBoundary && face != visitedFaces.end(); ++face)
	{
		Dart e = *face ;

		//if this dart is not phi3-linked
		if(phi3(e) == e)
			isBoundary = true;

		if(!isBoundary)
		{

			do	// add all face neighbours to the table
			{
				Dart ee = phi2(e) ;
				if(!mark.isMarked(ee)) // not already marked
				{
					visitedFaces.push_back(ee) ;
440
					mark.markOrbit(FACE, ee) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
441
442
443
444
445
446
447
448
449
				}
				e = phi1(e) ;
			} while(e != *face) ;
		}
	}

	return isBoundary;
}

450
bool Map3::check()
451
{
452
453
454
455
456
457
458
459
460
461
    std::cout << "Check: topology begin" << std::endl;
    DartMarker m(*this);
    for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
    {
        Dart d3 = phi3(d);
        if (phi3(d3) != d) // phi3 involution ?
		{
            std::cout << "Check: phi3 is not an involution" << std::endl;
            return false;
        }
462

463
464
465
466
467
468
469
470
        if(d3 != d)
        {
        	if(phi1(d3) != phi3(phi_1(d)))
        	{
        		std::cout << "Check: phi3 , faces are not entirely sewn" << std::endl;
        		return false;
        	}
        }
471

472
473
474
475
476
477
        Dart d2 = phi2(d);
        if (phi2(d2) != d) // phi2 involution ?
		{
            std::cout << "Check: phi2 is not an involution" << std::endl;
            return false;
        }
478

479
480
481
482
483
484
        Dart d1 = phi1(d);
        if (phi_1(d1) != d) // phi1 a une image correcte ?
		{
            std::cout << "Check: unconsistent phi_1 link" << std::endl;
            return false;
        }
485

486
        if (m.isMarked(d1)) // phi1 a un seul antécédent ?
487
		{
488
489
490
491
            std::cout << "Check: dart with two phi1 predecessors" << std::endl;
            return false;
        }
        m.mark(d1);
492

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
        if (d1 == d)
            std::cout << "Check: (warning) face loop (one edge)" << std::endl;

        if (phi1(d1) == d)
            std::cout << "Check: (warning) face with only two edges" << std::endl;

        if (phi2(d1) == d)
            std::cout << "Check: (warning) dandling edge (phi2)" << std::endl;

        if (phi3(d1) == d)
            std::cout << "Check: (warning) dandling edge (phi3)" << std::endl;
    }

    for(Dart d = this->begin(); d != this->end(); this->next(d))
    {
        if (!m.isMarked(d)) // phi1 a au moins un antécédent ?
509
		{
510
511
512
513
514
        	//std::cout << "dart = " << d << std::endl;
            std::cout << "Check: dart with no phi1 predecessor" << std::endl;
            return false;
        }
    }
515

516
    std::cout << "Check: topology ok" << std::endl;
517

518
519
520
521

    std::cout << "nb vertex orbits" << getNbOrbits(VERTEX) << std::endl ;
    std::cout << "nb vertex cells" << m_attribs[VERTEX].size() << std::endl ;

untereiner's avatar
untereiner committed
522
523
524
525
526
527
528
529
530
531
    std::cout << "nb edge orbits" << getNbOrbits(EDGE) << std::endl ;
    std::cout << "nb edge cells" << m_attribs[EDGE].size() << std::endl ;

    std::cout << "nb face orbits" << getNbOrbits(FACE) << std::endl ;
    std::cout << "nb face cells" << m_attribs[FACE].size() << std::endl ;

    std::cout << "nb volume orbits" << getNbOrbits(VOLUME) << std::endl ;
    std::cout << "nb volume cells" << m_attribs[VOLUME].size() << std::endl ;


532
533

    return true;
534
535
}

Pierre Kraemer's avatar
Pierre Kraemer committed
536
537
538
539
/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

540
bool Map3::foreach_dart_of_oriented_vertex(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
541
{
Sylvain Thery's avatar
Sylvain Thery committed
542
	DartMarkerStore mv(*this,thread);	// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
543
544
	bool found = false;					// Last functor return value

untereiner's avatar
untereiner committed
545
546
	std::vector<Dart> darts_list;			//Darts that are traversed
	darts_list.reserve(512);
untereiner's avatar
untereiner committed
547
	darts_list.push_back(d);			//Start with the dart d
Pierre Kraemer's avatar
Pierre Kraemer committed
548
549
	mv.mark(d);

untereiner's avatar
untereiner committed
550
	for(std::vector<Dart>::iterator darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
Pierre Kraemer's avatar
Pierre Kraemer committed
551
552
553
554
555
	{
		Dart dc = *darts;

		//add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(dc);
untereiner's avatar
untereiner committed
556
		if(d2 != dc)
Pierre Kraemer's avatar
Pierre Kraemer committed
557
		{
untereiner's avatar
untereiner committed
558
559
			Dart d21 = phi1(d2); // turn in volume
			Dart d23 = phi3(d2); // change volume
Pierre Kraemer's avatar
Pierre Kraemer committed
560

untereiner's avatar
untereiner committed
561
562
563
564
565
566
567
568
569
570
571
			if(!mv.isMarked(d21))
			{
				darts_list.push_back(d21);
				mv.mark(d21);
			}

			if((d23!=d2) && !mv.isMarked(d23))
			{
				darts_list.push_back(d23);
				mv.mark(d23);
			}
Pierre Kraemer's avatar
Pierre Kraemer committed
572
573
574
575
576
577
578
579
		}

		found = f(dc);
	}

	return found;
}

Sylvain Thery's avatar
Sylvain Thery committed
580
bool Map3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
581
582
583
{
	Dart dNext = d;
	do {
Sylvain Thery's avatar
Sylvain Thery committed
584
		if (Map2::foreach_dart_of_edge(dNext,f,thread)) return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
585
586
587
588
589
		dNext = alpha2(dNext);
	} while (dNext != d);
	return false;
}

Sylvain Thery's avatar
Sylvain Thery committed
590
bool Map3::foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
591
{
Sylvain Thery's avatar
Sylvain Thery committed
592
	DartMarkerStore mv(*this,thread);	// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
	bool found = false;					// Last functor return value

	std::list<Dart> darts_list;			//Darts that are traversed
	darts_list.push_back(d);			//Start with the dart d
	std::list<Dart>::iterator darts;

	mv.mark(d);

	for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
	{
		Dart d1 = *darts;

		Dart d3 = phi2(d1); // change face
		Dart d4 = phi3(d1); // change volume

		if (!mv.isMarked(d3))
		{
			darts_list.push_back(d3);
			mv.mark(d3);
		}
		if (!mv.isMarked(d4))
		{
			darts_list.push_back(d4);
			mv.mark(d4);
		}

		found = f(d1);
	}


	return found;
}

Sylvain Thery's avatar
Sylvain Thery committed
626
bool Map3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
627
{
Sylvain Thery's avatar
Sylvain Thery committed
628
	if (foreach_dart_of_oriented_face(d,f,thread)) return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
629
630

	Dart d3 = phi3(d);
Sylvain Thery's avatar
Sylvain Thery committed
631
	if (d3 != d) return foreach_dart_of_oriented_face(d3,f,thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
632
633
634
	return false;
}

Sylvain Thery's avatar
Sylvain Thery committed
635
bool Map3::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
636
{
Sylvain Thery's avatar
Sylvain Thery committed
637
	DartMarkerStore mv(*this,thread);			// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
	bool found = false;					// Last functor return value

	std::list<Dart> darts_list;			//Darts that are traversed
	darts_list.push_back(d);			//Start with the dart d
	std::list<Dart>::iterator darts;

	mv.mark(d);


	for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
	{
		Dart d1 = *darts;

		// add all successors if they are not marked yet
		Dart d2 = phi1(d1); // turn in face
		Dart d3 = phi2(d1); // change volume
		Dart d4 = phi3(d1); // change volume

		if (!mv.isMarked(d2))
		{
			darts_list.push_back(d2);
			mv.mark(d2);
		}
		if (!mv.isMarked(d3))
		{
			darts_list.push_back(d2);
			mv.mark(d2);
		}
		if (!mv.isMarked(d4))
		{
			darts_list.push_back(d4);
			mv.mark(d4);
		}

		found = f(d1);	// functor say finish
	}


	return found;
}


} // namespace CGoGN