env_map.h 13.7 KB
Newer Older
1
2
#ifndef ENV_MAP_H
#define ENV_MAP_H
Pierre Kraemer's avatar
Pierre Kraemer committed
3
4
5
6
7

#include <iostream>
#include <algorithm>

#include "Topology/generic/parameters.h"
Pierre Kraemer's avatar
update  
Pierre Kraemer committed
8
#include "Topology/map/embeddedMap2.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
9
10
11
12
13
14
15
16
17

#include "Algo/ImplicitHierarchicalMesh/ihm.h"
#include "Algo/ImplicitHierarchicalMesh/subdivision.h"

#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/extrusion.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Geometry/area.h"
Thomas's avatar
Thomas committed
18
#include "Geometry/bounding_box.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
19
20
21
22
23

#include "Container/fakeAttribute.h"

#include "Algo/Parallel/parallel_foreach.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
24
25
#include "spatialHashing.h"

26
using namespace CGoGN ;
Pierre Kraemer's avatar
Pierre Kraemer committed
27

pitiot's avatar
maj  
pitiot committed
28
29
30
class Agent;
class Obstacle;
class MovingObstacle;
pitiot's avatar
merging  
pitiot committed
31
class ArticulatedObstacle;
Pierre Kraemer's avatar
Pierre Kraemer committed
32

David Cazier's avatar
David Cazier committed
33
#include "pfp.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
34

Arash HABIBI's avatar
Arash HABIBI committed
35
// #define EXPORTING3
pitiot's avatar
merging  
pitiot committed
36

pitiot's avatar
pop  
pitiot committed
37
//#define TWO_AND_HALF_DIM
38
39
40
41
42
43
44
45
46
47



#ifdef EXPORTING3
	#include "Utils/Shaders/shaderPhongTexture.h"
	#include "Utils/Shaders/shaderSimpleTexture.h"
	#include "shaderCustomTex.h"
	#include "Algo/Import/importObjTex.h"
#endif

Pierre Kraemer's avatar
Pierre Kraemer committed
48
49
class EnvMap
{
50
51
public:
	PFP::MAP map ;
52

53
54
55
56
57
58
59
60
61
62
63
	/* Geometry of the EnvMap : the bounding box of the scene
	 * The density of cells in the EnvMap is given by two parameters :
	 *  - minCellSize : the size under which no subdivision occurs
	 *  - maxCellSize : the size of the initial cells (before subdivisions occur)
	 *  - obstacleDistance : the minimal goal distance between agents and obstacles
	 * The number of cells in the initial EnvMap is about (width*height)/(size*size)
	 */
	Geom::BoundingBox<VEC3> geometry ;
	REAL maxCellSize ;
	REAL minCellSize ;
	REAL obstacleDistance ;
Arash HABIBI's avatar
Arash HABIBI committed
64

Thomas Jund's avatar
Thomas Jund committed
65
	unsigned int config;
66

David Cazier's avatar
David Cazier committed
67
	EnvMap() ;
68
	void init(unsigned int config, REAL width, REAL height, REAL minSize, REAL maxSize) ;
69

70
71
72
	void initGL();
	void draw();

73
	void scale(float val);
pitiot's avatar
up  
pitiot committed
74
	bool is_insideConvexCell2D(VEC3 p, Dart d);
pitiot's avatar
up  
pitiot committed
75
	bool isInsideFace3D(VEC3 p, Dart d);
David Cazier's avatar
David Cazier committed
76
	void markPedWay() ;
Thomas's avatar
Thomas committed
77

David Cazier's avatar
David Cazier committed
78
	unsigned int mapMemoryCost() ;
Thomas's avatar
Thomas committed
79

Pierre Kraemer's avatar
Pierre Kraemer committed
80
#ifndef SPATIAL_HASHING
81
	Dart getBelongingCell(const VEC3& pos) ;
82
	Dart getBelongingCellOnSurface(const VEC3& pos) ;
Thomas's avatar
Thomas committed
83

84
85
	void subdivideAllToMaxLevel() ;
	void subdivideToProperLevel() ;
Thomas's avatar
Thomas committed
86

87
	void foreach_neighborFace(Dart d, FunctorType& f) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
88

89
	void registerObstaclesInFaces() ;
pitiot's avatar
maj  
pitiot committed
90
	void registerWallInFaces();
91
	void addNeighborObstacles(PFP::OBSTACLES& obst, Dart d, bool edgeNeighbor) ;
92

93
	void setAgentNeighborsAndObstacles(Agent* agent) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
94

95
96
97
98
99
100
	unsigned int totalNeighborSize(Dart d) ;
	void nbAgentsIncrease(Dart d) ;
	void nbAgentsDecrease(Dart d) ;
	void pushAgentInCells(Agent* agent, Dart d) ;
	void popAgentInCells(Agent* agent, Dart d) ;
	void agentChangeFace(Agent* agent, Dart oldFace) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
101

Thomas Jund's avatar
Thomas Jund committed
102
	Dart popAndPushObstacleInCells(Obstacle* o, int n);
103
104
105
106
107
	void pushObstacleInCells(Obstacle * mo);
	void pushObstacleInOneRingCells(Obstacle * o, Dart d, int n);
	void pushObstacleInCells(Obstacle* o, int n, const std::vector<Dart>& memo_cross);
	void popObstacleInCells(Obstacle* o, int n);

108
	void popObstacleInCells(Obstacle* o, Dart d) ;
109
110
	void refine() ;
	void coarse() ;
111
	void updateMap() ;
pitiot's avatar
pitiot committed
112
	int testOrientation(VEC3 p, VEC3 p1, VEC3 p2, Dart d);
113

114
	void resetAgentInFace(Agent* agent) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
115
116
#endif

David Cazier's avatar
David Cazier committed
117
118
	PFP::TVEC3 position ;
	PFP::TVEC3 normal ;
Pierre Kraemer's avatar
Pierre Kraemer committed
119

120
121
	Geom::BoundingBox<PFP::VEC3> bb;

David Cazier's avatar
David Cazier committed
122
123
124
	PFP::MAP mapScenary ;
	PFP::TVEC3 positionScenary ;
	PFP::TVEC3 normalScenary ;
pitiot's avatar
maj  
pitiot committed
125
126
127
128
129
	CellMarker<EDGE> obstacleMarkS ;
	CellMarker<FACE> buildingMarkS ;
	CellMarker<EDGE> obstacleMark ;
	CellMarker<FACE> buildingMark ;
	CellMarker<FACE> pedWayMark ;
130
//	CellMarkerMemo<FACE> memo_mark;
pitiot's avatar
maj  
pitiot committed
131
	// ajout moving obst
132
133
	void addObstAsNeighbor (Obstacle *  o, const std::vector<Dart>& belonging_cells, std::vector<Dart> * nieghbor_cells);
	// void addMovingObstAsNeighbor (MovingObstacle *  mo,std::vector<Dart> belonging_cells, std::vector<Dart> *neighbor_cells);
pitiot's avatar
maj  
pitiot committed
134
135
	void pushObstNeighborInCells(Obstacle* o, Dart d);
	void popObstNeighborInCells(Obstacle* o, Dart d);
136
	void find_next(Obstacle* o,Dart * d, CellMarkerMemo<FACE>& cms);
pitiot's avatar
up  
pitiot committed
137
	bool movingObstacleFree(Dart d);
pitiot's avatar
ok  
pitiot committed
138
	bool movingObstacleNeighborFree(Dart d);
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifdef EXPORTING3
	std::vector<PFP::MAP *> m_map_Export;
	std::vector<Algo::Surface::Import::OBJModel<PFP2> *> m_obj_Export;

	std::vector<Utils::Texture<2,Geom::Vec3uc>*> m_texture_Export;
	std::vector<Utils::VBO*> m_positionVBO_Export;
	std::vector<Utils::VBO*> m_normalVBO_Export;
	std::vector<Utils::VBO*> m_texcoordVBO_Export;
	std::vector<ShaderCustomTex*> m_shaderTex_Export;

	std::vector<unsigned int> m_nbIndice_Export;

//	PFP2::MAP m_map_Export;
//	VertexAttribute<VEC3> position_Export ;
//	VertexAttribute<VEC3> normal_Export ;
//	Algo::Surface::Import::OBJModel<PFP2> * m_obj_Export;
//
//	Utils::Texture<2,Geom::Vec3uc>* m_texture_Export;
//	Utils::VBO* m_positionVBO_Export;
//	Utils::VBO* m_normalVBO_Export;
//	Utils::VBO* m_texcoordVBO_Export;
//	ShaderCustomTex* m_shaderTex_Export;
//
//	unsigned int m_nbIndice_Export;
#endif

165

David Cazier's avatar
David Cazier committed
166
	std::vector<Dart> newBuildings ;
167

Pierre Kraemer's avatar
Pierre Kraemer committed
168
#ifndef SPATIAL_HASHING
pitiot's avatar
maj  
pitiot committed
169
170
171
172
173
	FaceAttribute<PFP::BOOLATTRIB> subdivisableFace ;

	PFP::TAB_AGENTVECT agentvect ;
	PFP::TAB_AGENTVECT neighborAgentvect ;
	PFP::TAB_OBSTACLEVECT neighborObstvect;
Pierre Kraemer's avatar
Pierre Kraemer committed
174
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
175

David Cazier's avatar
David Cazier committed
176
	PFP::TAB_OBSTACLEVECT obstvect ;
Pierre Kraemer's avatar
Pierre Kraemer committed
177
178


Pierre Kraemer's avatar
Pierre Kraemer committed
179
#ifndef SPATIAL_HASHING
180
	static const unsigned int nbAgentsToSubdivide = 5 ;
Jund Thomas's avatar
Jund Thomas committed
181
	static const unsigned int nbAgentsToSimplify = 4 ;
David Cazier's avatar
David Cazier committed
182

pitiot's avatar
maj  
pitiot committed
183
184
	CellMarker<FACE> refineMark ;
	CellMarker<FACE> coarsenMark ;
185
186
	std::vector<Dart> refineCandidate ;
	std::vector<Dart> coarsenCandidate ;
Pierre Kraemer's avatar
Pierre Kraemer committed
187

188
	void clearUpdateCandidates() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
189
190
191
#endif

#ifdef SPATIAL_HASHING
David Cazier's avatar
David Cazier committed
192
193
194
195
196
197
198
199
200
	unsigned int agentGridSize(unsigned int i)
	{
		return geometry.size(i) / minCellSize ;
	}

	unsigned int obstacleGridSize(unsigned int i)
	{
		return geometry.size(i) / obstacleDistance ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
201

pitiot's avatar
maj  
pitiot committed
202
	Geom::Vec2ui agentPositionCell(Agent* a) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
203

pitiot's avatar
maj  
pitiot committed
204
	Geom::Vec2ui obstaclePositionCell(VEC3 pos)
Pierre Kraemer's avatar
Pierre Kraemer committed
205
	{
David Cazier's avatar
David Cazier committed
206
207
		VEC3 relativePos = pos - geometry.min() ;
		relativePos /= obstacleDistance ;
208
		return Geom::Vec2ui(relativePos[0], relativePos[1]) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
209
210
	}

pitiot's avatar
maj  
pitiot committed
211
212
213
214
215
	const std::vector<Agent*>& getNeighbors(Geom::Vec2ui c) {
		assert(ht_agents.hasData(c)) ;
		return ht_agents[c];
	}
	const std::vector<Agent*>& getNeighbors(Agent* a) ;
David Cazier's avatar
David Cazier committed
216
	const std::vector<Agent*>& getNeighborAgents(Agent* a) ;
pitiot's avatar
maj  
pitiot committed
217
218
219
220
221
222
223

	void addAgentInGrid(Agent* a) ;
	void addAgentInGrid(Agent* a, Geom::Vec2ui c) ;

	void removeAgentFromGrid(Agent* a) ;
	void removeAgentFromGrid(Agent* a, Geom::Vec2ui c) ;

Pierre Kraemer's avatar
Pierre Kraemer committed
224
	HashTable2D< std::vector<Agent*> > ht_agents ;
David Cazier's avatar
David Cazier committed
225
	HashTable2D< std::vector<Agent*> > ht_neighbor_agents ;
Pierre Kraemer's avatar
Pierre Kraemer committed
226
227
	HashTable2D< std::vector<Obstacle*> > ht_obstacles ;
#endif
228
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
229

pitiot's avatar
maj  
pitiot committed
230
231
void update_registration(Obstacle * o);
void register_pop(Obstacle* o, int n);
232
void resetPartSubdiv(Obstacle* o);
pitiot's avatar
up  
pitiot committed
233
//void resetObstPartInFace(Obstacle* o, Dart d, unsigned int fLevel);// empeche de viser une dart ayant disparu
234
void resetObstPartInFace(Obstacle* o, Dart d);// empeche de viser une dart ayant disparu
pitiot's avatar
pitiot committed
235
void resetPart(Obstacle * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins
pitiot's avatar
maj  
pitiot committed
236
237
void displayMO(Obstacle * o);

Pierre Kraemer's avatar
Pierre Kraemer committed
238
/**************************************
David Cazier's avatar
David Cazier committed
239
240
 *           INLINE FUNCTIONS          *
 **************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
241

242
243
244
245
246
247
248
template <typename T>
inline void addElementToVector(std::vector<T>& a, T ag)
{
	assert(std::find(a.begin(), a.end(), ag) == a.end());
	a.push_back(ag) ;
}

David Cazier's avatar
David Cazier committed
249
template <typename T>
pitiot's avatar
maj  
pitiot committed
250
inline bool removeElementFromVector(std::vector<T>& a, T ag)
Pierre Kraemer's avatar
Pierre Kraemer committed
251
{
252
253
	assert(std::find(a.begin(), a.end(), ag) != a.end());

254
	typename std::vector<T>::iterator end = a.template end() ;
David Cazier's avatar
David Cazier committed
255
256
257
258
	for (typename std::vector<T>::iterator it = a.begin(); it != end; ++it)
	{
		if (*it == ag)
		{
259
260
			*it = a.back() ;
			a.pop_back() ;
pitiot's avatar
maj  
pitiot committed
261
			return true ;
Pierre Kraemer's avatar
Pierre Kraemer committed
262
263
		}
	}
pitiot's avatar
maj  
pitiot committed
264
	return false ;
Pierre Kraemer's avatar
Pierre Kraemer committed
265
266
267
}

#ifndef SPATIAL_HASHING
David Cazier's avatar
David Cazier committed
268
269
inline unsigned int EnvMap::totalNeighborSize(Dart d)
{
270
271
272
273
	return agentvect[d].size() + neighborAgentvect[d].size() ;
}

inline void EnvMap::nbAgentsIncrease(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
274
{
275
276
	if (refineMark.isMarked(d)) return ;
	if (totalNeighborSize(d) < nbAgentsToSubdivide) return ;
Pierre Kraemer's avatar
Pierre Kraemer committed
277

278
	std::pair<bool, bool>& sf = subdivisableFace[d] ;
David Cazier's avatar
David Cazier committed
279
280
	if (sf.first == false || (sf.first == true && sf.second))
	{
281
282
283
		refineMark.mark(d) ;
		refineCandidate.push_back(d) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
284
285
}

286
inline void EnvMap::nbAgentsDecrease(Dart d)
Thomas's avatar
Thomas committed
287
{
288
289
	if (coarsenMark.isMarked(d) || refineMark.isMarked(d)) return ;
	if (totalNeighborSize(d) > nbAgentsToSimplify) return ;
Thomas's avatar
Thomas committed
290

291
292
293
	coarsenMark.mark(d) ;
	coarsenCandidate.push_back(map.faceOldestDart(d)) ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
294
295

inline void EnvMap::pushAgentInCells(Agent* agent, Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
296
{
David Cazier's avatar
David Cazier committed
297
	assert(map.getCurrentLevel() == map.getMaxLevel()) ;
pitiot's avatar
maj  
pitiot committed
298
//	assert(std::find(agentvect[d].begin(), agentvect[d].end(), agent) == agentvect[d].end());
pitiot's avatar
pitiot committed
299
//	map.check();
David Cazier's avatar
David Cazier committed
300

pitiot's avatar
pitiot committed
301
302
303
304
305
306
307
308
309
//	TraversorF<PFP::MAP> tF(map);
//		for(Dart ddd = tF.begin() ; ddd != tF.end() ; ddd = tF.next())
//		{
//			if(std::find(agentvect[ddd].begin(), agentvect[ddd].end(), agent) != agentvect[ddd].end())
//				std::cout <<agent << "   SO WRONG ADD" <<ddd.index<< std::endl;
//
//			if(std::find(neighborAgentvect[ddd].begin(), neighborAgentvect[ddd].end(), agent) != neighborAgentvect[ddd].end())
//				std::cout <<agent<< "   SO SO WRONG  ADD" <<ddd.index<< std::endl;
//		}
David Cazier's avatar
David Cazier committed
310

311
312
	addElementToVector<Agent*>(agentvect[d],agent);
//	agentvect[d].push_back(agent) ;
313
//	nbAgentsIncrease(d);
David Cazier's avatar
David Cazier committed
314
315

	Dart dd = d ;
David Cazier's avatar
David Cazier committed
316
317
	do
	{
David Cazier's avatar
David Cazier committed
318
		Dart ddd = map.alpha1(map.alpha1(dd)) ;
David Cazier's avatar
David Cazier committed
319
320
		while (ddd != dd)
		{
pitiot's avatar
pitiot committed
321
322
323
			if (!map.isBoundaryMarked2(ddd))
				addElementToVector<Agent*>(neighborAgentvect[ddd],agent);

324
//			neighborAgentvect[ddd].push_back(agent) ;
325
//			nbAgentsIncrease(ddd);
David Cazier's avatar
David Cazier committed
326
			ddd = map.alpha1(ddd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
327
		}
David Cazier's avatar
David Cazier committed
328
329
		dd = map.phi1(dd) ;
	} while (dd != d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
330
331
}

Thomas's avatar
Thomas committed
332
333
inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
{
David Cazier's avatar
David Cazier committed
334
335
336
	assert(map.getCurrentLevel() == map.getMaxLevel()) ;

	removeElementFromVector<Agent*>(agentvect[d], agent) ;
Thomas Jund's avatar
Thomas Jund committed
337

338
//	nbAgentsDecrease(d) ;
David Cazier's avatar
David Cazier committed
339
340

	Dart dd = d ;
David Cazier's avatar
David Cazier committed
341
342
	do
	{
David Cazier's avatar
David Cazier committed
343
		Dart ddd = map.alpha1(map.alpha1(dd)) ;
David Cazier's avatar
David Cazier committed
344
345
		while (ddd != dd)
		{
pitiot's avatar
pitiot committed
346
347
			if (!map.isBoundaryMarked2(ddd))
				removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
Thomas Jund's avatar
Thomas Jund committed
348

349
//			nbAgentsDecrease(ddd) ;
David Cazier's avatar
David Cazier committed
350
			ddd = map.alpha1(ddd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
351
		}
David Cazier's avatar
David Cazier committed
352
353
		dd = map.phi1(dd) ;
	} while (dd != d) ;
pitiot's avatar
pitiot committed
354

pitiot's avatar
pitiot committed
355
356
357
358
359
360
361
362
363
//	TraversorF<PFP::MAP> tF(map);
//		for(Dart ddd = tF.begin() ; ddd != tF.end() ; ddd = tF.next())
//		{
//			if(std::find(agentvect[ddd].begin(), agentvect[ddd].end(), agent) != agentvect[ddd].end())
//				std::cout <<agent << "   SO WRONG" <<ddd.index<< std::endl;
//
//			if(std::find(neighborAgentvect[ddd].begin(), neighborAgentvect[ddd].end(), agent) != neighborAgentvect[ddd].end())
//				std::cout <<agent<< "   SO SO WRONG " <<ddd.index<< std::endl;
//		}
Pierre Kraemer's avatar
Pierre Kraemer committed
364
365
}

pitiot's avatar
maj  
pitiot committed
366
367
368

//ajout moving obst///////////////////////////////////////////////////////////////////////////////////////////////////////

369

370
inline void EnvMap::addObstAsNeighbor (Obstacle *  o, const std::vector<Dart>& belonging_cells, std::vector<Dart> *neighbor_cells)
pitiot's avatar
maj  
pitiot committed
371
372
{
	assert(map.getCurrentLevel() == map.getMaxLevel());
373
	assert(!belonging_cells.empty());
pitiot's avatar
maj  
pitiot committed
374
	neighbor_cells->clear();
pitiot's avatar
pitiot committed
375
376
377
//	CellMarkerMemo<FACE> memo_mark_speed(map);//marqueur additionnel (vitesse)
	CellMarkerMemo<FACE> memo_mark(map); //marqueur des cellules "présentes"
	CellMarkerMemo<FACE> OneRingMark(map); // marquer des cellules voisines
Thomas Jund's avatar
Thomas Jund committed
378

379
	for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
pitiot's avatar
pitiot committed
380
			memo_mark.mark(*it);
pitiot's avatar
pitiot committed
381

pitiot's avatar
pitiot committed
382
383
384
385




pitiot's avatar
maj  
pitiot committed
386

387
	std::vector<Dart>::const_iterator it=belonging_cells.begin();
pitiot's avatar
maj  
pitiot committed
388
389
390
391
	Dart beg = NIL;
	Dart first =NIL;
	Dart d=NIL;
	Dart dd=NIL;
pitiot's avatar
pitiot committed
392

pitiot's avatar
pitiot committed
393

pitiot's avatar
pitiot committed
394
395
396
397
398
399
	/////////////////////////////////////////////boucle pour trouver une face du voisinage de l'obstacle ne contenant pas l'obstacle
//	CGoGNout<<"debut neighbors cellules : ";
//	for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
//		CGoGNout<<(*it).index<<" ; ";
//	CGoGNout<<CGoGNendl;

pitiot's avatar
maj  
pitiot committed
400
401
	do
		{
pitiot's avatar
pitiot committed
402
403
404
405
406
407
408
409
410
411
			beg = *it;
			first = NIL;
			d=beg;
			do {
				dd=map.alpha1(map.alpha1(d));
				do {
					if (!memo_mark.isMarked(dd) && !OneRingMark.isMarked(dd))
					{
						OneRingMark.mark(dd);
						(*neighbor_cells).push_back(dd);
pitiot's avatar
maj  
pitiot committed
412

pitiot's avatar
pitiot committed
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
					}
					dd=map.alpha1(dd);
				}while (dd!=d);

				d=map.phi1(d);

			} while(d!=beg);
			++it;
		}while(it!=belonging_cells.end());



	// save thomas
//	Dart lastCell=NIL;
//		Dart LastDartinLastCell=NIL;
//	while(true)
//	{
//
//		// look a new component of one-ring
//		do
//		{
//			beg = *it;
//			first = NIL;
//			d=beg;
//			do {
//				dd=map.alpha1(map.alpha1(d));
//				do {
//					if (!memo_mark.isMarked(dd) && !OneRingMark.isMarked(dd))
//					{
//						first = dd;
//						lastCell=beg;
//						LastDartinLastCell=d;
//					}
//					dd=map.alpha1(dd);
//				}while (first==NIL && dd!=d);
//
//				d=map.phi1(d);
//
//			} while(first==NIL && d!=beg);
//			++it;
//		}while(first==NIL && it!=belonging_cells.end());
//
//		// here a component found (or not)
//
//
//
//	//	assert(!buildingMark.isMarked(d)) ;
//		assert(first!=NIL) ;
//	//	CGoGNout<<"first : "<<first<<CGoGNendl;
//
//		// register a component
//		if (first !=NIL)
//		{
//			d=first;
//			do
//			{
//				if (!OneRingMark.isMarked(d))				// on tente de marquer la cellule en tant que voisine
//				{
//					OneRingMark.mark(d);
//					(*neighbor_cells).push_back(d);
//				}
//
//				dd=map.alpha1((d));
//				if (!(memo_mark.isMarked(dd)))	// Si la cellule a droite n'est pas marquée comme présente, on la sélectionne
//				{
//					d = dd;
//				}
//				else d=map.phi_1(d);			// sinon on tourne dans la cellule actuelle
//		//		CGoGNout<<"d : "<<d<<CGoGNendl;
//			}while(d!=first); //on s'arrête quand on est revenu a la dart de départ
//
//		}
//		else break;
//	}
pitiot's avatar
maj  
pitiot committed
487
488
489



490

pitiot's avatar
maj  
pitiot committed
491
492
}

pitiot's avatar
pitiot committed
493

pitiot's avatar
maj  
pitiot committed
494
495
496
inline void EnvMap::pushObstNeighborInCells(Obstacle* o, Dart d)
{
	assert(map.getCurrentLevel() == map.getMaxLevel());
pitiot's avatar
merging  
pitiot committed
497
	assert(std::find(neighborObstvect[d].begin(), neighborObstvect[d].end(), o) == neighborObstvect[d].end());
pitiot's avatar
maj  
pitiot committed
498

499
	addElementToVector<Obstacle*>(neighborObstvect[d],o);
pitiot's avatar
maj  
pitiot committed
500
501
}

502
503
504
505
//inline void EnvMap::pushObstacleInCell(Obstacle* o, Dart d)
//{
//	assert(map.getCurrentLevel() == map.getMaxLevel()) ;
//	assert(!buildingMark.isMarked(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
506
//
507
508
//	addElementToVector<Obstacle*>(obstvect[d],o);
//}
509

Pierre Kraemer's avatar
Pierre Kraemer committed
510
511
inline void EnvMap::clearUpdateCandidates()
{
David Cazier's avatar
David Cazier committed
512
513
	refineCandidate.clear() ;
	coarsenCandidate.clear() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
514
}
pitiot's avatar
maj  
pitiot committed
515
516
///addMovingObstAsNeighbor est pour détecter les voisins du movingobstacle global afin de le considerer comme un super agent

Pierre Kraemer's avatar
Pierre Kraemer committed
517
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
518
519

#endif