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

namespace CGoGN
{

namespace Algo
{

31
32
33
namespace Volume
{

untereiner's avatar
untereiner committed
34
namespace IHM
35
36
{

37
/***************************************************
38
 *  	   ATTRIBUTES MANAGEMENT    	           	 *
39
40
 ***************************************************/

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

Pierre Kraemer's avatar
Pierre Kraemer committed
48
	AttributeHandler<T, ORBIT, EMap3_IMPL> h = Map3::addAttribute<T, ORBIT>(nameAttr) ;
49
50
51

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

Pierre Kraemer's avatar
Pierre Kraemer committed
59
	return AttributeHandler_IHM<T, ORBIT>(this, h.getDataVector()) ;
60
61
}

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

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

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


81
/***************************************************
untereiner's avatar
untereiner committed
82
 *     		 	    MAP TRAVERSAL         		   *
83
84
85
86
87
88
89
90
91
92
93
 ***************************************************/

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

Sylvain Thery's avatar
Sylvain Thery committed
94
inline Dart ImplicitHierarchicalMap3::phi1(Dart d) const
95
96
97
98
99
100
{
	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
101

102
103
	do
	{
untereiner's avatar
untereiner committed
104

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

113
114
115
116
117
118
		}
	} while(!finished) ;

	return it ;
}

Sylvain Thery's avatar
Sylvain Thery committed
119
inline Dart ImplicitHierarchicalMap3::phi_1(Dart d) const
120
121
122
123
124
125
126
127
128
129
130
131
132
{
	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) ;
133
			while(m_edgeId[it] != edgeId)
untereiner's avatar
untereiner committed
134
				it = Map3::phi_1(phi2bis(it));
135
136
137
138
139
140
		}
	} while(!finished) ;

	return it ;
}

Sylvain Thery's avatar
Sylvain Thery committed
141
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d) const
142
143
144
145
146
{
	unsigned int faceId = m_faceId[d];
	Dart it = d;

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

148
	/* du cote des volumes non subdivise (subdiv adapt) */
149
150
151
152
	if(m_faceId[it] == faceId)
		return it;
	else
	{
untereiner's avatar
untereiner committed
153
154
		do
		{
155
			it = Map3::phi2(Map3::phi3(it));
untereiner's avatar
untereiner committed
156
157
		}
		while(m_faceId[it] != faceId);
158
159
160
161
162

		return it;
	}
}

Sylvain Thery's avatar
Sylvain Thery committed
163
inline Dart ImplicitHierarchicalMap3::phi2(Dart d) const
164
165
166
167
168
169
{
	assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;

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

Sylvain Thery's avatar
Sylvain Thery committed
170
inline Dart ImplicitHierarchicalMap3::phi3(Dart d) const
171
172
173
174
175
176
177
178
179
{
	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)));
}

Sylvain Thery's avatar
Sylvain Thery committed
180
inline Dart ImplicitHierarchicalMap3::alpha0(Dart d) const
181
182
183
184
{
	return phi3(d) ;
}

Sylvain Thery's avatar
Sylvain Thery committed
185
inline Dart ImplicitHierarchicalMap3::alpha1(Dart d) const
186
{
187
	//assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
188

189
	return phi3(phi_1(d)) ;
190
191
}

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

196
	return phi3(phi2(d));
197
198
}

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

203
	return phi2(phi3(d));
204
205
}

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

214
inline Dart ImplicitHierarchicalMap3::end() const
215
216
217
218
{
	return Map3::end() ;
}

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

227
inline void ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, std::function<void (Dart)> f, unsigned int thread) const
228
{
Pierre Kraemer's avatar
Pierre Kraemer committed
229
	DartMarkerStore<Map3> mv(*this, thread);	// Lock a marker
230

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

236
	for(unsigned int i = 0; i < darts.size(); ++i)
237
	{
untereiner's avatar
untereiner committed
238
239
240
241
		// 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
242

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

254
		f(darts[i]);
255
256
257
	}
}

258
inline void ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, std::function<void (Dart)> f, unsigned int thread) const
259
260
261
{
	Dart dNext = d;
	do {
262
		foreach_dart_of_edge2(dNext, f, thread);
263
264
265
266
		dNext = alpha2(dNext);
	} while (dNext != d);
}

267
inline void ImplicitHierarchicalMap3::foreach_dart_of_oriented_face(Dart d, std::function<void (Dart)> f, unsigned int /*thread*/) const
268
269
270
271
{
	Dart dNext = d ;
	do
	{
272
		f(dNext);
273
274
275
276
		dNext = phi1(dNext) ;
	} while (dNext != d) ;
}

277
inline void ImplicitHierarchicalMap3::foreach_dart_of_face(Dart d, std::function<void (Dart)> f, unsigned int thread) const
278
{
279
280
	foreach_dart_of_oriented_face(d, f, thread);
	foreach_dart_of_oriented_face(phi3(d), f, thread);
281
282
}

283
inline void ImplicitHierarchicalMap3::foreach_dart_of_oriented_volume(Dart d, std::function<void (Dart)> f, unsigned int thread) const
untereiner's avatar
untereiner committed
284
{
Pierre Kraemer's avatar
Pierre Kraemer committed
285
	DartMarkerStore<Map3> mark(*this, thread);	// Lock a marker
untereiner's avatar
untereiner committed
286
287
288
289
290
291

	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
292
	for(unsigned int i = 0; i < visitedFaces.size(); ++i)
untereiner's avatar
untereiner committed
293
294
295
296
	{
		if (!mark.isMarked(visitedFaces[i]))	// Face has not been visited yet
		{
			// Apply functor to the darts of the face
297
			foreach_dart_of_oriented_face(visitedFaces[i], f);
untereiner's avatar
untereiner committed
298

299
			// mark visited darts (current face)
untereiner's avatar
untereiner committed
300
			// and add non visited adjacent faces to the list of face
301
302
			Dart e = visitedFaces[i] ;
			do
untereiner's avatar
untereiner committed
303
			{
304
305
306
307
308
309
				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]);
untereiner's avatar
untereiner committed
310
311
312
313
		}
	}
}

314
inline void ImplicitHierarchicalMap3::foreach_dart_of_volume(Dart d, std::function<void (Dart)> f, unsigned int thread) const
untereiner's avatar
untereiner committed
315
{
316
	foreach_dart_of_oriented_volume(d, f, thread) ;
untereiner's avatar
untereiner committed
317
}
untereiner's avatar
untereiner committed
318

319
inline void ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, std::function<void (Dart)> f, unsigned int thread) const
320
{
Pierre Kraemer's avatar
Pierre Kraemer committed
321
	DartMarkerStore<Map3> mark(*this, thread);	// Lock a marker
322

323
	std::vector<Dart> visitedFaces;	// Faces that are traversed
untereiner's avatar
untereiner committed
324
	visitedFaces.reserve(1024) ;
325
326
327
	visitedFaces.push_back(d);		// Start with the face of d

	// For every face added to the list
328
	for(unsigned int i = 0; i < visitedFaces.size(); ++i)
329
	{
untereiner's avatar
untereiner committed
330
		if (!mark.isMarked(visitedFaces[i]))	// Face has not been visited yet
331
332
		{
			// Apply functor to the darts of the face
333
			foreach_dart_of_face(visitedFaces[i], f);
334

335
			// mark visited darts (current face)
336
			// and add non visited adjacent faces to the list of face
337
338
			Dart e = visitedFaces[i] ;
			do
339
			{
340
341
342
343
344
345
				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]);
346
347
348
		}
	}

349
//	// foreach_dart_of_oriented_volume(d, f) ;
untereiner's avatar
untereiner committed
350
351
352
353
354
355
356
//	DartMarkerStore mv(*this,thread);	// Lock a marker
//
//	std::vector<Dart> darts;	// Darts that are traversed
//	darts.reserve(1024);
//	darts.push_back(d);			// Start with the dart d
//	mv.mark(d);
//
357
//	for(unsigned int i = 0; i < darts.size(); ++i)
untereiner's avatar
untereiner committed
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
//	{
//		// 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);
//		}
//
380
//		f(darts[i]);
untereiner's avatar
untereiner committed
381
//	}
382
383
}

384
inline void ImplicitHierarchicalMap3::foreach_dart_of_vertex2(Dart d, std::function<void (Dart)> f, unsigned int /*thread*/) const
untereiner's avatar
untereiner committed
385
386
387
388
{
	Dart dNext = d;
	do
	{
389
		f(dNext);
untereiner's avatar
untereiner committed
390
		dNext = phi2(phi_1(dNext));
391
	} while (dNext != d);
392
393
}

394
inline void ImplicitHierarchicalMap3::foreach_dart_of_edge2(Dart d, std::function<void (Dart)> f, unsigned int /*thread*/) const
untereiner's avatar
untereiner committed
395
{
396
397
	f(d);
	f(phi2(d));
untereiner's avatar
untereiner committed
398
399
}

400
inline void ImplicitHierarchicalMap3::foreach_dart_of_face2(Dart d, std::function<void (Dart)> f, unsigned int thread) const
untereiner's avatar
untereiner committed
401
{
402
	foreach_dart_of_oriented_face(d, f, thread);
untereiner's avatar
untereiner committed
403
}
untereiner's avatar
untereiner committed
404

405
406
407
408
/***************************************************
 *              LEVELS MANAGEMENT                  *
 ***************************************************/

untereiner's avatar
untereiner committed
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
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 ;
}



Sylvain Thery's avatar
Sylvain Thery committed
427
inline unsigned int ImplicitHierarchicalMap3::getCurrentLevel() const
428
429
430
431
432
433
434
435
436
{
	return m_curLevel ;
}

inline void ImplicitHierarchicalMap3::setCurrentLevel(unsigned int l)
{
	m_curLevel = l ;
}

Sylvain Thery's avatar
Sylvain Thery committed
437
inline unsigned int ImplicitHierarchicalMap3::getMaxLevel() const
438
439
440
441
{
	return m_maxLevel ;
}

Sylvain Thery's avatar
Sylvain Thery committed
442
inline unsigned int ImplicitHierarchicalMap3::getDartLevel(Dart d) const
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
{
	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)
{
469
	if(orbit == EDGE)
470
471
472
473
474
475
476
477
478
479
480
	{
		Dart e = d;

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

			e = Map3::alpha2(e);
		} while(e != d);
	}
481
	else if(orbit == DART)
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
	{
		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] ;
}

501
inline void ImplicitHierarchicalMap3::setFaceId(unsigned int orbit, Dart d)
502
503
{
	//Mise a jour de l'id de face pour les brins autour d'une arete
504
	if(orbit == EDGE)
505
506
507
508
509
	{
		Dart e = d;

		do
		{
510
			m_faceId[Map3::phi1(e)] = m_faceId[e];
511
512
513
514
515

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

	}
516
517
518
519
520
}

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

521
	//Mise a jour de l'id de face pour les brins autour de la face
522
	if(orbit == FACE)
523
524
525
526
527
528
529
530
531
532
533
534
535
536
	{
		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);
	}
537
	else if(orbit == DART)
538
539
	{
		m_faceId[d] = i;
540
541
542

		if(Map3::phi3(d) != d)
			m_faceId[Map3::phi3(d)] = i;
543
544
545
546
547
548
549
550
	}
}

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

//TODO
Sylvain Thery's avatar
Sylvain Thery committed
551
inline unsigned int ImplicitHierarchicalMap3::vertexInsertionLevel(Dart d) const
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
{
	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;
}

581
template <unsigned int ORBIT>
Sylvain Thery's avatar
Sylvain Thery committed
582
inline unsigned int ImplicitHierarchicalMap3::getEmbedding(Dart d) const
583
{
584
585
    unsigned int nbSteps = m_curLevel - vertexInsertionLevel(d);
    unsigned int index = EmbeddedMap3::getEmbedding<ORBIT>(d);
586

587
588
589
590
591
592
593
594
595
    unsigned int step = 0;
    while(step < nbSteps)
    {
        step++;
        unsigned int next = m_nextLevelCell[ORBIT]->operator[](index);
        //index = next;
        if(next != EMBNULL) index = next;
        else break;
    }
596

597
    return index;
598
599
}

600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
inline bool ImplicitHierarchicalMap3::isWellEmbedded()
{
	//std::cout << "yeahhh ? " << std::endl;
	TraversorV<ImplicitHierarchicalMap3> tv(*this);

	for(Dart dv = tv.begin() ; dv != tv.end() ; dv = tv.next())
	{
		unsigned int curem = this->getEmbedding<VERTEX>(dv);
		//std::cout << "current emb = " << curem << std::endl;

		unsigned int count = 0;
		TraversorDartsOfOrbit<ImplicitHierarchicalMap3, VERTEX> to(*this, dv);
		for(Dart dit = to.begin() ; dit != to.end() ; dit = to.next())
		{
			//std::cout << getDartLevel(dit) << std::endl;

			if(curem != this->getEmbedding<VERTEX>(dit))
			{
				std::cout << "erreur dart #" << dit;
				std::cout << " / curem = " << curem;
				std::cout << " / em = " << this->getEmbedding<VERTEX>(dit);
				std::cout << std::endl;
			}

			std::cout << EmbeddedMap3::getEmbedding<VERTEX>(dit) << "(" << this->getEmbedding<VERTEX>(dit) << ")" << " / ";
			++count;
		}
		std::cout << " / vertex degree = " << count << std::endl;

	}

	return true;
}

634

635
636
637
638
639
640
641
642
643
644










645
646
647
//void ImplicitHierarchicalMap3::analysis()
//{
//    assert(getCurrentLevel() > 0 || !"analysis : called on level 0") ;
648

649
//   decCurrentLevel() ;
650

651
652
653
//    for(unsigned int i = 0; i < analysisFilters.size(); ++i)
//        (*analysisFilters[i])() ;
//}
654

655
656
657
//void ImplicitHierarchicalMap3::synthesis()
//{
//    assert(getCurrentLevel() < getMaxLevel() || !"synthesis : called on max level") ;
658

659
660
//    for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
//        (*synthesisFilters[i])() ;
661

662
663
//    incCurrentLevel() ;
//}
664

665
666
667
668
/***************************************************
 *               ATTRIBUTE HANDLER                 *
 ***************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
669
670
template <typename T, unsigned int ORBIT>
T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
671
672
673
674
675
{
	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") ;

676
//	std::cout << std::endl << "vertexInsertionLevel[" << d <<"] = " << m->vertexInsertionLevel(d) << "\t";
677

678
	unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
679
680
681
682
683
684
	unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;

//	std::cout << " m->vertexInsertionLevel(d) = " <<  m->vertexInsertionLevel(d) << std::endl;
//	std::cout << "m_curLevel = " << m->m_curLevel << std::endl;
//	std::cout << " nbSteps = " <<  nbSteps << std::endl;
//	std::cout << "index EmbMap3 = " << index << std::endl;
685
686
687

	if(index == EMBNULL)
	{
688
		index = m->setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
689
		m->m_nextLevelCell[ORBIT]->operator[](index) = EMBNULL ;
690
691
	}

Pierre Kraemer's avatar
Pierre Kraemer committed
692
	AttributeContainer& cont = m->getAttributeContainer<ORBIT>() ;
693
694
695
696
	unsigned int step = 0 ;
	while(step < nbSteps)
	{
		step++ ;
697
		unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
698
699
		if (nextIdx == EMBNULL)
		{
Pierre Kraemer's avatar
Pierre Kraemer committed
700
701
			nextIdx = m->newCell<ORBIT>() ;
			m->copyCell<ORBIT>(nextIdx, index) ;
702
703
			m->m_nextLevelCell[ORBIT]->operator[](index) = nextIdx ;
			m->m_nextLevelCell[ORBIT]->operator[](nextIdx) = EMBNULL ;
704
705
706
707
			cont.refLine(index) ;
		}
		index = nextIdx ;
	}
708

709
//	std::cout << "emb = " << index << std::endl;
710
711
712
713
714

//	std::cout << "index IHM = " << index << std::endl;
//	if(index != EMBNULL)
//		std::cout << " emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;

715
716
717
	return this->m_attrib->operator[](index);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
718
719
template <typename T, unsigned int ORBIT>
const T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d) const
720
721
722
723
724
725
{
	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 nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
726
727
    //unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
    unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
728
729
730
731
732

//	std::cout << "(const) m->vertexInsertionLevel(d) = " <<  m->vertexInsertionLevel(d) << std::endl;
//	std::cout << "(const) m_curLevel = " << m->m_curLevel << std::endl;
//	std::cout << "(const) nbSteps = " <<  nbSteps << std::endl;
//	std::cout << "(const) index EmbMap3 = " << index << std::endl;
733
734
735
736
737

	unsigned int step = 0 ;
	while(step < nbSteps)
	{
		step++ ;
738
739
		unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
		if(nextIdx != EMBNULL) index = nextIdx ;
740
741
		else break ;
	}
742
743
744
745

//	if(index != EMBNULL)
//		std::cout << "(const) emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;

746
747
	return this->m_attrib->operator[](index);
}
748

749

750
} //namespace IHM
751
} // Volume
752
753
} //namespace Algo
} //namespace CGoGN