embeddedMap3.cpp 14.7 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#include "Topology/map/embeddedMap3.h"
26 27
#include <vector>
#include <algorithm>
28 29 30 31

namespace CGoGN
{

untereiner's avatar
untereiner committed
32
//TODO
untereiner's avatar
untereiner committed
33
Dart EmbeddedMap3::splitVertex(std::vector<Dart>& vd)
untereiner's avatar
untereiner committed
34
{
Lionel Untereiner's avatar
Lionel Untereiner committed
35
	Dart d = vd.front();
untereiner's avatar
untereiner committed
36
	Dart d2 = phi1(phi2(d));
untereiner's avatar
untereiner committed
37

untereiner's avatar
untereiner committed
38
	Dart dres = Map3::splitVertex(vd);
untereiner's avatar
untereiner committed
39

40
	if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
41
	{
42
		setOrbitEmbeddingOnNewCell<VERTEX>(d2);
43
		copyCell<VERTEX>(d2, d);
44
		setOrbitEmbedding<VERTEX>( d, getEmbedding<VERTEX>(d));
untereiner's avatar
untereiner committed
45 46
	}

47
	if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
48
	{
49
		initOrbitEmbeddingNewCell<EDGE>(dres) ; // TODO : check if dres is a dart of the new edge
untereiner's avatar
untereiner committed
50 51
	}

52
	if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
53
	{
Lionel Untereiner's avatar
Lionel Untereiner committed
54 55
		for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
		{
56
			setOrbitEmbedding<VOLUME>( *it, getEmbedding<VOLUME>(*it)) ;
Lionel Untereiner's avatar
Lionel Untereiner committed
57
		}
untereiner's avatar
untereiner committed
58
	}
untereiner's avatar
untereiner committed
59 60

	return dres;
untereiner's avatar
untereiner committed
61 62
}

untereiner's avatar
untereiner committed
63
//TODO
Pierre Kraemer's avatar
Pierre Kraemer committed
64
Dart EmbeddedMap3::deleteVertex(Dart d)
65
{
untereiner's avatar
untereiner committed
66 67 68
	Dart v = Map3::deleteVertex(d) ;
	if(v != NIL)
	{
69
		if (isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
70
		{
71
			setOrbitEmbedding<VOLUME>(v, getEmbedding<VOLUME>(v)) ;
untereiner's avatar
untereiner committed
72 73 74
		}
	}
	return v ;
75 76
}

David Cazier's avatar
David Cazier committed
77
Dart EmbeddedMap3::cutEdge(Dart d)
78
{
David Cazier's avatar
David Cazier committed
79
	Dart nd = Map3::cutEdge(d);
80

untereiner's avatar
untereiner committed
81 82 83 84
//	if(isOrbitEmbedded<VERTEX>())
//	{
//		initOrbitEmbeddingNewCell<VERTEX>(nd) ;
//	}
85

86
	if(isOrbitEmbedded<EDGE>())
87
	{
untereiner's avatar
untereiner committed
88
		// embed the new darts created in the cut edge
89
		setOrbitEmbedding<EDGE>(d, getEmbedding<EDGE>(d)) ;
untereiner's avatar
untereiner committed
90
		// embed a new cell for the new edge and copy the attributes' line (c) Lionel
91
		setOrbitEmbeddingOnNewCell<EDGE>(nd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
92
		copyCell<EDGE>(nd, d) ;
93 94
	}

95
	if(isOrbitEmbedded<FACE2>())
96 97 98 99
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
100
			Dart f1 = phi1(f) ;
101

Pierre Kraemer's avatar
Pierre Kraemer committed
102
			copyDartEmbedding<FACE2>(f1, f);
Pierre Kraemer's avatar
Pierre Kraemer committed
103
			Dart e = phi3(f1);
Pierre Kraemer's avatar
Pierre Kraemer committed
104
			copyDartEmbedding<FACE2>(phi1(e), e);
untereiner's avatar
untereiner committed
105 106 107 108
			f = alpha2(f);
		} while(f != d);
	}

109
	if(isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
110 111 112 113
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
114 115 116
			unsigned int fEmb = getEmbedding<FACE>(f) ;
			setDartEmbedding<FACE>(phi1(f), fEmb);
			setDartEmbedding<FACE>(phi3(f), fEmb);
117 118 119 120
			f = alpha2(f);
		} while(f != d);
	}

121
	if(isOrbitEmbedded<VOLUME>())
122 123 124 125
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
126 127 128
			unsigned int vEmb = getEmbedding<VOLUME>(f) ;
			setDartEmbedding<VOLUME>(phi1(f), vEmb);
			setDartEmbedding<VOLUME>(phi2(f), vEmb);
129 130 131
			f = alpha2(f);
		} while(f != d);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
132 133

	return nd ;
134 135
}

136
bool EmbeddedMap3::uncutEdge(Dart d)
137
{
138
	if(Map3::uncutEdge(d))
untereiner's avatar
untereiner committed
139
	{
140
		//embed all darts from the old two edges to one of the two edge embedding
141
		if(isOrbitEmbedded<EDGE>())
142
		{
143
			setOrbitEmbedding<EDGE>(d, getEmbedding<EDGE>(d)) ;
144 145
		}
		return true ;
untereiner's avatar
untereiner committed
146
	}
147
	return false ;
148 149
}

untereiner's avatar
untereiner committed
150 151
Dart EmbeddedMap3::deleteEdge(Dart d)
{
152
	Dart v = Map3::deleteEdge(d) ;
untereiner's avatar
untereiner committed
153 154
	if(v != NIL)
	{
155
		if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
156
		{
157
			setOrbitEmbedding<VOLUME>(v, getEmbedding<VOLUME>(v)) ;
untereiner's avatar
untereiner committed
158 159 160 161 162
		}
	}
	return v;
}

163 164
bool EmbeddedMap3::edgeCanCollapse(Dart d)
{
165 166 167 168 169
//	if(isBoundaryVertex(d) || isBoundaryVertex(phi1(d)))
//		return false;
//
//	if(isBoundaryEdge(d))
//		return false;
170 171 172 173 174

	CellMarkerStore<VERTEX> mv(*this);

	Traversor3VVaE<TOPO_MAP> t3VVaE_v1(*this,d);
	for(Dart dit = t3VVaE_v1.begin() ; dit != t3VVaE_v1.end() ; dit = t3VVaE_v1.next())
175
	{
176
		mv.mark(dit);
177
	}
178

179 180
	Traversor3EW<TOPO_MAP> t3EW(*this,d);
	for(Dart dit = t3EW.begin() ; dit != t3EW.end() ; dit = t3EW.next())
181
	{
182 183
		mv.unmark(phi_1(dit));
		mv.unmark(phi_1(phi2(dit)));
184
	}
185

186 187
	Traversor3VVaE<TOPO_MAP> t3VVaE_v2(*this,phi2(d));
	for(Dart dit = t3VVaE_v2.begin() ; dit != t3VVaE_v2.end() ; dit = t3VVaE_v2.next())
188
	{
189 190 191 192 193
		if(mv.isMarked(dit))
			return false;
	}

	return true;
194 195
}

untereiner's avatar
untereiner committed
196 197
Dart EmbeddedMap3::collapseEdge(Dart d, bool delDegenerateVolumes)
{
198
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
untereiner's avatar
untereiner committed
199

200 201 202
	Dart d2 = phi2(phi_1(d)) ;
	Dart dd2 = phi2(phi_1(phi2(d))) ;

untereiner's avatar
untereiner committed
203 204 205 206
	Dart resV = Map3::collapseEdge(d, delDegenerateVolumes);

	if(resV != NIL)
	{
207
		if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
208
		{
209
			setOrbitEmbedding<VERTEX>(resV, vEmb);
untereiner's avatar
untereiner committed
210
		}
211 212 213

		if(isOrbitEmbedded<EDGE>())
		{
214 215
			setOrbitEmbedding<EDGE>(d2, getEmbedding<EDGE>(d2));
			setOrbitEmbedding<EDGE>(dd2, getEmbedding<EDGE>(dd2));
216
		}
untereiner's avatar
untereiner committed
217 218 219 220 221
	}

	return resV;
}

222 223
void EmbeddedMap3::splitFace(Dart d, Dart e)
{
untereiner's avatar
untereiner committed
224 225 226 227
	Dart dd = phi1(phi3(d));
	Dart ee = phi1(phi3(e));

	Map3::splitFace(d, e);
228

229
	if(isOrbitEmbedded<VERTEX>())
230
	{
231 232
		unsigned int vEmb1 = getEmbedding<VERTEX>(d) ;
		unsigned int vEmb2 = getEmbedding<VERTEX>(e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
233 234 235 236
		setDartEmbedding<VERTEX>(phi_1(e), vEmb1);
		setDartEmbedding<VERTEX>(phi_1(ee), vEmb1);
		setDartEmbedding<VERTEX>(phi_1(d), vEmb2);
		setDartEmbedding<VERTEX>(phi_1(dd), vEmb2);
untereiner's avatar
untereiner committed
237
	}
238

untereiner's avatar
untereiner committed
239 240 241 242
//	if(isOrbitEmbedded<EDGE>())
//	{
//		initOrbitEmbeddingNewCell<EDGE>(phi_1(d)) ;
//	}
243

244
	if(isOrbitEmbedded<FACE2>())
untereiner's avatar
untereiner committed
245
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
246
		copyDartEmbedding<FACE2>(phi_1(d), d) ;
247
		setOrbitEmbeddingOnNewCell<FACE2>(e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
248
		copyCell<FACE2>(e, d) ;
249

Pierre Kraemer's avatar
Pierre Kraemer committed
250
		copyDartEmbedding<FACE2>(phi_1(dd), dd) ;
251
		setOrbitEmbeddingOnNewCell<FACE2>(ee) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
252
		copyCell<FACE2>(ee, dd) ;
253 254
	}

255
	if(isOrbitEmbedded<FACE>())
256
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
257 258 259
		unsigned int fEmb = getEmbedding<FACE>(d) ;
		setDartEmbedding<FACE>(phi_1(d), fEmb) ;
		setDartEmbedding<FACE>(phi_1(ee), fEmb) ;
260
		setOrbitEmbeddingOnNewCell<FACE>(e);
Pierre Kraemer's avatar
Pierre Kraemer committed
261
		copyCell<FACE>(e, d);
262 263
	}

264
	if(isOrbitEmbedded<VOLUME>())
265
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
266 267 268
		unsigned int vEmb1 = getEmbedding<VOLUME>(d) ;
		setDartEmbedding<VOLUME>(phi_1(d),  vEmb1);
		setDartEmbedding<VOLUME>(phi_1(e),  vEmb1);
269

Pierre Kraemer's avatar
Pierre Kraemer committed
270 271 272
		unsigned int vEmb2 = getEmbedding<VOLUME>(dd) ;
		setDartEmbedding<VOLUME>(phi_1(dd),  vEmb2);
		setDartEmbedding<VOLUME>(phi_1(ee),  vEmb2);
273 274 275
	}
}

Thomas's avatar
Thomas committed
276 277 278 279 280 281 282 283
bool EmbeddedMap3::mergeFaces(Dart d)
{
	Dart d1 = phi1(d);

	if(Map3::mergeFaces(d))
	{
		if(isOrbitEmbedded<FACE2>())
		{
284
			setOrbitEmbedding<FACE2>(d1, getEmbedding<FACE2>(d1)) ;
Thomas's avatar
Thomas committed
285 286 287 288
		}

		if(isOrbitEmbedded<FACE>())
		{
289
			setOrbitEmbedding<FACE>(d1, getEmbedding<FACE>(d1)) ;
Thomas's avatar
Thomas committed
290 291 292 293 294 295 296 297
		}

		return true;
	}

	return false;
}

298 299 300 301 302 303
//!
/*!
 *
 */
Dart EmbeddedMap3::collapseFace(Dart d, bool delDegenerateVolumes)
{
304
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
305 306 307 308 309

	Dart resV = Map3::collapseFace(d, delDegenerateVolumes);

	if(resV != NIL)
	{
310
		if(isOrbitEmbedded<VERTEX>())
311
		{
312
			setOrbitEmbedding<VERTEX>(resV, vEmb);
313 314 315 316 317 318
		}
	}

	return resV;
}

untereiner's avatar
untereiner committed
319
void EmbeddedMap3::sewVolumes(Dart d, Dart e, bool withBoundary)
320
{
321 322 323 324 325 326
	if (!withBoundary)
	{
		Map3::sewVolumes(d, e, false) ;
		return ;
	}

untereiner's avatar
untereiner committed
327
	Map3::sewVolumes(d, e, withBoundary);
328

Pierre Kraemer's avatar
Pierre Kraemer committed
329 330
	// embed the vertex orbits from the oriented face with dart e
	// with vertex orbits value from oriented face with dart d
331
	if (isOrbitEmbedded<VERTEX>())
332
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
333
		Dart it = d ;
untereiner's avatar
untereiner committed
334 335
		do
		{
336
			setOrbitEmbedding<VERTEX>(it, getEmbedding<VERTEX>(it)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
337 338
			it = phi1(it) ;
		} while(it != d) ;
339 340
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
341 342
	// embed the new edge orbit with the old edge orbit value
	// for all the face
343
	if (isOrbitEmbedded<EDGE>())
344
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
345
		Dart it = d ;
untereiner's avatar
untereiner committed
346 347
		do
		{
348
			setOrbitEmbedding<EDGE>(it, getEmbedding<EDGE>(it)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
349 350
			it = phi1(it) ;
		} while(it != d) ;
351 352
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
353
	// embed the face orbit from the volume sewn
354
	if (isOrbitEmbedded<FACE>())
355
	{
356
		setOrbitEmbedding<FACE>(e, getEmbedding<FACE>(d)) ;
357
	}
358 359 360 361
}

void EmbeddedMap3::unsewVolumes(Dart d)
{
362 363
	Dart dd = alpha1(d);

untereiner's avatar
untereiner committed
364
	unsigned int fEmb = EMBNULL ;
365
	if(isOrbitEmbedded<FACE>())
Pierre Kraemer's avatar
Pierre Kraemer committed
366
		fEmb = getEmbedding<FACE>(d) ;
untereiner's avatar
untereiner committed
367

Pierre Kraemer's avatar
Pierre Kraemer committed
368 369
	Map3::unsewVolumes(d);

untereiner's avatar
untereiner committed
370 371 372 373
	Dart dit = d;
	do
	{
		// embed the unsewn vertex orbit with the vertex embedding if it is deconnected
374
		if(isOrbitEmbedded<VERTEX>())
Thomas's avatar
Thomas committed
375
		{
untereiner's avatar
untereiner committed
376
			if(!sameVertex(dit, dd))
Thomas's avatar
Thomas committed
377
			{
378
				setOrbitEmbedding<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ;
379
				setOrbitEmbeddingOnNewCell<VERTEX>(dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
380
				copyCell<VERTEX>(dd, dit);
381 382 383
			}
			else
			{
384
				setOrbitEmbedding<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ;
Thomas's avatar
Thomas committed
385
			}
untereiner's avatar
untereiner committed
386
		}
Thomas's avatar
Thomas committed
387

untereiner's avatar
untereiner committed
388
		dd = phi_1(dd);
Thomas's avatar
Thomas committed
389

untereiner's avatar
untereiner committed
390
		// embed the unsewn edge with the edge embedding if it is deconnected
391
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
392 393
		{
			if(!sameEdge(dit, dd))
Thomas's avatar
Thomas committed
394
			{
395
				setOrbitEmbeddingOnNewCell<EDGE>(dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
396 397
				copyCell<EDGE>(dd, dit);
				copyDartEmbedding<EDGE>(phi3(dit), dit) ;
398 399 400
			}
			else
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
401 402 403
				unsigned int eEmb = getEmbedding<EDGE>(dit) ;
				setDartEmbedding<EDGE>(phi3(dit), eEmb) ;
				setDartEmbedding<EDGE>(alpha_2(dit), eEmb) ;
Thomas's avatar
Thomas committed
404
			}
untereiner's avatar
untereiner committed
405
		}
Thomas's avatar
Thomas committed
406

407
		if(isOrbitEmbedded<FACE>())
Thomas's avatar
Thomas committed
408
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
409
			setDartEmbedding<FACE>(phi3(dit), fEmb) ;
Thomas's avatar
Thomas committed
410
		}
untereiner's avatar
untereiner committed
411 412 413 414 415

		dit = phi1(dit);
	} while(dit != d);

	// embed the unsewn face with the face embedding
416
	if (isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
417
	{
418
		setOrbitEmbeddingOnNewCell<FACE>(dd);
Pierre Kraemer's avatar
Pierre Kraemer committed
419
		copyCell<FACE>(dd, d);
Thomas's avatar
Thomas committed
420
	}
421 422 423 424 425 426 427 428
}

bool EmbeddedMap3::mergeVolumes(Dart d)
{
	Dart d2 = phi2(d);

	if(Map3::mergeVolumes(d))
	{
429
		if (isOrbitEmbedded<VOLUME>())
430
		{
431
			setOrbitEmbedding<VOLUME>(d2, getEmbedding<VOLUME>(d2)) ;
432 433 434 435 436 437
		}
		return true;
	}
	return false;
}

untereiner's avatar
untereiner committed
438 439 440 441
void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
{
	Map3::splitVolume(vd);

untereiner's avatar
untereiner committed
442
	// follow the edge path a second time to embed the vertex, edge and volume orbits
untereiner's avatar
untereiner committed
443 444 445
	for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
	{
		Dart dit = *it;
446
		Dart dit23 = phi3(phi2(dit));
untereiner's avatar
untereiner committed
447

untereiner's avatar
untereiner committed
448
		// embed the vertex embedded from the origin volume to the new darts
449
		if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
450
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
451 452
			copyDartEmbedding<VERTEX>(dit23, dit);
			copyDartEmbedding<VERTEX>(phi2(dit), phi1(dit));
untereiner's avatar
untereiner committed
453 454
		}

455 456 457 458 459 460 461 462 463
		// embed the edge embedded from the origin volume to the new darts
		if(isOrbitEmbedded<EDGE2>())
		{
			setOrbitEmbeddingOnNewCell<EDGE2>(dit23) ;
			copyCell<EDGE2>(dit23, dit) ;

			copyDartEmbedding<EDGE2>(phi2(dit), dit);
		}

untereiner's avatar
untereiner committed
464
		// embed the edge embedded from the origin volume to the new darts
465
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
466
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
467 468 469
			unsigned int eEmb = getEmbedding<EDGE>(dit) ;
			setDartEmbedding<EDGE>(dit23, eEmb);
			setDartEmbedding<EDGE>(phi2(dit), eEmb);
untereiner's avatar
untereiner committed
470 471
		}

untereiner's avatar
untereiner committed
472
		// embed the volume embedded from the origin volume to the new darts
473
		if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
474
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
475
			copyDartEmbedding<VOLUME>(phi2(dit), dit);
untereiner's avatar
untereiner committed
476 477
		}
	}
untereiner's avatar
untereiner committed
478

479
	if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
480
	{
481
		Dart v = vd.front() ;
482
		Dart v23 = phi3(phi2(v));
483
		setOrbitEmbeddingOnNewCell<VOLUME>(v23) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
484
		copyCell<VOLUME>(v23, v) ;
untereiner's avatar
untereiner committed
485 486 487
	}
}

488 489
Dart EmbeddedMap3::collapseVolume(Dart d, bool delDegenerateVolumes)
{
490
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
491 492 493 494 495

	Dart resV = Map3::collapseVolume(d, delDegenerateVolumes);

	if(resV != NIL)
	{
496
		if(isOrbitEmbedded<VERTEX>())
497
		{
498
			setOrbitEmbedding<VERTEX>(resV, vEmb);
499 500 501 502 503 504
		}
	}

	return resV;
}

untereiner's avatar
untereiner committed
505 506 507 508 509 510 511 512
unsigned int EmbeddedMap3::closeHole(Dart d, bool forboundary)
{
	unsigned int nbF = Map3::closeHole(d, forboundary) ;

	DartMarkerStore mark(*this);	// Lock a marker

	std::vector<Dart> visitedFaces;	// Faces that are traversed
	visitedFaces.reserve(1024) ;
513
	visitedFaces.push_back(phi3(d));// Start with the face of d
Pierre Kraemer's avatar
Pierre Kraemer committed
514
	mark.markOrbit<FACE2>(phi3(d)) ;
untereiner's avatar
untereiner committed
515 516

	// For every face added to the list
517
	for(unsigned int i = 0; i < visitedFaces.size(); ++i)
untereiner's avatar
untereiner committed
518
	{
519 520
		Dart it = visitedFaces[i] ;
		Dart f = it ;
521
		do
untereiner's avatar
untereiner committed
522
		{
523
			if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
524
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
525
				copyDartEmbedding<VERTEX>(f, alpha1(f)) ;
526
			}
527
			if(isOrbitEmbedded<EDGE>())
528
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
529
				copyDartEmbedding<EDGE>(f, phi3(f)) ;
530
			}
531
			if(isOrbitEmbedded<FACE>())
532
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
533
				copyDartEmbedding<FACE>(f, phi3(f)) ;
534 535 536 537 538 539
			}

			Dart adj = phi2(f);	// Get adjacent face
			if (!mark.isMarked(adj))
			{
				visitedFaces.push_back(adj);	// Add it
Pierre Kraemer's avatar
Pierre Kraemer committed
540
				mark.markOrbit<FACE2>(adj) ;
541 542 543
			}

			f = phi1(f) ;
544
		} while(f != it) ;
untereiner's avatar
untereiner committed
545 546 547
	}

	return nbF ;
untereiner's avatar
untereiner committed
548 549
}

550
bool EmbeddedMap3::check()
551
{
Pierre Kraemer's avatar
Pierre Kraemer committed
552
    std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ;
553 554
    std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;

Pierre Kraemer's avatar
Pierre Kraemer committed
555
    std::cout << "nb edge orbits : " << getNbOrbits<EDGE>() << std::endl ;
556 557
    std::cout << "nb edge cells : " << m_attribs[EDGE].size() << std::endl ;

Pierre Kraemer's avatar
Pierre Kraemer committed
558
    std::cout << "nb face orbits : " << getNbOrbits<FACE>() << std::endl ;
559 560
    std::cout << "nb face cells : " << m_attribs[FACE].size() << std::endl ;

Pierre Kraemer's avatar
Pierre Kraemer committed
561
    std::cout << "nb volume orbits : " << getNbOrbits<VOLUME>() << std::endl ;
562 563 564
    std::cout << "nb volume cells : " << m_attribs[VOLUME].size() << std::endl ;


untereiner's avatar
untereiner committed
565 566 567 568 569 570
	bool topo = Map3::check() ;
	if (!topo)
		return false ;

	std::cout << "Check: embedding begin" << std::endl ;

571
	for(Dart d = begin(); d != end(); next(d))
572
	{
573
		if(isOrbitEmbedded<VERTEX>())
574
		{
575
			if( getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha1(d)))
576 577 578 579
			{
				std::cout << "Embedding Check : different embeddings on vertex (alpha1(d) != d)" << std::endl ;
				return false ;
			}
580
			if(getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha2(d)) )
581
			{
582
				std::cout << "Embedding Check : different embeddings on vertex (alpha2(d) != d)" << std::endl ;
untereiner's avatar
untereiner committed
583 584 585 586
				return false ;
			}
		}

587
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
588
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
589 590
			if( getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi2(d)) ||
					getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi3(d)) )
untereiner's avatar
untereiner committed
591 592 593 594 595 596
			{
				std::cout << "Embedding Check : different embeddings on edge" << std::endl ;
				return false ;
			}
		}

597
		if (isOrbitEmbedded<FACE2>())
untereiner's avatar
untereiner committed
598
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
599
			if (getEmbedding<FACE2>(d) != getEmbedding<FACE2>(phi1(d)))
untereiner's avatar
untereiner committed
600 601 602
			{
				CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ;
				return false ;
603
			}
604
		}
605

606
		if (isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
607
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
608 609
			if( getEmbedding<FACE>(d) != getEmbedding<FACE>(phi1(d)) ||
					getEmbedding<FACE>(d) != getEmbedding<FACE>(phi3(d)) )
untereiner's avatar
untereiner committed
610 611 612 613 614 615
			{
				CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
				return false ;
			}
		}

616
		if (isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
617
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
618 619
			if( getEmbedding<VOLUME>(d) != getEmbedding<VOLUME>(phi1(d)) ||
					getEmbedding<VOLUME>(d) != getEmbedding<VOLUME>(phi2(d)) )
untereiner's avatar
untereiner committed
620 621 622 623 624
			{
				CGoGNout << "Check: different embeddings on volume" << CGoGNendl ;
				return false ;
			}
		}
625
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
626

627
	std::cout << "Check: embedding ok" << std::endl ;
628

629
	return true ;
630 631 632
}

} // namespace CGoGN