embeddedMap3.cpp 13.9 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
Dart EmbeddedMap3::splitVertex(std::vector<Dart>& vd)
untereiner's avatar
untereiner committed
33
{
Lionel Untereiner's avatar
Lionel Untereiner committed
34
	Dart d = vd.front();
untereiner's avatar
untereiner committed
35
	Dart d2 = phi1(phi2(d));
untereiner's avatar
untereiner committed
36

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

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

46
	if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
47
48
49
50
	{

	}

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

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

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

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

79
	if(isOrbitEmbedded<EDGE>())
80
	{
untereiner's avatar
untereiner committed
81
		// embed the new darts created in the cut edge
Pierre Kraemer's avatar
Pierre Kraemer committed
82
		embedOrbit<EDGE>(d, getEmbedding<EDGE>(d)) ;
untereiner's avatar
untereiner committed
83
		// embed a new cell for the new edge and copy the attributes' line (c) Lionel
Pierre Kraemer's avatar
Pierre Kraemer committed
84
85
		embedNewCell<EDGE>(nd) ;
		copyCell<EDGE>(nd, d) ;
86
87
	}

88
	if(isOrbitEmbedded<FACE2>())
89
90
91
92
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
93
			Dart f1 = phi1(f) ;
94

Pierre Kraemer's avatar
Pierre Kraemer committed
95
			copyDartEmbedding<FACE2>(f1, f);
Pierre Kraemer's avatar
Pierre Kraemer committed
96
			Dart e = phi3(f1);
Pierre Kraemer's avatar
Pierre Kraemer committed
97
			copyDartEmbedding<FACE2>(phi1(e), e);
untereiner's avatar
untereiner committed
98
99
100
101
			f = alpha2(f);
		} while(f != d);
	}

102
	if(isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
103
104
105
106
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
107
108
109
			unsigned int fEmb = getEmbedding<FACE>(f) ;
			setDartEmbedding<FACE>(phi1(f), fEmb);
			setDartEmbedding<FACE>(phi3(f), fEmb);
110
111
112
113
			f = alpha2(f);
		} while(f != d);
	}

114
	if(isOrbitEmbedded<VOLUME>())
115
116
117
118
	{
		Dart f = d;
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
119
120
121
			unsigned int vEmb = getEmbedding<VOLUME>(f) ;
			setDartEmbedding<VOLUME>(phi1(f), vEmb);
			setDartEmbedding<VOLUME>(phi2(f), vEmb);
122
123
124
			f = alpha2(f);
		} while(f != d);
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
125
126

	return nd ;
127
128
}

129
bool EmbeddedMap3::uncutEdge(Dart d)
130
{
131
	if(Map3::uncutEdge(d))
untereiner's avatar
untereiner committed
132
	{
133
		//embed all darts from the old two edges to one of the two edge embedding
134
		if(isOrbitEmbedded<EDGE>())
135
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
136
			embedOrbit<EDGE>(d, getEmbedding<EDGE>(d)) ;
137
138
		}
		return true ;
untereiner's avatar
untereiner committed
139
	}
140
	return false ;
141
142
}

untereiner's avatar
untereiner committed
143
144
Dart EmbeddedMap3::deleteEdge(Dart d)
{
145
	Dart v = Map3::deleteEdge(d) ;
untereiner's avatar
untereiner committed
146
147
	if(v != NIL)
	{
148
		if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
149
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
150
			embedOrbit<VOLUME>(v, getEmbedding<VOLUME>(v)) ;
untereiner's avatar
untereiner committed
151
152
153
154
155
		}
	}
	return v;
}

156
157
bool EmbeddedMap3::edgeCanCollapse(Dart d)
{
158
159
160
161
162
//	if(isBoundaryVertex(d) || isBoundaryVertex(phi1(d)))
//		return false;
//
//	if(isBoundaryEdge(d))
//		return false;
163
164
165
166
167

	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())
168
	{
169
		mv.mark(dit);
170
	}
171

172
173
	Traversor3EW<TOPO_MAP> t3EW(*this,d);
	for(Dart dit = t3EW.begin() ; dit != t3EW.end() ; dit = t3EW.next())
174
	{
175
176
		mv.unmark(phi_1(dit));
		mv.unmark(phi_1(phi2(dit)));
177
	}
178

179
180
	Traversor3VVaE<TOPO_MAP> t3VVaE_v2(*this,phi2(d));
	for(Dart dit = t3VVaE_v2.begin() ; dit != t3VVaE_v2.end() ; dit = t3VVaE_v2.next())
181
	{
182
183
184
185
186
		if(mv.isMarked(dit))
			return false;
	}

	return true;
187
188
}

untereiner's avatar
untereiner committed
189
190
Dart EmbeddedMap3::collapseEdge(Dart d, bool delDegenerateVolumes)
{
191
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
untereiner's avatar
untereiner committed
192

193
194
195
	Dart d2 = phi2(phi_1(d)) ;
	Dart dd2 = phi2(phi_1(phi2(d))) ;

untereiner's avatar
untereiner committed
196
197
198
199
	Dart resV = Map3::collapseEdge(d, delDegenerateVolumes);

	if(resV != NIL)
	{
200
		if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
201
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
202
			embedOrbit<VERTEX>(resV, vEmb);
untereiner's avatar
untereiner committed
203
		}
204
205
206
207
208
209

		if(isOrbitEmbedded<EDGE>())
		{
			embedOrbit<EDGE>(d2, getEmbedding<EDGE>(d2));
			embedOrbit<EDGE>(dd2, getEmbedding<EDGE>(dd2));
		}
untereiner's avatar
untereiner committed
210
211
212
213
214
	}

	return resV;
}

215
216
void EmbeddedMap3::splitFace(Dart d, Dart e)
{
untereiner's avatar
untereiner committed
217
218
219
220
	Dart dd = phi1(phi3(d));
	Dart ee = phi1(phi3(e));

	Map3::splitFace(d, e);
221

222
	if(isOrbitEmbedded<VERTEX>())
223
	{
224
225
		unsigned int vEmb1 = getEmbedding<VERTEX>(d) ;
		unsigned int vEmb2 = getEmbedding<VERTEX>(e) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
226
227
228
229
		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
230
	}
231

232
	if(isOrbitEmbedded<FACE2>())
untereiner's avatar
untereiner committed
233
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
234
235
236
		copyDartEmbedding<FACE2>(phi_1(d), d) ;
		embedNewCell<FACE2>(e) ;
		copyCell<FACE2>(e, d) ;
237

Pierre Kraemer's avatar
Pierre Kraemer committed
238
239
240
		copyDartEmbedding<FACE2>(phi_1(dd), dd) ;
		embedNewCell<FACE2>(ee) ;
		copyCell<FACE2>(ee, dd) ;
241
242
	}

243
	if(isOrbitEmbedded<FACE>())
244
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
245
246
247
248
249
		unsigned int fEmb = getEmbedding<FACE>(d) ;
		setDartEmbedding<FACE>(phi_1(d), fEmb) ;
		setDartEmbedding<FACE>(phi_1(ee), fEmb) ;
		embedNewCell<FACE>(e);
		copyCell<FACE>(e, d);
250
251
	}

252
	if(isOrbitEmbedded<VOLUME>())
253
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
254
255
256
		unsigned int vEmb1 = getEmbedding<VOLUME>(d) ;
		setDartEmbedding<VOLUME>(phi_1(d),  vEmb1);
		setDartEmbedding<VOLUME>(phi_1(e),  vEmb1);
257

Pierre Kraemer's avatar
Pierre Kraemer committed
258
259
260
		unsigned int vEmb2 = getEmbedding<VOLUME>(dd) ;
		setDartEmbedding<VOLUME>(phi_1(dd),  vEmb2);
		setDartEmbedding<VOLUME>(phi_1(ee),  vEmb2);
261
262
263
	}
}

Thomas's avatar
Thomas committed
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
bool EmbeddedMap3::mergeFaces(Dart d)
{
	Dart d1 = phi1(d);

	if(Map3::mergeFaces(d))
	{
		if(isOrbitEmbedded<FACE2>())
		{
			embedOrbit<FACE2>(d1, getEmbedding<FACE2>(d1)) ;
		}

		if(isOrbitEmbedded<FACE>())
		{
			embedOrbit<FACE>(d1, getEmbedding<FACE>(d1)) ;
		}

		return true;
	}

	return false;
}

286
287
288
289
290
291
//!
/*!
 *
 */
Dart EmbeddedMap3::collapseFace(Dart d, bool delDegenerateVolumes)
{
292
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
293
294
295
296
297

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

	if(resV != NIL)
	{
298
		if(isOrbitEmbedded<VERTEX>())
299
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
300
			embedOrbit<VERTEX>(resV, vEmb);
301
302
303
304
305
306
		}
	}

	return resV;
}

untereiner's avatar
untereiner committed
307
void EmbeddedMap3::sewVolumes(Dart d, Dart e, bool withBoundary)
308
{
309
310
311
312
313
314
	if (!withBoundary)
	{
		Map3::sewVolumes(d, e, false) ;
		return ;
	}

untereiner's avatar
untereiner committed
315
	Map3::sewVolumes(d, e, withBoundary);
316

Pierre Kraemer's avatar
Pierre Kraemer committed
317
318
	// embed the vertex orbits from the oriented face with dart e
	// with vertex orbits value from oriented face with dart d
319
	if (isOrbitEmbedded<VERTEX>())
320
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
321
		Dart it = d ;
untereiner's avatar
untereiner committed
322
323
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
324
			embedOrbit<VERTEX>(it, getEmbedding<VERTEX>(it)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
325
326
			it = phi1(it) ;
		} while(it != d) ;
327
328
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
329
330
	// embed the new edge orbit with the old edge orbit value
	// for all the face
331
	if (isOrbitEmbedded<EDGE>())
332
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
333
		Dart it = d ;
untereiner's avatar
untereiner committed
334
335
		do
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
336
			embedOrbit<EDGE>(it, getEmbedding<EDGE>(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
	// embed the face orbit from the volume sewn
342
	if (isOrbitEmbedded<FACE>())
343
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
344
		embedOrbit<FACE>(e, getEmbedding<FACE>(d)) ;
345
	}
346
347
348
349
}

void EmbeddedMap3::unsewVolumes(Dart d)
{
350
351
	Dart dd = alpha1(d);

untereiner's avatar
untereiner committed
352
	unsigned int fEmb = EMBNULL ;
353
	if(isOrbitEmbedded<FACE>())
Pierre Kraemer's avatar
Pierre Kraemer committed
354
		fEmb = getEmbedding<FACE>(d) ;
untereiner's avatar
untereiner committed
355

Pierre Kraemer's avatar
Pierre Kraemer committed
356
357
	Map3::unsewVolumes(d);

untereiner's avatar
untereiner committed
358
359
360
361
	Dart dit = d;
	do
	{
		// embed the unsewn vertex orbit with the vertex embedding if it is deconnected
362
		if(isOrbitEmbedded<VERTEX>())
Thomas's avatar
Thomas committed
363
		{
untereiner's avatar
untereiner committed
364
			if(!sameVertex(dit, dd))
Thomas's avatar
Thomas committed
365
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
366
367
368
				embedOrbit<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ;
				embedNewCell<VERTEX>(dd);
				copyCell<VERTEX>(dd, dit);
369
370
371
			}
			else
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
372
				embedOrbit<VERTEX>(dit, getEmbedding<VERTEX>(dit)) ;
Thomas's avatar
Thomas committed
373
			}
untereiner's avatar
untereiner committed
374
		}
Thomas's avatar
Thomas committed
375

untereiner's avatar
untereiner committed
376
		dd = phi_1(dd);
Thomas's avatar
Thomas committed
377

untereiner's avatar
untereiner committed
378
		// embed the unsewn edge with the edge embedding if it is deconnected
379
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
380
381
		{
			if(!sameEdge(dit, dd))
Thomas's avatar
Thomas committed
382
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
383
384
385
				embedNewCell<EDGE>(dd);
				copyCell<EDGE>(dd, dit);
				copyDartEmbedding<EDGE>(phi3(dit), dit) ;
386
387
388
			}
			else
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
389
390
391
				unsigned int eEmb = getEmbedding<EDGE>(dit) ;
				setDartEmbedding<EDGE>(phi3(dit), eEmb) ;
				setDartEmbedding<EDGE>(alpha_2(dit), eEmb) ;
Thomas's avatar
Thomas committed
392
			}
untereiner's avatar
untereiner committed
393
		}
Thomas's avatar
Thomas committed
394

395
		if(isOrbitEmbedded<FACE>())
Thomas's avatar
Thomas committed
396
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
397
			setDartEmbedding<FACE>(phi3(dit), fEmb) ;
Thomas's avatar
Thomas committed
398
		}
untereiner's avatar
untereiner committed
399
400
401
402
403

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

	// embed the unsewn face with the face embedding
404
	if (isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
405
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
406
407
		embedNewCell<FACE>(dd);
		copyCell<FACE>(dd, d);
Thomas's avatar
Thomas committed
408
	}
409
410
411
412
413
414
415
416
}

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

	if(Map3::mergeVolumes(d))
	{
417
		if (isOrbitEmbedded<VOLUME>())
418
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
419
			embedOrbit<VOLUME>(d2, getEmbedding<VOLUME>(d2)) ;
420
421
422
423
424
425
		}
		return true;
	}
	return false;
}

untereiner's avatar
untereiner committed
426
427
428
429
void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
{
	Map3::splitVolume(vd);

untereiner's avatar
untereiner committed
430
	// follow the edge path a second time to embed the vertex, edge and volume orbits
untereiner's avatar
untereiner committed
431
432
433
	for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
	{
		Dart dit = *it;
untereiner's avatar
untereiner committed
434
		Dart dit23 = alpha2(dit);
untereiner's avatar
untereiner committed
435

untereiner's avatar
untereiner committed
436
		// embed the vertex embedded from the origin volume to the new darts
437
		if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
438
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
439
440
			copyDartEmbedding<VERTEX>(dit23, dit);
			copyDartEmbedding<VERTEX>(phi2(dit), phi1(dit));
untereiner's avatar
untereiner committed
441
442
		}

untereiner's avatar
untereiner committed
443
		// embed the edge embedded from the origin volume to the new darts
444
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
445
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
446
447
448
			unsigned int eEmb = getEmbedding<EDGE>(dit) ;
			setDartEmbedding<EDGE>(dit23, eEmb);
			setDartEmbedding<EDGE>(phi2(dit), eEmb);
untereiner's avatar
untereiner committed
449
450
		}

untereiner's avatar
untereiner committed
451
		// embed the volume embedded from the origin volume to the new darts
452
		if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
453
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
454
			copyDartEmbedding<VOLUME>(phi2(dit), dit);
untereiner's avatar
untereiner committed
455
456
		}
	}
untereiner's avatar
untereiner committed
457

458
	if(isOrbitEmbedded<VOLUME>())
untereiner's avatar
untereiner committed
459
	{
460
		Dart v = vd.front() ;
untereiner's avatar
untereiner committed
461
		Dart v23 = alpha2(v) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
462
463
		embedNewCell<VOLUME>(v23) ;
		copyCell<VOLUME>(v23, v) ;
untereiner's avatar
untereiner committed
464
465
466
	}
}

467
468
Dart EmbeddedMap3::collapseVolume(Dart d, bool delDegenerateVolumes)
{
469
	unsigned int vEmb = getEmbedding<VERTEX>(d) ;
470
471
472
473
474

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

	if(resV != NIL)
	{
475
		if(isOrbitEmbedded<VERTEX>())
476
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
477
			embedOrbit<VERTEX>(resV, vEmb);
478
479
480
481
482
483
		}
	}

	return resV;
}

untereiner's avatar
untereiner committed
484
485
486
487
488
489
490
491
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) ;
492
	visitedFaces.push_back(phi3(d));// Start with the face of d
Pierre Kraemer's avatar
Pierre Kraemer committed
493
	mark.markOrbit<FACE2>(phi3(d)) ;
untereiner's avatar
untereiner committed
494
495

	// For every face added to the list
496
	for(unsigned int i = 0; i < visitedFaces.size(); ++i)
untereiner's avatar
untereiner committed
497
	{
498
499
		Dart it = visitedFaces[i] ;
		Dart f = it ;
500
		do
untereiner's avatar
untereiner committed
501
		{
502
			if(isOrbitEmbedded<VERTEX>())
untereiner's avatar
untereiner committed
503
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
504
				copyDartEmbedding<VERTEX>(f, alpha1(f)) ;
505
			}
506
			if(isOrbitEmbedded<EDGE>())
507
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
508
				copyDartEmbedding<EDGE>(f, phi3(f)) ;
509
			}
510
			if(isOrbitEmbedded<FACE>())
511
			{
Pierre Kraemer's avatar
Pierre Kraemer committed
512
				copyDartEmbedding<FACE>(f, phi3(f)) ;
513
514
515
516
517
518
			}

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

			f = phi1(f) ;
523
		} while(f != it) ;
untereiner's avatar
untereiner committed
524
525
526
	}

	return nbF ;
untereiner's avatar
untereiner committed
527
528
}

529
bool EmbeddedMap3::check()
530
{
531
532
533
	bool topo = Map3::check() ;
	if (!topo)
		return false ;
534

535
	std::cout << "Check: embedding begin" << std::endl ;
Pierre Kraemer's avatar
Pierre Kraemer committed
536

Pierre Kraemer's avatar
Pierre Kraemer committed
537
    std::cout << "nb vertex orbits : " << getNbOrbits<VERTEX>() << std::endl ;
538
539
    std::cout << "nb vertex cells : " << m_attribs[VERTEX].size() << std::endl ;

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

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

Pierre Kraemer's avatar
Pierre Kraemer committed
546
    std::cout << "nb volume orbits : " << getNbOrbits<VOLUME>() << std::endl ;
547
548
549
    std::cout << "nb volume cells : " << m_attribs[VOLUME].size() << std::endl ;


550
	for(Dart d = begin(); d != end(); next(d))
551
	{
552
		if(isOrbitEmbedded<VERTEX>())
553
		{
554
			if( getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha1(d)))
555
556
557
558
			{
				std::cout << "Embedding Check : different embeddings on vertex (alpha1(d) != d)" << std::endl ;
				return false ;
			}
559
			if(getEmbedding<VERTEX>(d) != getEmbedding<VERTEX>(alpha2(d)) )
560
			{
561
				std::cout << "Embedding Check : different embeddings on vertex (alpha2(d) != d)" << std::endl ;
untereiner's avatar
untereiner committed
562
563
564
565
				return false ;
			}
		}

566
		if(isOrbitEmbedded<EDGE>())
untereiner's avatar
untereiner committed
567
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
568
569
			if( getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi2(d)) ||
					getEmbedding<EDGE>(d) != getEmbedding<EDGE>(phi3(d)) )
untereiner's avatar
untereiner committed
570
571
572
573
574
575
			{
				std::cout << "Embedding Check : different embeddings on edge" << std::endl ;
				return false ;
			}
		}

576
		if (isOrbitEmbedded<FACE2>())
untereiner's avatar
untereiner committed
577
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
578
			if (getEmbedding<FACE2>(d) != getEmbedding<FACE2>(phi1(d)))
untereiner's avatar
untereiner committed
579
580
581
			{
				CGoGNout << "Check: different embeddings on oriented face" << CGoGNendl ;
				return false ;
582
			}
583
		}
584

585
		if (isOrbitEmbedded<FACE>())
untereiner's avatar
untereiner committed
586
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
587
588
			if( getEmbedding<FACE>(d) != getEmbedding<FACE>(phi1(d)) ||
					getEmbedding<FACE>(d) != getEmbedding<FACE>(phi3(d)) )
untereiner's avatar
untereiner committed
589
590
591
592
593
594
			{
				CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
				return false ;
			}
		}

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

606
	std::cout << "Check: embedding ok" << std::endl ;
607

608
	return true ;
609
610
611
}

} // namespace CGoGN