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

100
	return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
101 102 103 104
}

void Map3::cutEdge(Dart d)
{
untereiner's avatar
untereiner committed
105
	if(isBoundaryFace(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
		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
128
	if(!isBoundaryFace(d))
Pierre Kraemer's avatar
Pierre Kraemer committed
129 130 131 132 133 134 135 136
	{
		Dart d3 = phi3(d);
		phi3unsew(d);
		phi3sew(d, phi1(d3));
		phi3sew(d3, phi1(d));
	}
}

untereiner's avatar
untereiner committed
137
void Map3::uncutEdge(Dart d)
untereiner's avatar
untereiner committed
138
{
untereiner's avatar
untereiner committed
139
	if(isBoundaryFace(d))
untereiner's avatar
untereiner committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
		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
159 160 161

}

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

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

171
		Map2::splitFace(dd,ee);
Pierre Kraemer's avatar
Pierre Kraemer committed
172

173 174
		phi3sew(phi_1(d), phi_1(ee));
		phi3sew(phi_1(e), phi_1(dd));
Pierre Kraemer's avatar
Pierre Kraemer committed
175 176 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
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
204
	if(!isBoundaryFace(d))
205
	{
untereiner's avatar
untereiner committed
206 207
		Dart e = phi3(d);
		Map3::unsewVolumes(d);
208 209 210 211 212 213
		Map2::mergeVolumes(d, e); // merge the two volumes along common face
		return true ;
	}
	return false ;
}

untereiner's avatar
untereiner committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
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));
}

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

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

bool Map3::sameVertex(Dart d, Dart e)
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
{
	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
279 280
unsigned int Map3::vertexDegree(Dart d)
{
untereiner's avatar
untereiner committed
281
	unsigned int count = 0;
untereiner's avatar
untereiner committed
282 283
	DartMarkerStore mv(*this);	// Lock a marker

284 285 286
	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
287 288 289

	mv.mark(d);

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

		//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))
		{
301
			darts_list.push_back(d21);
untereiner's avatar
untereiner committed
302 303 304 305 306
			mv.mark(d21);
		}

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

	DartMarkerStore me(*this);

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

	return count;
}

326 327 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
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
366
	return sameEdge(d,e);
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
}

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
383
unsigned int Map3::edgeDegree(Dart d)
384
{
untereiner's avatar
untereiner committed
385
	unsigned int deg = 0;
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410
	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
411 412 413 414 415 416 417 418
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) ;
419
	mark.markOrbit(FACE, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437

	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) ;
438
					mark.markOrbit(FACE, ee) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
439 440 441 442 443 444 445 446 447
				}
				e = phi1(e) ;
			} while(e != *face) ;
		}
	}

	return isBoundary;
}

448
bool Map3::check()
449
{
450 451 452 453 454 455 456 457 458 459
    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;
        }
460

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

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

477 478 479 480 481 482
        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;
        }
483

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

491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
        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 ?
507
		{
508 509 510 511 512
        	//std::cout << "dart = " << d << std::endl;
            std::cout << "Check: dart with no phi1 predecessor" << std::endl;
            return false;
        }
    }
513

514
    std::cout << "Check: topology ok" << std::endl;
515

516 517 518 519

    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
520 521 522 523 524 525 526 527 528 529
    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 ;


530 531

    return true;
532 533
}

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

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

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

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

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

untereiner's avatar
untereiner committed
559 560 561 562 563 564 565 566 567 568 569
			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
570 571 572 573 574 575 576 577
		}

		found = f(dc);
	}

	return found;
}

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

Sylvain Thery's avatar
Sylvain Thery committed
588
bool Map3::foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
589
{
Sylvain Thery's avatar
Sylvain Thery committed
590
	DartMarkerStore mv(*this,thread);	// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
591 592 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
	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
624
bool Map3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
625
{
Sylvain Thery's avatar
Sylvain Thery committed
626
	if (foreach_dart_of_oriented_face(d,f,thread)) return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
627 628

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

Sylvain Thery's avatar
Sylvain Thery committed
633
bool Map3::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
634
{
Sylvain Thery's avatar
Sylvain Thery committed
635
	DartMarkerStore mv(*this,thread);			// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
636 637 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
	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