Commit 9a25743a authored by pitiot's avatar pitiot
Browse files

Version à jour avec moving obstacles

parent 4801340b
......@@ -11,16 +11,16 @@ namespace CityGenerator
{
template <typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark);
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark);
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark);
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark);
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height);
Dart extrudeFaceAndMark(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<FACE>& buildingMark, float height);
#ifndef SPATIAL_HASHING
template <typename PFP>
......@@ -34,33 +34,33 @@ template <typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares);
template <typename PFP>
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize);
void generateMall(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize);
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& position, Dart dLower,Dart dUpper);
void generatePathToUpperStair(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, Dart dLower,Dart dUpper);
/*******************************************************************************/
template <typename PFP>
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float radius, unsigned int nbSquares);
void generatePlanet(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float radius, unsigned int nbSquares);
/*******************************************************************************/
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position);
void simplifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
template <typename PFP>
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area);
bool isAnEar(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart dd, float& area);
template <typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& obstacleMark);
bool canRemoveEdgeConvex(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<EDGE>& obstacleMark);
template <typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark);
void convexifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark);
template <typename PFP>
void installGuardRail(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float height);
void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float height);
}
......
......@@ -10,7 +10,7 @@ namespace CityGenerator
{
template <typename PFP>
bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark)
bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark)
{
Dart dd = d;
do
......@@ -24,7 +24,7 @@ bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildin
}
template <typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark)
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark)
{
Dart dd = d;
do
......@@ -38,7 +38,7 @@ bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker&
}
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark)
Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
{
Algo::Modelisation::Polyhedron<PFP> prim(map, position);
prim.grid_topo(cX, cY);
......@@ -61,7 +61,7 @@ Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, typenam
}
template <typename PFP>
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark)
Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
{
Algo::Modelisation::Polyhedron<PFP> prim(map, position);
prim.grid_topo(cX, cY);
......@@ -159,7 +159,7 @@ Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, ty
}
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height)
Dart extrudeFaceAndMark(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<FACE>& buildingMark, float height)
{
Dart dRoof = Algo::Modelisation::extrudeFace<PFP>(map, position, d, height);
buildingMark.mark(dRoof);
......@@ -177,11 +177,11 @@ template <typename PFP>
bool animateCity(EnvMap* envMap)
{
typename PFP::MAP& map = envMap->map;
typename PFP::TVEC3& position = envMap->position;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
typename PFP::TAB_AGENTVECT& agents = envMap->agentvect;
typename PFP::TAB_AGENTVECT& agentNeighbors = envMap->neighborAgentvect;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
std::vector<Dart>& newBuildings = envMap->newBuildings;
unsigned int state = rand() % 10;
......@@ -258,19 +258,19 @@ bool animateCity(EnvMap* envMap)
#endif
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark)
//Dart generateBuilding(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, float height, unsigned int buildingType, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
//template <typename PFP>
//void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize, unsigned int nbSquares)
//void generateCity(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize, unsigned int nbSquares)
template <typename PFP>
Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildingType)
{
typename PFP::MAP& map = envMap->map;
typename PFP::TVEC3& position = envMap->position;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
// mark the face as obstacle before extrusion
Dart dd = d;
......@@ -386,9 +386,9 @@ template <typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares)
{
typename PFP::MAP& map = envMap->map;
typename PFP::TVEC3& position = envMap->position;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
unsigned int nbBuilding = 1000;
float height = sideSize / 2.0f;
......@@ -410,7 +410,7 @@ void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares)
// int emptySquareY = (nbSquares * sideSize / 2.0f) - (nbEmpty * sideSize) - 10;
// if(! ((p[0] < -emptySquareX && p[1] < -emptySquareY) || (p[0] > emptySquareX && p[1] > emptySquareY)) )
// {
generateBuilding<PFP>(envMap, d, (1+(rand()%3)) * height / 2.0f, rand() % 4); /////////////////commentaire temporaire/////////
generateBuilding<PFP>(envMap, d, (1+(rand()%3)) * height / 2.0f, rand() % 4);
--nbBuilding;
// }
}
......@@ -418,7 +418,7 @@ void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares)
}
template <typename PFP>
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize)
void generateMall(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize)
{
unsigned int side = 5;
std::vector<Algo::Modelisation::Polyhedron<PFP> > floors;
......@@ -432,7 +432,7 @@ void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMark
{
float floorHeight = 100;
typename PFP::VEC3 transl(0,0,floorHeight);
CellMarker m(map, VERTEX) ;
CellMarker<VERTEX> m(map) ;
for(Dart d=map.begin();d!=map.end();map.next(d))
{
......@@ -472,7 +472,7 @@ void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMark
}
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& position, Dart dLower,Dart dUpper)
void generatePathToUpperStair(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, Dart dLower,Dart dUpper)
{
if(dLower!= map.phi2(dLower) || dUpper!=map.phi2(dUpper)) {
std::cout << "generatePathToUpperStair : lower and upper stair darts must be fixpoint in phi2" << std::endl;
......@@ -531,7 +531,7 @@ void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& positi
}
template <typename PFP>
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float radius, unsigned int nbSquares)
void generatePlanet(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float radius, unsigned int nbSquares)
{
Algo::Modelisation::Polyhedron<PFP> prim(map, position);
prim.cylinder_topo(nbSquares, nbSquares, true, true);
......@@ -540,19 +540,19 @@ void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellM
}
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark)
void simplifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
{
typedef typename PFP::VEC3 VEC3;
typedef std::multimap<float, Dart> VEC_D_A;
AutoAttributeHandler<float> tableArea(map, FACE);
AutoAttributeHandler<CGoGN::NoMathIONameAttribute<VEC_D_A::iterator> > tableIt(map, EDGE);
FaceAutoAttribute<float> tableArea(map);
EdgeAutoAttribute<CGoGN::NoMathIONameAttribute<VEC_D_A::iterator> > tableIt(map);
VEC_D_A orderedD;
// compute all heuristic and construct multimap
Algo::Geometry::computeAreaFaces<PFP>(map, position, tableArea);
CellMarker eM(map, EDGE);
CellMarker<EDGE> eM(map);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!eM.isMarked(d) && !obstacleMark.isMarked(d) && !buildingMark.isMarked(d))
......@@ -712,7 +712,7 @@ void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, Ce
}
template <typename PFP>
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area)
bool isAnEar(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart dd, float& area)
{
typedef typename PFP::VEC3 VEC3;
......@@ -746,7 +746,7 @@ bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, flo
}
template <typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& obstacleMark)
bool canRemoveEdgeConvex(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<EDGE>& obstacleMark)
{
typedef typename PFP::VEC3 VEC3;
......@@ -773,12 +773,12 @@ bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position,
}
template <typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark)
void convexifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
{
typedef typename PFP::VEC3 VEC3;
float area;
CellMarker m(map, FACE);
CellMarker<FACE> m(map);
for(Dart d = map.begin();d != map.end(); map.next(d))
{
......@@ -842,10 +842,10 @@ void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, C
}
template <typename PFP>
void installGuardRail(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float height)
void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float height)
{
CellMarker cm(map,EDGE);
CellMarkerNoUnmark railVert(map,EDGE);
CellMarker<EDGE> cm(map);
CellMarkerNoUnmark<EDGE> railVert(map);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!cm.isMarked(d))
......
......@@ -42,9 +42,8 @@ struct PFP: public PFP_STANDARD
typedef NoMathIONameAttribute<AGENTS> AGENTVECT;
typedef NoMathIONameAttribute<OBSTACLES> OBSTACLEVECT;
typedef NoMathIONameAttribute<MOVINGOBSTACLES> MOVINGOBSTACLEVECT;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT> TAB_OBSTACLEVECT;
typedef AttributeHandler<AGENTVECT, FACE> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT, FACE> TAB_OBSTACLEVECT;
typedef NoMathIONameAttribute<std::pair<bool,bool> > BOOLATTRIB;
};
......@@ -92,10 +91,10 @@ public :
//ajout moving obst
void addObstAsNeighbor (Obstacle * o,std::list<Dart> belonging_cells, std::list<Dart> * nieghbor_cells);
void addMovingObstAsNeighbor (MovingObstacle * mo,std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells);
// void addMovingObstAsNeighbor (MovingObstacle * mo,std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells);
void pushObstNeighborInCells(Obstacle* o, Dart d);
void popObstNeighborInCells(Obstacle* o, Dart d);
void find_next(Dart * d);
void find_next(Obstacle* o,Dart * d);
......@@ -107,20 +106,19 @@ public :
PFP::MAP map;
PFP::TVEC3 position;
PFP::TVEC3 normal;
VertexAttribute<VEC3> position;
VertexAttribute<VEC3> normal;
PFP::MAP mapScenary;
PFP::TVEC3 positionScenary;
PFP::TVEC3 normalScenary;
CellMarker obstacleMarkS;
CellMarker buildingMarkS;
VertexAttribute<VEC3> positionScenary;
VertexAttribute<VEC3> normalScenary;
CellMarker<EDGE> obstacleMarkS;
CellMarker<FACE> buildingMarkS;
std::vector<Dart> newBuildings;
#ifndef SPATIAL_HASHING
AttributeHandler<PFP::BOOLATTRIB> subdivisableFace;
AttributeHandler<PFP::BOOLATTRIB, FACE> subdivisableFace;
PFP::TAB_AGENTVECT agentvect;
PFP::TAB_AGENTVECT neighborAgentvect;
......@@ -129,17 +127,18 @@ public :
#endif
CellMarker obstacleMark;
CellMarker buildingMark;
CellMarker pedWayMark;
CellMarker MovingObstMark;
CellMarker OneRingMark;
CellMarker<EDGE> obstacleMark;
CellMarker<FACE> buildingMark;
CellMarker<FACE> pedWayMark;
CellMarker<FACE> MovingObstMark;
CellMarker<FACE> OneRingMark;
#ifndef SPATIAL_HASHING
static const unsigned int nbAgentsToSubdivide = 5;
static const unsigned int nbAgentsToSimplify = 4;
CellMarker refineMark;
CellMarker coarsenMark;
CellMarker<FACE> refineMark;
CellMarker<FACE> coarsenMark;
std::vector<Dart> refineCandidate;
std::vector<Dart> coarsenCandidate;
#endif
......@@ -175,6 +174,7 @@ void register_add(Obstacle* o, int n);
void resetObstInFace(Obstacle* o);
void resetObstPartInFace(Obstacle* o, Dart d);
void resetPart(MovingObstacle * mo, Dart d);
void displayMO(Obstacle * o);
/**************************************
* INLINE FUNCTIONS *
......@@ -238,6 +238,8 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
//ajout moving obst///////////////////////////////////////////////////////////////////////////////////////////////////////
// addobstasneighbor
inline void EnvMap::addObstAsNeighbor (Obstacle * o, std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells)
{
assert(map.getCurrentLevel() == map.getMaxLevel());
......@@ -309,7 +311,8 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, std::list<Dart> belonging_
}
find_next(&d);
find_next(o,&d);
round ++;
// CGoGNout << "Dart suivante : "<< d<< CGoGNendl;
// tour++;
......@@ -335,7 +338,9 @@ inline void EnvMap::addObstAsNeighbor (Obstacle * o, std::list<Dart> belonging_
}
inline void EnvMap::find_next(Dart * ddd)
// find_next cherche la prochaine case "voisine" d'un obstacle faisant parti d'un movingobstacle (algo de parcours du one-ring )
inline void EnvMap::find_next(Obstacle* o,Dart * ddd)
{
Dart d=*ddd;
Dart first = NIL;
......@@ -354,7 +359,8 @@ inline void EnvMap::find_next(Dart * ddd)
d=map.phi_1(d);
if (rd>10000) {
CGoGNout << "infini find next"<<CGoGNendl;
displayMO(o);
CGoGNout <<(first==NIL)<< " infini find next : "<< *ddd<<CGoGNendl;
break;
}
}while(first==NIL);
......@@ -382,25 +388,8 @@ inline void EnvMap::pushObstacleInCells(Obstacle* o, Dart d)
obstvect[d].push_back(o);
// MovingObstMark.mark(d);
// removeElementFromVector<Dart* >(neighborObstvect[d], o);
// OneRingMark.unmark(d);
//
// Dart dd = d;
// do
// {
// Dart ddd = map.alpha1(map.alpha1(dd));
// while(ddd != dd)
// {
// if (!MovingObstMark.isMarked(ddd))
// {
// neighborObstvect[ddd].push_back(o);
// OneRingMark.mark(ddd);
// }
// ddd = map.alpha1(ddd);
// }
// dd = map.phi1(dd);
// } while(dd != d);
}
inline void EnvMap::popObstacleInCells(Obstacle* o, Dart d)
......@@ -409,20 +398,7 @@ inline void EnvMap::popObstacleInCells(Obstacle* o, Dart d)
removeElementFromVector<Obstacle* >(obstvect[d], o);
//
//
// Dart dd = d;
// do
// {
// Dart ddd = map.alpha1(map.alpha1(dd));
// while(ddd != dd)
// {
// removeElementFromVector<Dart* >(neighborObstvect[ddd], o);
// ddd = map.alpha1(ddd);
// }
// dd = map.phi1(dd);
// } while(dd != d);
// MovingObstMark.unmark(d);
// removeElementFromVector<Obstacle* >(obstvect[map.phi<12>(d)],o);
// removeElementFromVector<Obstacle* >(obstvect[map.phi2(map.phi_1(d))],o);
......@@ -444,82 +420,84 @@ inline void EnvMap::clearUpdateCandidates()
refineCandidate.clear();
coarsenCandidate.clear();
}
inline void EnvMap::addMovingObstAsNeighbor (MovingObstacle * mo,std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells)
{
assert(map.getCurrentLevel() == map.getMaxLevel());
(*neighbor_cells).clear();
MovingObstMark.unmarkAll();
OneRingMark.unmarkAll();
for(std::list<Dart>::iterator it= belonging_cells.begin();it!=belonging_cells.end();++it)
{
MovingObstMark.mark(*it);
}
///addMovingObstAsNeighbor est pour détecter les voisins du movingobstacle global afin de le considerer comme un super agent
std::list<Dart>::iterator it=belonging_cells.begin();
Dart beg = NIL;
Dart first =NIL;
Dart d=NIL;
Dart dd=NIL;
//boucle pour trouver la premiere case
do {
beg = *it;
first = NIL;
d=beg;
do{
dd=map.alpha1(map.alpha1(d));
do {
if (!MovingObstMark.isMarked(dd))
{
first = dd;
}
dd=map.alpha1(dd);
}while (dd!=d && first==NIL);
d=map.phi1(d);
}while(first==NIL);
++it;
}while((it!=belonging_cells.end())&&first==NIL);
// CGoGNout << "coucou je suis la2 et " << "first = "<< first << " et est ce un obstacle ?"<< MovingObstMark.isMarked(first)<< CGoGNendl;
d=first;
// int tour =0;
do{
if (!OneRingMark.isMarked(d))
{
OneRingMark.mark(d);
(*neighbor_cells).push_back(d);
// CGoGNout << "Dart marquée : "<< d<< CGoGNendl;
}
find_next(&d);
// CGoGNout << "Dart suivante : "<< d<< CGoGNendl;
// tour++;
// if(tour==20) break;
}while(!map.sameFace(d,first));
// Dart dd = belonging_cells[0];
// do
// {
// Dart ddd = map.alpha1(map.alpha1(dd));
// while(ddd != dd)
//inline void EnvMap::addMovingObstAsNeighbor (MovingObstacle * mo,std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells)
//{
// assert(map.getCurrentLevel() == map.getMaxLevel());
// (*neighbor_cells).clear();
// MovingObstMark.unmarkAll();
// OneRingMark.unmarkAll();
//
// for(std::list<Dart>::iterator it= belonging_cells.begin();it!=belonging_cells.end();++it)
//
// {
// MovingObstMark.mark(*it);
// }
//
//
// std::list<Dart>::iterator it=belonging_cells.begin();
// Dart beg = NIL;
// Dart first =NIL;
// Dart d=NIL;
// Dart dd=NIL;
// //boucle pour trouver la premiere case
// do {
// beg = *it;
// first = NIL;
// d=beg;
//
// do{
//
// dd=map.alpha1(map.alpha1(d));
// do {
//
// if (!MovingObstMark.isMarked(dd))
// {
// first = dd;
// }
// dd=map.alpha1(dd);
// }while (dd!=d && first==NIL);
// d=map.phi1(d);
// }while(first==NIL);
// ++it;
// }while((it!=belonging_cells.end())&&first==NIL);
//
//// CGoGNout << "coucou je suis la2 et " << "first = "<< first << " et est ce un obstacle ?"<< MovingObstMark.isMarked(first)<< CGoGNendl;
//
// d=first;
//// int tour =0;
// do{
// if (!OneRingMark.isMarked(d))
// {
// removeElementFromVector<Agent* >(neighborAgentvect[ddd], agent);
// ddd = map.alpha1(ddd);
// OneRingMark.mark(d);
// (*neighbor_cells).push_back(d);
//// CGoGNout << "Dart marquée : "<< d<< CGoGNendl;
//
// }
// dd = map.phi1(dd);
// } while(dd != d);
//
}
// find_next(mo->obstacles_[0],&d);
//// CGoGNout << "Dart suivante : "<< d<< CGoGNendl;
//// tour++;
//// if(tour==20) break;
// }while(!map.sameFace(d,first));
//
//
//// Dart dd = belonging_cells[0];
//// do
//// {
//// Dart ddd = map.alpha1(map.alpha1(dd));
//// while(ddd != dd)
//// {
//// removeElementFromVector<Agent* >(neighborAgentvect[ddd], agent);
//// ddd = map.alpha1(ddd);
//// }
//// dd = map.phi1(dd);
//// } while(dd != d);
////
//
//}
#endif
......
......@@ -8,7 +8,7 @@ namespace ExportScene
{