ihm3.hpp 17.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
29
30
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

namespace CGoGN
{

namespace Algo
{

untereiner's avatar
untereiner committed
31
namespace IHM
32
33
{

34
/***************************************************
35
 *  	   ATTRIBUTES MANAGEMENT    	           	 *
36
37
 ***************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
38
39
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::addAttribute(const std::string& nameAttr)
40
41
{
	bool addNextLevelCell = false ;
42
	if(!isOrbitEmbedded<ORBIT>())
43
44
		addNextLevelCell = true ;

Pierre Kraemer's avatar
Pierre Kraemer committed
45
	AttributeHandler<T, ORBIT> h = Map3::addAttribute<T, ORBIT>(nameAttr) ;
46
47
48

	if(addNextLevelCell)
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
49
		AttributeContainer& cellCont = m_attribs[ORBIT] ;
50
		AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
Pierre Kraemer's avatar
Pierre Kraemer committed
51
		m_nextLevelCell[ORBIT] = amv ;
52
53
54
55
		for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
			amv->operator[](i) = EMBNULL ;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
56
	return AttributeHandler_IHM<T, ORBIT>(this, h.getDataVector()) ;
57
58
}

Pierre Kraemer's avatar
Pierre Kraemer committed
59
60
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::getAttribute(const std::string& nameAttr)
61
{
Pierre Kraemer's avatar
Pierre Kraemer committed
62
63
	AttributeHandler<T, ORBIT> h = Map3::getAttribute<T, ORBIT>(nameAttr) ;
	return AttributeHandler_IHM<T, ORBIT>(this, h.getDataVector()) ;
64
}
untereiner's avatar
untereiner committed
65

66
67
68
69

inline void ImplicitHierarchicalMap3::update_topo_shortcuts()
{
	Map3::update_topo_shortcuts();
Pierre Kraemer's avatar
Pierre Kraemer committed
70
71
72
	m_dartLevel = Map3::getAttribute<unsigned int, DART>("dartLevel") ;
	m_faceId = Map3::getAttribute<unsigned int, DART>("faceId") ;
	m_edgeId = Map3::getAttribute<unsigned int, DART>("edgeId") ;
73
74
75

	//AttributeContainer& cont = m_attribs[DART] ;
	//m_nextLevelCell = cont.getDataVector<unsigned int>(cont.getAttributeIndex("nextLevelCell")) ;
76
77
78
}


79
/***************************************************
untereiner's avatar
untereiner committed
80
 *          			 	    MAP TRAVERSAL         		  		         *
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
 ***************************************************/

inline Dart ImplicitHierarchicalMap3::newDart()
{
	Dart d = Map3::newDart() ;
	m_dartLevel[d] = m_curLevel ;
	if(m_curLevel > m_maxLevel)			// update max level
		m_maxLevel = m_curLevel ;		// if needed
	return d ;
}

inline Dart ImplicitHierarchicalMap3::phi1(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
	bool finished = false ;

	unsigned int edgeId = m_edgeId[d] ;
	Dart it = d ;
untereiner's avatar
untereiner committed
99

100
101
	do
	{
untereiner's avatar
untereiner committed
102

103
104
105
106
107
		it = Map3::phi1(it) ;
		if(m_dartLevel[it] <= m_curLevel)
			finished = true ;
		else
		{
108
			while(m_edgeId[it] != edgeId)
109
				it = Map3::phi1(phi2bis(it));
untereiner's avatar
untereiner committed
110

111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
		}
	} while(!finished) ;

	return it ;
}

inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
	bool finished = false ;

	Dart it = Map3::phi_1(d) ;
	unsigned int edgeId = m_edgeId[it] ;
	do
	{
		if(m_dartLevel[it] <= m_curLevel)
			finished = true ;
		else
		{
			it = Map3::phi_1(it) ;
131
			while(m_edgeId[it] != edgeId)
untereiner's avatar
untereiner committed
132
				it = Map3::phi_1(phi2bis(it));
133
134
135
136
137
138
139
140
141
142
143
144
		}
	} while(!finished) ;

	return it ;
}

inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d)
{
	unsigned int faceId = m_faceId[d];
	Dart it = d;

	it = Map3::phi2(it) ;
untereiner's avatar
untereiner committed
145

146
147
148
149
	if(m_faceId[it] == faceId)
		return it;
	else
	{
untereiner's avatar
untereiner committed
150
151
		do
		{
152
			it = Map3::phi2(Map3::phi3(it));
untereiner's avatar
untereiner committed
153
154
		}
		while(m_faceId[it] != faceId);
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

		return it;
	}
}

inline Dart ImplicitHierarchicalMap3::phi2(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

	return Map3::phi2(Map3::phi_1(phi1(d))) ;
}

inline Dart ImplicitHierarchicalMap3::phi3(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

	if(Map3::phi3(d) == d)
		return d;

	return Map3::phi3(Map3::phi_1(phi1(d)));
}

inline Dart ImplicitHierarchicalMap3::alpha0(Dart d)
{
	return phi3(d) ;
}

inline Dart ImplicitHierarchicalMap3::alpha1(Dart d)
{
184
	//assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
185

186
	return phi3(phi_1(d)) ;
187
188
189
190
}

inline Dart ImplicitHierarchicalMap3::alpha2(Dart d)
{
untereiner's avatar
untereiner committed
191
192
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

193
	return phi3(phi2(d));
194
195
196
197
}

inline Dart ImplicitHierarchicalMap3::alpha_2(Dart d)
{
untereiner's avatar
untereiner committed
198
199
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

200
	return phi2(phi3(d));
201
202
}

203
inline Dart ImplicitHierarchicalMap3::begin() const
204
205
206
207
208
209
210
{
	Dart d = Map3::begin() ;
	while(m_dartLevel[d] > m_curLevel)
		Map3::next(d) ;
	return d ;
}

211
inline Dart ImplicitHierarchicalMap3::end() const
212
213
214
215
{
	return Map3::end() ;
}

216
inline void ImplicitHierarchicalMap3::next(Dart& d) const
217
218
219
220
{
	do
	{
		Map3::next(d) ;
221
	} while(d != Map3::end() && m_dartLevel[d] > m_curLevel) ;
222
223
}

224
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
225
{
untereiner's avatar
untereiner committed
226
	DartMarkerStore mv(*this, thread);	// Lock a marker
227
228
	bool found = false;					// Last functor return value

untereiner's avatar
untereiner committed
229
230
231
	std::vector<Dart> darts;	// Darts that are traversed
	darts.reserve(256);
	darts.push_back(d);			// Start with the dart d
232
233
	mv.mark(d);

234
	for(unsigned int i = 0; !found && i < darts.size(); ++i)
235
	{
untereiner's avatar
untereiner committed
236
237
238
239
		// add phi21 and phi23 successor if they are not marked yet
		Dart d2 = phi2(darts[i]);
		Dart d21 = phi1(d2); // turn in volume
		Dart d23 = phi3(d2); // change volume
240

untereiner's avatar
untereiner committed
241
		if(!mv.isMarked(d21))
242
		{
untereiner's avatar
untereiner committed
243
244
245
246
247
248
249
			darts.push_back(d21);
			mv.mark(d21);
		}
		if(!mv.isMarked(d23))
		{
			darts.push_back(d23);
			mv.mark(d23);
250
251
		}

untereiner's avatar
untereiner committed
252
		found = f(darts[i]);
253
254
255
256
	}
	return found;
}

257
inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
258
259
260
{
	Dart dNext = d;
	do {
untereiner's avatar
untereiner committed
261
		if (foreach_dart_of_edge2(dNext, f, thread))
262
			return true;
263
264
265
266
267
		dNext = alpha2(dNext);
	} while (dNext != d);
	return false;
}

268
inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread)
269
270
271
272
273
274
275
276
277
278
279
{
	Dart dNext = d ;
	do
	{
		if (f(dNext))
			return true ;
		dNext = phi1(dNext) ;
	} while (dNext != d) ;
	return false ;
}

280
inline bool ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
281
{
untereiner's avatar
untereiner committed
282
	return foreach_dart_of_oriented_face(d, f, thread) || foreach_dart_of_oriented_face(phi3(d), f, thread);
283
284
}

untereiner's avatar
untereiner committed
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
317
318
319
320
321
322
323
324
inline bool ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int thread)
{
	DartMarkerStore mark(*this, thread);	// Lock a marker
	bool found = false;				// Last functor return value

	std::vector<Dart> visitedFaces;	// Faces that are traversed
	visitedFaces.reserve(1024) ;
	visitedFaces.push_back(d);		// Start with the face of d

	// For every face added to the list
	for(unsigned int i = 0; !found && i < visitedFaces.size(); ++i)
	{
		if (!mark.isMarked(visitedFaces[i]))	// Face has not been visited yet
		{
			// Apply functor to the darts of the face
			found = foreach_dart_of_oriented_face(visitedFaces[i], f);

			// If functor returns false then mark visited darts (current face)
			// and add non visited adjacent faces to the list of face
			if (!found)
			{
				Dart e = visitedFaces[i] ;
				do
				{
					mark.mark(e);				// Mark
					Dart adj = phi2(e);			// Get adjacent face
					if (!mark.isMarked(adj))
						visitedFaces.push_back(adj);	// Add it
					e = phi1(e);
				} while(e != visitedFaces[i]);
			}
		}
	}
	return found;
}

inline bool ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{
	return foreach_dart_of_oriented_volume(d, f) ;
}
untereiner's avatar
untereiner committed
325
326

inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
327
{
untereiner's avatar
untereiner committed
328
	DartMarkerStore mark(*this, thread);	// Lock a marker
329
330
	bool found = false;				// Last functor return value

331
	std::vector<Dart> visitedFaces;	// Faces that are traversed
untereiner's avatar
untereiner committed
332
	visitedFaces.reserve(1024) ;
333
334
335
	visitedFaces.push_back(d);		// Start with the face of d

	// For every face added to the list
336
	for(unsigned int i = 0; !found && i < visitedFaces.size(); ++i)
337
	{
untereiner's avatar
untereiner committed
338
		if (!mark.isMarked(visitedFaces[i]))	// Face has not been visited yet
339
340
		{
			// Apply functor to the darts of the face
untereiner's avatar
untereiner committed
341
			found = foreach_dart_of_face(visitedFaces[i], f);
342
343
344
345
346

			// If functor returns false then mark visited darts (current face)
			// and add non visited adjacent faces to the list of face
			if (!found)
			{
untereiner's avatar
untereiner committed
347
				Dart e = visitedFaces[i] ;
348
349
				do
				{
untereiner's avatar
untereiner committed
350
351
352
					mark.mark(e);				// Mark
					Dart adj = phi2(e);			// Get adjacent face
					if (!mark.isMarked(adj))
353
						visitedFaces.push_back(adj);	// Add it
untereiner's avatar
untereiner committed
354
355
					e = phi1(e);
				} while(e != visitedFaces[i]);
356
357
358
359
360
			}
		}
	}
	return found;

untereiner's avatar
untereiner committed
361

untereiner's avatar
untereiner committed
362
363
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
//	//return foreach_dart_of_oriented_volume(d, f) ;
//	DartMarkerStore mv(*this,thread);	// Lock a marker
//	bool found = false;					// Last functor return value
//
//	std::vector<Dart> darts;	// Darts that are traversed
//	darts.reserve(1024);
//	darts.push_back(d);			// Start with the dart d
//	mv.mark(d);
//
//	for(unsigned int i = 0; !found && i < darts.size(); ++i)
//	{
//		// add all successors if they are not marked yet
//		Dart d2 = phi1(darts[i]); // turn in face
//		Dart d3 = phi2(darts[i]); // change face
//		Dart d4 = phi3(darts[i]); // change volume
//
//		if (!mv.isMarked(d2))
//		{
//			darts.push_back(d2);
//			mv.mark(d2);
//		}
//		if (!mv.isMarked(d3))
//		{
//			darts.push_back(d2);
//			mv.mark(d2);
//		}
//		if (!mv.isMarked(d4))
//		{
//			darts.push_back(d4);
//			mv.mark(d4);
//		}
//
//		found = f(darts[i]);
//	}
//	return found;
397
398
}

untereiner's avatar
untereiner committed
399

untereiner's avatar
untereiner committed
400
401
402
403
404
405
406
407
408
409
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex2(Dart d, FunctorType& f, unsigned int thread)
{
	Dart dNext = d;
	do
	{
		if (f(dNext))
			return true;
		dNext = phi2(phi_1(dNext));
 	} while (dNext != d);
 	return false;
410
411
}

untereiner's avatar
untereiner committed
412
413
414
415
416
417
418
419
420
421
422
inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge2(Dart d, FunctorType& f, unsigned int thread)
{
	if (f(d))
		return true;
	return f(phi2(d));
}

inline bool ImplicitHierarchicalMap3::foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread)
{
	return foreach_dart_of_oriented_face(d,f,thread);
}
untereiner's avatar
untereiner committed
423

424
425
426
427
/***************************************************
 *              LEVELS MANAGEMENT                  *
 ***************************************************/

untereiner's avatar
untereiner committed
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
inline void ImplicitHierarchicalMap3::incCurrentLevel()
{
	if(m_curLevel < m_maxLevel)
		++m_curLevel ;
	else
		CGoGNout << "incCurrentLevel : already at maximum resolution level" << CGoGNendl ;
}

inline void ImplicitHierarchicalMap3::decCurrentLevel()
{
	if(m_curLevel > 0)
		--m_curLevel ;
	else
		CGoGNout << "decCurrentLevel : already at minimum resolution level" << CGoGNendl ;
}



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
inline unsigned int ImplicitHierarchicalMap3::getCurrentLevel()
{
	return m_curLevel ;
}

inline void ImplicitHierarchicalMap3::setCurrentLevel(unsigned int l)
{
	assert(l >= 0 || !"Trying to set current level to a negative value") ;
	m_curLevel = l ;
}

inline unsigned int ImplicitHierarchicalMap3::getMaxLevel()
{
	return m_maxLevel ;
}

inline unsigned int ImplicitHierarchicalMap3::getDartLevel(Dart d)
{
	return m_dartLevel[d] ;
}

inline void ImplicitHierarchicalMap3::setDartLevel(Dart d, unsigned int l)
{
	m_dartLevel[d] = l ;
}

/***************************************************
 *             EDGE ID MANAGEMENT                  *
 ***************************************************/

inline unsigned int ImplicitHierarchicalMap3::getNewEdgeId()
{
	return m_edgeIdCount++ ;
}


inline unsigned int ImplicitHierarchicalMap3::getEdgeId(Dart d)
{
	return m_edgeId[d] ;
}

inline void ImplicitHierarchicalMap3::setEdgeId(Dart d, unsigned int i, unsigned int orbit)
{
489
	if(orbit == EDGE)
490
491
492
493
494
495
496
497
498
499
500
	{
		Dart e = d;

		do
		{
			m_edgeId[e] = i;
			m_edgeId[Map3::phi2(e)] = i;

			e = Map3::alpha2(e);
		} while(e != d);
	}
501
	else if(orbit == DART)
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
	{
		m_edgeId[d] = i;
	}
}

/***************************************************
 *             FACE ID MANAGEMENT                  *
 ***************************************************/

inline unsigned int ImplicitHierarchicalMap3::getNewFaceId()
{
	return m_faceIdCount++;
}

inline unsigned int ImplicitHierarchicalMap3::getFaceId(Dart d)
{
	return m_faceId[d] ;
}

521
inline void ImplicitHierarchicalMap3::setFaceId(unsigned int orbit, Dart d)
522
523
{
	//Mise a jour de l'id de face pour les brins autour d'une arete
524
	if(orbit == EDGE)
525
526
527
528
529
	{
		Dart e = d;

		do
		{
530
			m_faceId[Map3::phi1(e)] = m_faceId[e];
531
532
533
534
535

			e = Map3::alpha2(e);
		}while(e != d);

	}
536
537
538
539
540
}

inline void ImplicitHierarchicalMap3::setFaceId(Dart d, unsigned int i, unsigned int orbit)
{

541
	//Mise a jour de l'id de face pour les brins autour de la face
542
	if(orbit == FACE)
543
544
545
546
547
548
549
550
551
552
553
554
555
556
	{
		Dart e = d;

		do
		{
			m_faceId[e] = i;

			Dart e3 = Map3::phi3(e);
			if(e3 != e)
				m_faceId[e3] = i;

			e = Map3::phi1(e);
		} while(e != d);
	}
557
	else if(orbit == DART)
558
559
	{
		m_faceId[d] = i;
560
561
562

		if(Map3::phi3(d) != d)
			m_faceId[Map3::phi3(d)] = i;
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
	}
}

/***************************************************
 *               CELLS INFORMATION                 *
 ***************************************************/

//TODO
inline unsigned int ImplicitHierarchicalMap3::vertexInsertionLevel(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
	return m_dartLevel[d] ;
}

inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

	// the level of an edge is the maximum of the
	// insertion levels of its darts

	unsigned int r = 0;

	Dart e = d;
	do
	{
		unsigned int ld = m_dartLevel[e] ;
		unsigned int ldd = m_dartLevel[phi2(e)] ;
		unsigned int temp = ld < ldd ? ldd : ld;

		r =  r < temp ? temp : r ;

		e = alpha2(e);
	} while(e != d);

	return r;
}

601

602
603
604
605
/***************************************************
 *               ATTRIBUTE HANDLER                 *
 ***************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
606
607
template <typename T, unsigned int ORBIT>
T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
608
609
610
611
612
613
614
{
	ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
	assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
	assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;

	unsigned int orbit = this->getOrbit() ;
	unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
615
	unsigned int index = m->getEmbedding<ORBIT>(d) ;
616
617
618

	if(index == EMBNULL)
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
619
		index = m->embedNewCell<ORBIT>(d) ;
620
621
622
		m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
623
	AttributeContainer& cont = m->getAttributeContainer<ORBIT>() ;
624
625
626
627
628
629
630
	unsigned int step = 0 ;
	while(step < nbSteps)
	{
		step++ ;
		unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ;
		if (nextIdx == EMBNULL)
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
631
632
			nextIdx = m->newCell<ORBIT>() ;
			m->copyCell<ORBIT>(nextIdx, index) ;
633
634
635
636
637
638
639
640
641
			m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ;
			m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ;
			cont.refLine(index) ;
		}
		index = nextIdx ;
	}
	return this->m_attrib->operator[](index);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
642
643
template <typename T, unsigned int ORBIT>
const T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d) const
644
645
646
647
648
649
650
{
	ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
	assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
	assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;

	unsigned int orbit = this->getOrbit() ;
	unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
651
	unsigned int index = m->getEmbedding<ORBIT>(d) ;
652
653
654
655
656
657
658
659
660
661
662

	unsigned int step = 0 ;
	while(step < nbSteps)
	{
		step++ ;
		unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
		if(next != EMBNULL) index = next ;
		else break ;
	}
	return this->m_attrib->operator[](index);
}
663
664
665
666
667
668

} //namespace IHM

} //namespace Algo

} //namespace CGoGN