embeddedMap2.cpp 15.2 KB
Newer Older
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           *
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/                                           *
21 22 23 24 25 26 27 28
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include <vector>
#include <algorithm>

#include "Topology/map/embeddedMap2.h"
Sylvain Thery's avatar
Sylvain Thery committed
29
#include "Topology/generic/traversor2.h"
30 31 32 33

namespace CGoGN
{

David Cazier's avatar
David Cazier committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
Dart EmbeddedMap2::newPolyLine(unsigned int nbEdges)
{
	Dart d = Map2::newPolyLine(nbEdges) ;

	if (isOrbitEmbedded<VERTEX>())
	{
		Dart e = d ;
		for (unsigned int i = 0 ; i <= nbEdges ; ++i)
		{
			initOrbitEmbeddingNewCell<VERTEX>(e) ;
			e = this->phi1(e) ;
		}
	}

	if (isOrbitEmbedded<EDGE>())
	{
		Dart e = d ;
		for (unsigned int i = 0 ; i < nbEdges ; ++i)
		{
			initOrbitEmbeddingNewCell<EDGE>(e) ;
			e = this->phi1(e) ;
		}
	}

	if (isOrbitEmbedded<FACE>())
	{
		initOrbitEmbeddingNewCell<FACE>(d) ;
	}
	return d ;
}

65 66 67 68 69 70 71 72
Dart EmbeddedMap2::newFace(unsigned int nbEdges, bool withBoundary)
{
	Dart d = Map2::newFace(nbEdges, withBoundary);

	if(withBoundary)
	{
		if (isOrbitEmbedded<VERTEX>())
		{
73
/*
74 75 76
			Traversor2FV<EmbeddedMap2> t(*this, d);
			for(Dart it = t.begin(); it != t.end(); it = t.next())
				initOrbitEmbeddingNewCell<VERTEX>(it) ;
77 78 79 80 81 82 83
*/
			Dart e = d;
			do
			{
				initOrbitEmbeddingNewCell<VERTEX>(e) ;
				e = this->phi1(e);
			} while (d!=e);
84 85 86 87
		}

		if(isOrbitEmbedded<EDGE>())
		{
88
/*
89 90 91
			Traversor2FE<EmbeddedMap2> t(*this, d);
			for(Dart it = t.begin(); it != t.end(); it = t.next())
				initOrbitEmbeddingNewCell<EDGE>(it) ;
92 93 94 95 96 97 98
*/
			Dart e = d;
			do
			{
				initOrbitEmbeddingNewCell<EDGE>(e) ;
				e = this->phi1(e);
			} while (d!=e);
99 100 101 102 103 104 105 106
		}

		if(isOrbitEmbedded<FACE>())
		{
			initOrbitEmbeddingNewCell<FACE>(d) ;
			initOrbitEmbeddingNewCell<FACE>(phi2(d)) ;
		}
	}
Sylvain Thery's avatar
Sylvain Thery committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
//	else
//	{
//		if (isOrbitEmbedded<VERTEX>())
//		{
///*
//			Traversor2FV<EmbeddedMap2> t(*this, d);
//			for(Dart it = t.begin(); it != t.end(); it = t.next())
//				initOrbitEmbeddingNewCell<VERTEX>(it) ;
//*/
//			Dart e = d;
//			do
//			{
//				initDartEmbedding<VERTEX>(e,newCell<VERTEX>());
//				e = this->phi1(e);
//			} while (d!=e);
//		}
//
//		if(isOrbitEmbedded<FACE>())
//			initOrbitEmbeddingNewCell<FACE>(d) ;
//
//	}
128 129 130
	return d ;
}

131 132 133 134 135 136 137
void EmbeddedMap2::splitVertex(Dart d, Dart e)
{
	Dart dd = phi2(d) ;
	Dart ee = phi2(e) ;

	Map2::splitVertex(d, e) ;

138
	if (isOrbitEmbedded<VERTEX>())
139
	{
140 141
		initDartEmbedding<VERTEX>(phi1(dd), getEmbedding<VERTEX>(d)) ;
		setOrbitEmbeddingOnNewCell<VERTEX>(e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
142
		copyCell<VERTEX>(e, d) ;
143 144
	}

145 146 147 148 149
	if(isOrbitEmbedded<EDGE>())
	{
		initOrbitEmbeddingNewCell<EDGE>(phi1(dd)) ;
	}

150
	if(isOrbitEmbedded<FACE>())
151
	{
152 153
		initDartEmbedding<FACE>(phi1(dd), getEmbedding<FACE>(dd)) ;
		initDartEmbedding<FACE>(phi1(ee), getEmbedding<FACE>(ee)) ;
154 155 156
	}
}

157
Dart EmbeddedMap2::deleteVertex(Dart d)
158
{
159 160
	Dart f = Map2::deleteVertex(d) ;
	if(f != NIL)
161
	{
162
		if (isOrbitEmbedded<FACE>())
163
		{
164
			setOrbitEmbedding<FACE>(f, getEmbedding<FACE>(f)) ;
165 166
		}
	}
167
	return f ;
168 169
}

David Cazier's avatar
David Cazier committed
170
Dart EmbeddedMap2::cutEdge(Dart d)
171
{
David Cazier's avatar
David Cazier committed
172
	Dart nd = Map2::cutEdge(d) ;
173

174 175 176 177 178
	if(isOrbitEmbedded<VERTEX>())
	{
		initOrbitEmbeddingNewCell<VERTEX>(nd) ;
	}

179
	if (isOrbitEmbedded<EDGE>())
180
	{
181 182
		initDartEmbedding<EDGE>(phi2(d), getEmbedding<EDGE>(d)) ;
		setOrbitEmbeddingOnNewCell<EDGE>(nd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
183
		copyCell<EDGE>(nd, d) ;
184
	}
185

186
	if(isOrbitEmbedded<FACE>())
187
	{
188
		initDartEmbedding<FACE>(nd, getEmbedding<FACE>(d)) ;
189
		Dart e = phi2(nd) ;
190
		initDartEmbedding<FACE>(phi1(e), getEmbedding<FACE>(e)) ;
191
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
192

David Cazier's avatar
David Cazier committed
193
	return nd;
194 195
}

Pierre Kraemer's avatar
Pierre Kraemer committed
196
bool EmbeddedMap2::uncutEdge(Dart d)
197
{
Pierre Kraemer's avatar
Pierre Kraemer committed
198
	if(Map2::uncutEdge(d))
199
	{
200
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
201
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
202
			copyDartEmbedding<EDGE>(phi2(d), d) ;
untereiner's avatar
untereiner committed
203
		}
Pierre Kraemer's avatar
Pierre Kraemer committed
204
		return true ;
205
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
206
	return false ;
207 208 209 210 211 212 213 214 215 216 217 218 219
}

bool EmbeddedMap2::edgeCanCollapse(Dart d)
{
	if(isBoundaryVertex(d) || isBoundaryVertex(phi1(d)))
		return false ;

	unsigned int val_v1 = vertexDegree(d) ;
	unsigned int val_v2 = vertexDegree(phi1(d)) ;

	if(val_v1 + val_v2 < 8 || val_v1 + val_v2 > 14)
		return false ;

220
	if(faceDegree(d) == 3)
221 222 223 224 225 226
	{
		if(vertexDegree(phi_1(d)) < 4)
			return false ;
	}

	Dart dd = phi2(d) ;
227
	if(faceDegree(dd) == 3)
228 229 230 231 232 233 234 235 236 237 238 239
	{
		if(vertexDegree(phi_1(dd)) < 4)
			return false ;
	}

	// Check vertex sharing condition
	std::vector<unsigned int> vu1 ;
	vu1.reserve(32) ;
	Dart vit1 = alpha1(alpha1(d)) ;
	Dart end = phi1(dd) ;
	do
	{
240
		unsigned int ve = getEmbedding<VERTEX>(phi2(vit1)) ;
241 242 243 244 245 246 247
		vu1.push_back(ve) ;
		vit1 = alpha1(vit1) ;
	} while(vit1 != end) ;
	end = phi1(d) ;
	Dart vit2 = alpha1(alpha1(dd)) ;
	do
	{
248
		unsigned int ve = getEmbedding<VERTEX>(phi2(vit2)) ;
249 250 251 252 253 254 255 256 257 258 259 260
		std::vector<unsigned int>::iterator it = std::find(vu1.begin(), vu1.end(), ve) ;
		if(it != vu1.end())
			return false ;
		vit2 = alpha1(vit2) ;
	} while(vit2 != end) ;

	return true ;
}

Dart EmbeddedMap2::collapseEdge(Dart d, bool delDegenerateFaces)
{
	unsigned int vEmb = EMBNULL ;
261
	if (isOrbitEmbedded<VERTEX>())
262
	{
263
		vEmb = getEmbedding<VERTEX>(d) ;
264 265 266 267
	}

	Dart dV = Map2::collapseEdge(d, delDegenerateFaces);

268
	if (isOrbitEmbedded<VERTEX>())
269
	{
270
		setOrbitEmbedding<VERTEX>(dV, vEmb) ;
271
	}
272
	
273 274 275 276 277 278 279 280 281
	return dV ;
}

bool EmbeddedMap2::flipEdge(Dart d)
{
	if(Map2::flipEdge(d))
	{
		Dart e = phi2(d) ;

282
		if (isOrbitEmbedded<VERTEX>())
283
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
284 285
			copyDartEmbedding<VERTEX>(d, phi1(e)) ;
			copyDartEmbedding<VERTEX>(e, phi1(d)) ;
286
		}
287

288
		if (isOrbitEmbedded<FACE>())
289
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
290 291
			copyDartEmbedding<FACE>(phi_1(d), d) ;
			copyDartEmbedding<FACE>(phi_1(e), e) ;
292
		}
293

294 295 296 297 298 299 300 301 302 303 304
		return true ;
	}
	return false ;
}

bool EmbeddedMap2::flipBackEdge(Dart d)
{
	if(Map2::flipBackEdge(d))
	{
		Dart e = phi2(d) ;

305
		if (isOrbitEmbedded<VERTEX>())
306
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
307 308
			copyDartEmbedding<VERTEX>(d, phi1(e)) ;
			copyDartEmbedding<VERTEX>(e, phi1(d)) ;
309
		}
310

311
		if (isOrbitEmbedded<FACE>())
312
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
313 314
			copyDartEmbedding<FACE>(phi1(d), d) ;
			copyDartEmbedding<FACE>(phi1(e), e) ;
315
		}
316

317 318 319 320 321
		return true ;
	}
	return false ;
}

untereiner's avatar
untereiner committed
322 323 324 325 326 327
void EmbeddedMap2::swapEdges(Dart d, Dart e)
{
	Dart d2 = phi2(d);
	Dart e2 = phi2(e);
	Map2::swapEdges(d,e);

328
	if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
329
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
330 331 332 333
		copyDartEmbedding<VERTEX>(d, phi2(phi_1(d)));
		copyDartEmbedding<VERTEX>(e, phi2(phi_1(e)));
		copyDartEmbedding<VERTEX>(d2, phi2(phi_1(d2)));
		copyDartEmbedding<VERTEX>(e2, phi2(phi_1(e2)));
untereiner's avatar
untereiner committed
334 335
	}

336
	if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
337 338 339 340
	{

	}

341
	if(isOrbitEmbedded<VOLUME>())
342
		setOrbitEmbeddingOnNewCell<VOLUME>(d);
untereiner's avatar
untereiner committed
343 344
}

345 346 347 348 349 350 351 352 353 354 355 356 357
void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e)
{
	Map2::insertEdgeInVertex(d, e);

	if (isOrbitEmbedded<VERTEX>())
	{
		copyDartEmbedding<VERTEX>(e, d) ;
	}

	if (isOrbitEmbedded<FACE>())
	{
		if(!sameFace(d,e))
		{
358 359
			setOrbitEmbeddingOnNewCell<FACE>(e);
			copyCell<FACE>(e, d);
360 361 362
		}
		else
		{
363
			setOrbitEmbedding<FACE>(d, getEmbedding<FACE>(d)) ;
364 365 366 367 368 369 370 371 372 373 374 375 376 377
		}
	}
}

bool EmbeddedMap2::removeEdgeFromVertex(Dart d)
{
	Dart dPrev = alpha_1(d);

	if (dPrev == d) return false ;

	bool b = Map2::removeEdgeFromVertex(d);

	if (isOrbitEmbedded<VERTEX>())
	{
378 379
		setOrbitEmbeddingOnNewCell<VERTEX>(d);
		copyCell<VERTEX>(d, dPrev);
380 381 382 383 384 385
	}

	if (isOrbitEmbedded<FACE>())
	{
		if(!sameFace(d, dPrev))
		{
386 387
			setOrbitEmbeddingOnNewCell<FACE>(d);
			copyCell<FACE>(d, dPrev);
388 389 390
		}
		else
		{
391
			setDartEmbedding<FACE>(d, getEmbedding<FACE>(d)) ;
392 393 394 395
		}
	}
	return b ;
}
396

397
void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary)
398
{
399 400 401
	if (!withBoundary)
	{
		Map2::sewFaces(d, e, false) ;
402

Sylvain Thery's avatar
Sylvain Thery committed
403 404 405 406 407 408 409 410 411
//		if(isOrbitEmbedded<EDGE>())
//		{
///*
//			initOrbitEmbeddingNewCell<EDGE>(d) ;
//*/
//			unsigned int emb = newCell<EDGE>();
//			initDartEmbedding<EDGE>(d,emb);
//			initDartEmbedding<EDGE>(e,emb);
//		}
412

413 414
		return ;
	}
415

untereiner's avatar
untereiner committed
416
	Map2::sewFaces(d, e, withBoundary) ;
417

418
	if (isOrbitEmbedded<VERTEX>())
419
	{
420 421
		setOrbitEmbedding<VERTEX>(d, getEmbedding<VERTEX>(d)) ;
		setOrbitEmbedding<VERTEX>(e, getEmbedding<VERTEX>(phi1(d))) ;
422 423
	}

424
	if (isOrbitEmbedded<EDGE>())
425
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
426
		copyDartEmbedding<EDGE>(e, d) ;
427 428 429
	}
}

430
void EmbeddedMap2::unsewFaces(Dart d, bool withBoundary)
431
{
432 433 434 435 436 437
	if (!withBoundary)
	{
		Map2::unsewFaces(d, false) ;
		return ;
	}

438 439 440
	Dart e = phi2(d) ;
	Map2::unsewFaces(d) ;

441
	if (isOrbitEmbedded<VERTEX>())
442
	{
Sylvain Thery's avatar
Sylvain Thery committed
443 444 445
		copyDartEmbedding<VERTEX>(phi2(e), d) ;
		copyDartEmbedding<VERTEX>(phi2(d), e) ;

446 447
		Dart ee = phi1(e) ;
		if(!sameVertex(d, ee))
448
		{
449
			setOrbitEmbeddingOnNewCell<VERTEX>(ee);
Pierre Kraemer's avatar
Pierre Kraemer committed
450
			copyCell<VERTEX>(ee, d);
451 452
		}

453 454
		Dart dd = phi1(d) ;
		if(!sameVertex(e, dd))
455
		{
456
			setOrbitEmbeddingOnNewCell<VERTEX>(dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
457
			copyCell<VERTEX>(dd, e);
458 459
		}
	}
460

461
	if (isOrbitEmbedded<EDGE>())
462
	{
463
		setOrbitEmbeddingOnNewCell<EDGE>(e);
Pierre Kraemer's avatar
Pierre Kraemer committed
464
		copyCell<EDGE>(e, d);
465 466 467 468 469 470
	}
}

bool EmbeddedMap2::collapseDegeneratedFace(Dart d)
{
	Dart e = phi2(d) ;
471 472 473
	bool updateEdgeEmb = false ;
	if(phi1(d) != d)
		updateEdgeEmb = true ;
474

475
	if(Map2::collapseDegeneratedFace(d))
476
	{
477
		if (isOrbitEmbedded<EDGE>() && updateEdgeEmb)
478
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
479
			copyDartEmbedding<EDGE>(phi2(e), e) ;
480 481 482 483 484 485 486 487 488 489
		}
		return true ;
	}
	return false ;
}

void EmbeddedMap2::splitFace(Dart d, Dart e)
{
	Map2::splitFace(d, e) ;

490
	if (isOrbitEmbedded<VERTEX>())
491
	{
492 493
		initDartEmbedding<VERTEX>(phi_1(e), getEmbedding<VERTEX>(d)) ;
		initDartEmbedding<VERTEX>(phi_1(d), getEmbedding<VERTEX>(e)) ;
494
	}
495 496 497 498 499 500

	if(isOrbitEmbedded<EDGE>())
	{
		initOrbitEmbeddingNewCell<EDGE>(phi_1(d)) ;
	}

501
	if (isOrbitEmbedded<FACE>())
502
	{
503 504
		initDartEmbedding<FACE>(phi_1(d), getEmbedding<FACE>(d)) ;
		setOrbitEmbeddingOnNewCell<FACE>(e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
505
		copyCell<FACE>(e, d) ;
506 507 508 509 510 511 512 513 514
	}
}

bool EmbeddedMap2::mergeFaces(Dart d)
{
	Dart dNext = phi1(d) ;

	if(Map2::mergeFaces(d))
	{
515
		if (isOrbitEmbedded<FACE>())
516
		{
517
			setOrbitEmbedding<FACE>(dNext, getEmbedding<FACE>(dNext)) ;
518 519 520 521 522 523
		}
		return true ;
	}
	return false ;
}

524
bool EmbeddedMap2::mergeVolumes(Dart d, Dart e, bool deleteFace)
525 526 527
{
	std::vector<Dart> darts ;
	std::vector<unsigned int> vEmb ;
untereiner's avatar
untereiner committed
528
	vEmb.reserve(32) ;
529
	std::vector<unsigned int> eEmb ;
untereiner's avatar
untereiner committed
530
	eEmb.reserve(32) ;
531 532 533 534 535
	Dart fit = d ;
	do
	{
		darts.push_back(phi2(fit)) ;

536
		if (isOrbitEmbedded<VERTEX>())
537
		{
538
			vEmb.push_back(getEmbedding<VERTEX>(phi2(fit))) ;
539 540
		}

541
		if (isOrbitEmbedded<EDGE>())
542
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
543
			eEmb.push_back(getEmbedding<EDGE>(fit)) ;
544
		}
545
		
546 547 548
		fit = phi1(fit) ;
	} while (fit != d) ;

549
	if(Map2::mergeVolumes(d, e, deleteFace))
550 551 552
	{
		for(unsigned int i = 0; i < darts.size(); ++i)
		{
553
			if (isOrbitEmbedded<VERTEX>())
554
			{
555
				setOrbitEmbedding<VERTEX>(darts[i], vEmb[i]) ;
556 557
			}

558
			if (isOrbitEmbedded<EDGE>())
559
			{
560
				setOrbitEmbedding<EDGE>(darts[i], eEmb[i]) ;
561 562 563 564 565 566 567
			}
		}
		return true ;
	}
	return false ;
}

568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
void EmbeddedMap2::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, bool secondSideClosed)
{
	std::vector<Dart> darts ;
	darts.reserve(vd.size());

	// save the edge neighbors darts
	for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
	{
		darts.push_back(phi2(*it));
	}

	assert(darts.size() == vd.size());

	Map2::splitSurface(vd, firstSideClosed, secondSideClosed);

	// follow the edge path a second time to embed the vertex, edge and volume orbits
	for(unsigned int i = 0; i < vd.size(); ++i)
	{
		Dart dit = vd[i];
		Dart dit2 = darts[i];

		// embed the vertex embedded from the origin volume to the new darts
590
		if(isOrbitEmbedded<VERTEX>())
591
		{
592 593
			initDartEmbedding<VERTEX>(phi2(dit), getEmbedding<VERTEX>(phi1(dit)));
			initDartEmbedding<VERTEX>(phi2(dit2), getEmbedding<VERTEX>(phi1(dit2)));
594 595 596
		}

		// embed the edge embedded from the origin volume to the new darts
597
		if(isOrbitEmbedded<EDGE>())
598
		{
599 600 601
			initDartEmbedding<EDGE>(phi2(dit), getEmbedding<EDGE>(dit));
			setOrbitEmbeddingOnNewCell<EDGE>(phi2(dit2));
			copyCell<EDGE>(dit2, dit);
602 603 604
		}

		// embed the volume embedded from the origin volume to the new darts
605
		if(isOrbitEmbedded<VOLUME>())
606
		{
607 608
			initDartEmbedding<VOLUME>(phi2(dit), getEmbedding<VOLUME>(dit));
			initDartEmbedding<VOLUME>(phi2(dit2), getEmbedding<VOLUME>(dit2));
609 610 611 612
		}
	}
}

613
unsigned int EmbeddedMap2::closeHole(Dart d, bool forboundary)
614
{
615
	unsigned int nbE = Map2::closeHole(d, forboundary) ;
616 617 618 619
	Dart dd = phi2(d) ;
	Dart f = dd ;
	do
	{
620
		if (isOrbitEmbedded<VERTEX>())
621
		{
Sylvain Thery's avatar
Sylvain Thery committed
622 623 624 625 626
			unsigned int emb = getEmbedding<VERTEX>(phi1(phi2(f)));
			if (emb == EMBNULL)
				initOrbitEmbeddingNewCell<VERTEX>(f) ;
			else
				initDartEmbedding<VERTEX>(f, emb) ;
627
		}
628

629
		if (isOrbitEmbedded<EDGE>())
630
		{
Sylvain Thery's avatar
Sylvain Thery committed
631 632 633 634 635
			unsigned int emb = getEmbedding<EDGE>(phi2(f));
			if (emb == EMBNULL)
				initOrbitEmbeddingNewCell<EDGE>(f) ;
			else
				initDartEmbedding<EDGE>(f, emb) ;
636
		}
637

638 639
		f = phi1(f) ;
	} while(dd != f) ;
640 641 642 643 644 645

	if(isOrbitEmbedded<FACE>())
	{
		initOrbitEmbeddingNewCell<FACE>(dd) ;
	}

646 647 648 649 650 651 652 653 654 655 656 657
	return nbE ;
}

bool EmbeddedMap2::check()
{
	bool topo = Map2::check() ;
	if (!topo)
		return false ;

	CGoGNout << "Check: embedding begin" << CGoGNendl ;
	for(Dart d = begin(); d != end(); next(d))
	{
658
		if (isOrbitEmbedded<VERTEX>())
659
		{
660
			if (getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha1(d)))
661 662 663 664 665 666
			{
				CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ;
				return false ;
			}
		}

667
		if (isOrbitEmbedded<EDGE>())
668
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
669
			if (getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi2(d)))
670 671 672 673 674 675
			{
				CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
				return false ;
			}
		}

676 677 678 679 680 681 682 683
//		if (isOrbitEmbedded(ORIENTED_FACE))
//		{
//			if (getEmbedding(ORIENTED_FACE, d) != getEmbedding(ORIENTED_FACE, phi1(d)))
//		{
//				CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ;
//				return false ;
//			}
//		}
untereiner's avatar
untereiner committed
684

685
		if (isOrbitEmbedded<FACE>())
686
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
687
			if (getEmbedding<FACE>(d) != getEmbedding<FACE>(phi1(d)))
688
			{
689 690 691 692 693
				CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
				return false ;
			}
		}
	}
694

695
	CGoGNout << "Check: embedding ok" << CGoGNendl ;
696

Pierre Kraemer's avatar
Pierre Kraemer committed
697
    std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ;
698 699
	if (isOrbitEmbedded<VERTEX>())
		std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;
700

Pierre Kraemer's avatar
Pierre Kraemer committed
701
    std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ;
702 703
	if (isOrbitEmbedded<EDGE>())
		std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;
704

Pierre Kraemer's avatar
Pierre Kraemer committed
705
    std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ;
706 707
	if (isOrbitEmbedded<FACE>())
		std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;
708

709 710 711 712
	return true ;
}

} // namespace CGoGN