env_map.h 13.4 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

35
//#define EXPORTING3
pitiot's avatar
pitiot committed
36
#define TWO_AND_HALF_DIM
37
38
39
40
41
42
43
44

#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
45
46
class EnvMap
{
47
48
public:
	PFP::MAP map ;
49

50
51
52
53
54
55
56
57
58
59
60
61
	/* 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 ;

David Cazier's avatar
David Cazier committed
62
	EnvMap() ;
63
	void init(unsigned int config, REAL width, REAL height, REAL minSize, REAL maxSize) ;
64

65
66
67
	void initGL();
	void draw();

68
	void scale(float val);
pitiot's avatar
up    
pitiot committed
69
	bool is_insideConvexCell2D(VEC3 p, Dart d);
pitiot's avatar
up    
pitiot committed
70
	bool isInsideFace3D(VEC3 p, Dart d);
David Cazier's avatar
David Cazier committed
71
	void markPedWay() ;
Thomas's avatar
Thomas committed
72

David Cazier's avatar
David Cazier committed
73
	unsigned int mapMemoryCost() ;
Thomas's avatar
Thomas committed
74

Pierre Kraemer's avatar
Pierre Kraemer committed
75
#ifndef SPATIAL_HASHING
76
	Dart getBelongingCell(const VEC3& pos) ;
77
	Dart getBelongingCellOnSurface(const VEC3& pos) ;
Thomas's avatar
Thomas committed
78

79
80
	void subdivideAllToMaxLevel() ;
	void subdivideToProperLevel() ;
Thomas's avatar
Thomas committed
81

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

84
	void registerObstaclesInFaces() ;
pitiot's avatar
maj    
pitiot committed
85
	void registerWallInFaces();
86
	void addNeighborObstacles(PFP::OBSTACLES& obst, Dart d, bool edgeNeighbor) ;
87

88
	void setAgentNeighborsAndObstacles(Agent* agent) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
89

90
91
92
93
94
95
	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
96

Thomas Jund's avatar
Thomas Jund committed
97
	Dart popAndPushObstacleInCells(Obstacle* o, int n);
98
99
100
101
102
	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);

103
	void popObstacleInCells(Obstacle* o, Dart d) ;
104
105
	void refine() ;
	void coarse() ;
106
	void updateMap() ;
107

108
	void resetAgentInFace(Agent* agent) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
109
110
#endif

David Cazier's avatar
David Cazier committed
111
112
	PFP::TVEC3 position ;
	PFP::TVEC3 normal ;
Pierre Kraemer's avatar
Pierre Kraemer committed
113

114
115
	Geom::BoundingBox<PFP::VEC3> bb;

David Cazier's avatar
David Cazier committed
116
117
118
	PFP::MAP mapScenary ;
	PFP::TVEC3 positionScenary ;
	PFP::TVEC3 normalScenary ;
pitiot's avatar
maj    
pitiot committed
119
120
121
122
123
	CellMarker<EDGE> obstacleMarkS ;
	CellMarker<FACE> buildingMarkS ;
	CellMarker<EDGE> obstacleMark ;
	CellMarker<FACE> buildingMark ;
	CellMarker<FACE> pedWayMark ;
124
//	CellMarkerMemo<FACE> memo_mark;
pitiot's avatar
maj    
pitiot committed
125
	// ajout moving obst
126
127
	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
128
129
	void pushObstNeighborInCells(Obstacle* o, Dart d);
	void popObstNeighborInCells(Obstacle* o, Dart d);
130
	void find_next(Obstacle* o,Dart * d, CellMarkerMemo<FACE>& cms);
pitiot's avatar
maj    
pitiot committed
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#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

158

David Cazier's avatar
David Cazier committed
159
	std::vector<Dart> newBuildings ;
160

Pierre Kraemer's avatar
Pierre Kraemer committed
161
#ifndef SPATIAL_HASHING
pitiot's avatar
maj    
pitiot committed
162
163
164
165
166
	FaceAttribute<PFP::BOOLATTRIB> subdivisableFace ;

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

David Cazier's avatar
David Cazier committed
169
	PFP::TAB_OBSTACLEVECT obstvect ;
Pierre Kraemer's avatar
Pierre Kraemer committed
170
171


Pierre Kraemer's avatar
Pierre Kraemer committed
172
#ifndef SPATIAL_HASHING
173
	static const unsigned int nbAgentsToSubdivide = 5 ;
Jund Thomas's avatar
Jund Thomas committed
174
	static const unsigned int nbAgentsToSimplify = 4 ;
David Cazier's avatar
David Cazier committed
175

pitiot's avatar
maj    
pitiot committed
176
177
	CellMarker<FACE> refineMark ;
	CellMarker<FACE> coarsenMark ;
178
179
	std::vector<Dart> refineCandidate ;
	std::vector<Dart> coarsenCandidate ;
Pierre Kraemer's avatar
Pierre Kraemer committed
180

181
	void clearUpdateCandidates() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
182
183
184
#endif

#ifdef SPATIAL_HASHING
David Cazier's avatar
David Cazier committed
185
186
187
188
189
190
191
192
193
	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
194

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

pitiot's avatar
maj    
pitiot committed
197
	Geom::Vec2ui obstaclePositionCell(VEC3 pos)
Pierre Kraemer's avatar
Pierre Kraemer committed
198
	{
David Cazier's avatar
David Cazier committed
199
200
		VEC3 relativePos = pos - geometry.min() ;
		relativePos /= obstacleDistance ;
201
		return Geom::Vec2ui(relativePos[0], relativePos[1]) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
202
203
	}

pitiot's avatar
maj    
pitiot committed
204
205
206
207
208
	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
209
	const std::vector<Agent*>& getNeighborAgents(Agent* a) ;
pitiot's avatar
maj    
pitiot committed
210
211
212
213
214
215
216

	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
217
	HashTable2D< std::vector<Agent*> > ht_agents ;
David Cazier's avatar
David Cazier committed
218
	HashTable2D< std::vector<Agent*> > ht_neighbor_agents ;
Pierre Kraemer's avatar
Pierre Kraemer committed
219
220
	HashTable2D< std::vector<Obstacle*> > ht_obstacles ;
#endif
221
} ;
Pierre Kraemer's avatar
Pierre Kraemer committed
222

pitiot's avatar
maj    
pitiot committed
223
224
void update_registration(Obstacle * o);
void register_pop(Obstacle* o, int n);
225
void resetPartSubdiv(Obstacle* o);
pitiot's avatar
up    
pitiot committed
226
//void resetObstPartInFace(Obstacle* o, Dart d, unsigned int fLevel);// empeche de viser une dart ayant disparu
227
void resetObstPartInFace(Obstacle* o, Dart d);// empeche de viser une dart ayant disparu
pitiot's avatar
pitiot committed
228
void resetPart(Obstacle * mo, Dart d); // empeche de viser une dart ayant disparu pour les voisins
pitiot's avatar
maj    
pitiot committed
229
230
void displayMO(Obstacle * o);

Pierre Kraemer's avatar
Pierre Kraemer committed
231
/**************************************
David Cazier's avatar
David Cazier committed
232
233
 *           INLINE FUNCTIONS          *
 **************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
234

235
236
237
238
239
240
241
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
242
template <typename T>
pitiot's avatar
maj    
pitiot committed
243
inline bool removeElementFromVector(std::vector<T>& a, T ag)
Pierre Kraemer's avatar
Pierre Kraemer committed
244
{
245
246
	assert(std::find(a.begin(), a.end(), ag) != a.end());

247
	typename std::vector<T>::iterator end = a.template end() ;
David Cazier's avatar
David Cazier committed
248
249
250
251
	for (typename std::vector<T>::iterator it = a.begin(); it != end; ++it)
	{
		if (*it == ag)
		{
252
253
			*it = a.back() ;
			a.pop_back() ;
pitiot's avatar
maj    
pitiot committed
254
			return true ;
Pierre Kraemer's avatar
Pierre Kraemer committed
255
256
		}
	}
pitiot's avatar
maj    
pitiot committed
257
	return false ;
Pierre Kraemer's avatar
Pierre Kraemer committed
258
259
260
}

#ifndef SPATIAL_HASHING
David Cazier's avatar
David Cazier committed
261
262
inline unsigned int EnvMap::totalNeighborSize(Dart d)
{
263
264
265
266
	return agentvect[d].size() + neighborAgentvect[d].size() ;
}

inline void EnvMap::nbAgentsIncrease(Dart d)
Pierre Kraemer's avatar
Pierre Kraemer committed
267
{
268
269
	if (refineMark.isMarked(d)) return ;
	if (totalNeighborSize(d) < nbAgentsToSubdivide) return ;
Pierre Kraemer's avatar
Pierre Kraemer committed
270

271
	std::pair<bool, bool>& sf = subdivisableFace[d] ;
David Cazier's avatar
David Cazier committed
272
273
	if (sf.first == false || (sf.first == true && sf.second))
	{
274
275
276
		refineMark.mark(d) ;
		refineCandidate.push_back(d) ;
	}
Pierre Kraemer's avatar
Pierre Kraemer committed
277
278
}

279
inline void EnvMap::nbAgentsDecrease(Dart d)
Thomas's avatar
Thomas committed
280
{
281
282
	if (coarsenMark.isMarked(d) || refineMark.isMarked(d)) return ;
	if (totalNeighborSize(d) > nbAgentsToSimplify) return ;
Thomas's avatar
Thomas committed
283

284
285
286
	coarsenMark.mark(d) ;
	coarsenCandidate.push_back(map.faceOldestDart(d)) ;
}
Pierre Kraemer's avatar
Pierre Kraemer committed
287
288

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

pitiot's avatar
pitiot committed
294
295
296
297
298
299
300
301
302
//	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
303

304
305
	addElementToVector<Agent*>(agentvect[d],agent);
//	agentvect[d].push_back(agent) ;
306
//	nbAgentsIncrease(d);
David Cazier's avatar
David Cazier committed
307
308

	Dart dd = d ;
David Cazier's avatar
David Cazier committed
309
310
	do
	{
David Cazier's avatar
David Cazier committed
311
		Dart ddd = map.alpha1(map.alpha1(dd)) ;
David Cazier's avatar
David Cazier committed
312
313
		while (ddd != dd)
		{
pitiot's avatar
pitiot committed
314
315
316
			if (!map.isBoundaryMarked2(ddd))
				addElementToVector<Agent*>(neighborAgentvect[ddd],agent);

317
//			neighborAgentvect[ddd].push_back(agent) ;
318
//			nbAgentsIncrease(ddd);
David Cazier's avatar
David Cazier committed
319
			ddd = map.alpha1(ddd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
320
		}
David Cazier's avatar
David Cazier committed
321
322
		dd = map.phi1(dd) ;
	} while (dd != d) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
323
324
}

Thomas's avatar
Thomas committed
325
326
inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
{
David Cazier's avatar
David Cazier committed
327
328
329
	assert(map.getCurrentLevel() == map.getMaxLevel()) ;

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

331
//	nbAgentsDecrease(d) ;
David Cazier's avatar
David Cazier committed
332
333

	Dart dd = d ;
David Cazier's avatar
David Cazier committed
334
335
	do
	{
David Cazier's avatar
David Cazier committed
336
		Dart ddd = map.alpha1(map.alpha1(dd)) ;
David Cazier's avatar
David Cazier committed
337
338
		while (ddd != dd)
		{
pitiot's avatar
pitiot committed
339
340
			if (!map.isBoundaryMarked2(ddd))
				removeElementFromVector<Agent*>(neighborAgentvect[ddd], agent) ;
Thomas Jund's avatar
Thomas Jund committed
341

342
//			nbAgentsDecrease(ddd) ;
David Cazier's avatar
David Cazier committed
343
			ddd = map.alpha1(ddd) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
344
		}
David Cazier's avatar
David Cazier committed
345
346
		dd = map.phi1(dd) ;
	} while (dd != d) ;
pitiot's avatar
pitiot committed
347

pitiot's avatar
pitiot committed
348
349
350
351
352
353
354
355
356
//	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
357
358
}

pitiot's avatar
maj    
pitiot committed
359
360
361

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

362

363
inline void EnvMap::addObstAsNeighbor (Obstacle *  o, const std::vector<Dart>& belonging_cells, std::vector<Dart> *neighbor_cells)
pitiot's avatar
maj    
pitiot committed
364
365
{
	assert(map.getCurrentLevel() == map.getMaxLevel());
366
	assert(!belonging_cells.empty());
pitiot's avatar
maj    
pitiot committed
367
	neighbor_cells->clear();
368
369
	CellMarkerMemo<FACE> memo_mark(map);
	CellMarkerMemo<FACE> OneRingMark(map);
Thomas Jund's avatar
Thomas Jund committed
370

371
372
	for (std::vector<Dart>::const_iterator it =belonging_cells.begin();it<belonging_cells.end();++it)
		memo_mark.mark(*it);
pitiot's avatar
maj    
pitiot committed
373

374
	std::vector<Dart>::const_iterator it=belonging_cells.begin();
pitiot's avatar
maj    
pitiot committed
375
376
377
378
	Dart beg = NIL;
	Dart first =NIL;
	Dart d=NIL;
	Dart dd=NIL;
pitiot's avatar
pitiot committed
379
380
381
382
383
384
385

	/////////////////////////////////////////////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
386
387
388
389
390
391
392
393
	do
	{
		beg = *it;
		first = NIL;
		d=beg;
		do {
			dd=map.alpha1(map.alpha1(d));
			do {
394
				if (!memo_mark.isMarked(dd))
pitiot's avatar
maj    
pitiot committed
395
396
397
398
399
400
401
402
403
404
405
				{
					first = dd;
				}
				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());
406
//	assert(!buildingMark.isMarked(d)) ;
407
408
	assert(first!=NIL) ;
//	CGoGNout<<"first : "<<first<<CGoGNendl;
pitiot's avatar
maj    
pitiot committed
409
410
411
412
413
414
415
416
417
	d=first;
	do
	{
		if (!OneRingMark.isMarked(d))
		{
			OneRingMark.mark(d);
			(*neighbor_cells).push_back(d);
		}

418
		find_next(o,&d, memo_mark);
419
//		CGoGNout<<"d : "<<d<<CGoGNendl;
pitiot's avatar
maj    
pitiot committed
420
421
422
423
424
	}while(!map.sameFace(d,first));
}

// find_next cherche la prochaine case "voisine" d'un obstacle faisant parti d'un movingobstacle (algo de parcours du one-ring )

425
inline void EnvMap::find_next(Obstacle* o,Dart * ddd, CellMarkerMemo<FACE>& cms)
pitiot's avatar
maj    
pitiot committed
426
427
428
429
430
431
432
433
434
435
436
437
438
439
{
	Dart d=*ddd;
	Dart first = NIL;
	Dart dd;
	int rd =0;
	do{
		rd++;
		dd=map.alpha1((d));

		if (!(cms.isMarked(dd)))
		{
			first = dd;
		}

440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

		if(rd>100)
		{
			if (rd>10000)
			{
				displayMO(o);
				CGoGNout <<(first==NIL)<< " infini find next d : "<< d<<"phi 2 markée ? : "<<cms.isMarked(map.phi2(d))<<CGoGNendl;
				CGoGNout<<"cellules markées : "<<CGoGNendl;
				std::vector<Dart> v=cms.get_markedCells();
				for(std::vector<Dart>::iterator it=v.begin();it<v.end();++it)
				{
					CGoGNout<<(*it).index<<CGoGNendl;
				}
				break;
			}
			CGoGNout <<(first==NIL)<< " infini find next d : "<< d<<"phi 2 markée ? : "<<cms.isMarked(map.phi2(d))<<CGoGNendl;
			CGoGNout<<"cellules markées : "<<CGoGNendl;
							std::vector<Dart> v=cms.get_markedCells();
							for(std::vector<Dart>::iterator it=v.begin();it<v.end();++it)
							{
								CGoGNout<<(*it).index<<CGoGNendl;
							}
pitiot's avatar
maj    
pitiot committed
462
		}
463
		d=map.phi_1(d);
pitiot's avatar
maj    
pitiot committed
464
465
466
467
468
469
470
	}while(first==NIL);
	*ddd=first;
}

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

473
	addElementToVector<Obstacle*>(neighborObstvect[d],o);
pitiot's avatar
maj    
pitiot committed
474
475
}

476
477
478
479
//inline void EnvMap::pushObstacleInCell(Obstacle* o, Dart d)
//{
//	assert(map.getCurrentLevel() == map.getMaxLevel()) ;
//	assert(!buildingMark.isMarked(d)) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
480
//
481
482
//	addElementToVector<Obstacle*>(obstvect[d],o);
//}
483

Pierre Kraemer's avatar
Pierre Kraemer committed
484
485
inline void EnvMap::clearUpdateCandidates()
{
David Cazier's avatar
David Cazier committed
486
487
	refineCandidate.clear() ;
	coarsenCandidate.clear() ;
Pierre Kraemer's avatar
Pierre Kraemer committed
488
}
pitiot's avatar
maj    
pitiot committed
489
490
///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
491
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
492
493

#endif