map3.cpp 14.9 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
{
74 75
	//is boundary
	if(phi3(d) != d)
Pierre Kraemer's avatar
Pierre Kraemer committed
76
	{
77 78
		Dart e = d;
		Dart d3 = phi2(phi3(d));
Pierre Kraemer's avatar
Pierre Kraemer committed
79

80 81 82 83 84
		do
		{
			unsewVolumes(e);
			e = phi2(phi_1(e));
		}while(e != d);
Pierre Kraemer's avatar
Pierre Kraemer committed
85

86 87
		Map2::deleteVertex(d3);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
88

89
	Map2::deleteVertex(d);
Pierre Kraemer's avatar
Pierre Kraemer committed
90

91
	return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
}

void Map3::cutEdge(Dart d)
{
	if(phi3(d) == d)
		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));
		}
	}

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

untereiner's avatar
untereiner committed
128
void Map3::uncutEdge(Dart d)
untereiner's avatar
untereiner committed
129
{
untereiner's avatar
untereiner committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
	if(phi3(d) == d)
		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
150 151 152

}

153
void Map3::splitFace(Dart d, Dart e)
Pierre Kraemer's avatar
Pierre Kraemer committed
154
{
155
	Map2::splitFace(d,e);
Pierre Kraemer's avatar
Pierre Kraemer committed
156

157
	if (phi3(d) != d)
Pierre Kraemer's avatar
Pierre Kraemer committed
158
	{
159 160
		Dart dd = phi1(phi3(d));
		Dart ee = phi1(phi3(e));
Pierre Kraemer's avatar
Pierre Kraemer committed
161

162
		Map2::splitFace(dd,ee);
Pierre Kraemer's avatar
Pierre Kraemer committed
163

164 165
		phi3sew(phi_1(d), phi_1(ee));
		phi3sew(phi_1(e), phi_1(dd));
Pierre Kraemer's avatar
Pierre Kraemer committed
166 167 168 169 170 171 172 173 174 175
	}
}

Dart Map3::cutSpike(Dart d)
{
  Dart e=d;
  int nb=0;
  Dart dNew;
  int tet=0;

176
  //CGoGNout << "cut" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
177 178 179 180 181 182 183 184 185

  //count the valence of the vertex
  do {
    nb++;
    e=phi1(phi2(e));
  } while (e!=d);

  if(nb<3)
  {
186
	CGoGNout << "Warning : cannot cut 2 volumes without creating a degenerated face " << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
187 188 189 190 191 192 193 194 195
	return d;
  }
  else
  {
	 //triangulate around the vertex
	do {
		if(phi1(phi1(phi1(e)))!=e)
		{
			splitFace(phi_1(e),phi1(e));
196
			//CGoGNout << "split" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
197 198 199 200 201 202 203
		}
		else
			tet++;

		e=phi1(phi2(e));
	} while (e!=d);

204 205
//	CGoGNout << "#tet= " << tet << CGoGNendl;
//	CGoGNout << "#nb= " << nb << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
206 207 208

	//si toute ces faces ne sont pas triangulaires (on insere une face)
	if(tet != nb) {
209
		//CGoGNout << "new face" << CGoGNendl;
Pierre Kraemer's avatar
Pierre Kraemer committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
		dNew=newFace(nb);
		Dart d3 = newFace(nb);
		sewVolumes(dNew,d3);

		//sew a face following the triangles
		Dart dTurn=dNew;
		do {
			Dart d1 = phi1(e);
			Dart dSym = phi2(d1);
			phi2unsew(d1);
			phi2sew(dTurn,d1);
			phi2sew(phi3(dTurn),dSym);
			dTurn = phi1(dTurn);
			e=phi1(phi2(e));
		}while(e!=d);
	}
	else
		dNew = d;
  }

  return dNew;
}

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
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)
{
	Dart e = phi3(d) ;
	if(e != d)
	{
		unsewVolumes(d);
		Map2::mergeVolumes(d, e); // merge the two volumes along common face
		return true ;
	}
	return false ;
}

269 270 271 272 273
/*! @name Topological Queries
 *  Return or set various topological information
 *************************************************************************/

bool Map3::sameOrientedVertex(Dart d, Dart e)
274 275 276 277 278
{
	return sameOrientedVertex(d,e);
}

bool Map3::sameVertex(Dart d, Dart e)
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
{
	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
317 318 319 320 321
unsigned int Map3::vertexDegree(Dart d)
{
	int count = 0;
	DartMarkerStore mv(*this);	// Lock a marker

322 323 324
	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
325 326 327

	mv.mark(d);

328
	for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
untereiner's avatar
untereiner committed
329
	{
330
		Dart dc = *darts;
untereiner's avatar
untereiner committed
331 332 333 334 335 336 337 338

		//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))
		{
339
			darts_list.push_back(d21);
untereiner's avatar
untereiner committed
340 341 342 343 344
			mv.mark(d21);
		}

		if((d23!=d2) && !mv.isMarked(d23))
		{
345
			darts_list.push_back(d23);
untereiner's avatar
untereiner committed
346 347 348 349 350 351
			mv.mark(d23);
		}
	}

	DartMarkerStore me(*this);

352
	for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
untereiner's avatar
untereiner committed
353
	{
354
		if(!me.isMarked(*darts))
untereiner's avatar
untereiner committed
355 356
		{
			++count;
357
			me.markOrbit(EDGE, *darts);
untereiner's avatar
untereiner committed
358 359 360 361 362 363
		}
	}

	return count;
}

364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 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 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
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)
{
	return sameOrientedEdge(d,e);
}

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;
}

int Map3::edgeDegree(Dart d)
{
	int deg = 0;
	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
449 450 451 452 453 454 455 456
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) ;
457
	mark.markOrbit(FACE, d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475

	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) ;
476
					mark.markOrbit(FACE, ee) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
477 478 479 480 481 482 483 484 485
				}
				e = phi1(e) ;
			} while(e != *face) ;
		}
	}

	return isBoundary;
}

486
bool Map3::check()
487
{
488 489 490 491 492 493 494 495 496 497
    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;
        }
498

499 500 501 502 503 504 505 506
        if(d3 != d)
        {
        	if(phi1(d3) != phi3(phi_1(d)))
        	{
        		std::cout << "Check: phi3 , faces are not entirely sewn" << std::endl;
        		return false;
        	}
        }
507

508 509 510 511 512 513
        Dart d2 = phi2(d);
        if (phi2(d2) != d) // phi2 involution ?
		{
            std::cout << "Check: phi2 is not an involution" << std::endl;
            return false;
        }
514

515 516 517 518 519 520
        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;
        }
521

522
        if (m.isMarked(d1)) // phi1 a un seul antécédent ?
523
		{
524 525 526 527
            std::cout << "Check: dart with two phi1 predecessors" << std::endl;
            return false;
        }
        m.mark(d1);
528

529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
        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 ?
545
		{
546 547 548 549 550
        	//std::cout << "dart = " << d << std::endl;
            std::cout << "Check: dart with no phi1 predecessor" << std::endl;
            return false;
        }
    }
551

552
    std::cout << "Check: topology ok" << std::endl;
553

554 555 556 557 558 559

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


    return true;
560 561
}

Pierre Kraemer's avatar
Pierre Kraemer committed
562 563 564 565
/*! @name Cell Functors
 *  Apply functors to all darts of a cell
 *************************************************************************/

Sylvain Thery's avatar
Sylvain Thery committed
566
bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
567
{
Sylvain Thery's avatar
Sylvain Thery committed
568
	DartMarkerStore mv(*this,thread);	// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
569 570
	bool found = false;					// Last functor return value

untereiner's avatar
untereiner committed
571 572
	std::vector<Dart> darts_list;			//Darts that are traversed
	darts_list.reserve(512);
untereiner's avatar
untereiner committed
573
	darts_list.push_back(d);			//Start with the dart d
Pierre Kraemer's avatar
Pierre Kraemer committed
574 575
	mv.mark(d);

untereiner's avatar
untereiner committed
576
	for(std::vector<Dart>::iterator darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
Pierre Kraemer's avatar
Pierre Kraemer committed
577 578 579 580 581
	{
		Dart dc = *darts;

		//add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(dc);
untereiner's avatar
untereiner committed
582
		if(d2 != dc)
Pierre Kraemer's avatar
Pierre Kraemer committed
583
		{
untereiner's avatar
untereiner committed
584 585
			Dart d21 = phi1(d2); // turn in volume
			Dart d23 = phi3(d2); // change volume
Pierre Kraemer's avatar
Pierre Kraemer committed
586

untereiner's avatar
untereiner committed
587 588 589 590 591 592 593 594 595 596 597
			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
598 599 600 601 602 603 604 605
		}

		found = f(dc);
	}

	return found;
}

Sylvain Thery's avatar
Sylvain Thery committed
606
bool Map3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
607 608 609
{
	Dart dNext = d;
	do {
Sylvain Thery's avatar
Sylvain Thery committed
610
		if (Map2::foreach_dart_of_edge(dNext,f,thread)) return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
611 612 613 614 615
		dNext = alpha2(dNext);
	} while (dNext != d);
	return false;
}

Sylvain Thery's avatar
Sylvain Thery committed
616
bool Map3::foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
617
{
Sylvain Thery's avatar
Sylvain Thery committed
618
	DartMarkerStore mv(*this,thread);	// Lock a marker
Pierre Kraemer's avatar
Pierre Kraemer committed
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651
	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
652
bool Map3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
Pierre Kraemer's avatar
Pierre Kraemer committed
653
{
Sylvain Thery's avatar
Sylvain Thery committed
654
	if (foreach_dart_of_oriented_face(d,f,thread)) return true;
Pierre Kraemer's avatar
Pierre Kraemer committed
655 656

	Dart d3 = phi3(d);
Sylvain Thery's avatar
Sylvain Thery committed
657
	if (d3 != d) return foreach_dart_of_oriented_face(d3,f,thread);
Pierre Kraemer's avatar
Pierre Kraemer committed
658 659 660
	return false;
}

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