Commit 4801340b authored by pitiot's avatar pitiot
Browse files

premieres modifs

parent 0f0720c7
......@@ -25,7 +25,7 @@ public:
void updateObstacleNeighbors();
void update();
void obstacle_priority(PFP::VEC3 * goalVector); //ajout moving obst
void computePrefVelocity();
void computeNewVelocity();
......@@ -51,7 +51,7 @@ public:
std::vector<std::pair<float, Agent*> > agentNeighbors_;
std::vector<std::pair<float, Obstacle*> > obstacleNeighbors_;
std::vector<std::pair<float, Obstacle*> > movingObstacleNeighbors_;
#ifdef SPATIAL_HASHING
VEC3 pos ;
#else
......@@ -60,7 +60,7 @@ public:
std::vector<VEC3> goals_;
VEC3 finalGoal;
VEC3 finalGoal;
Dart finalDart;
unsigned int curGoal_;
......@@ -78,6 +78,10 @@ public:
static float timeStep ;
static unsigned int cptAgent ;
float color1;
float color2;
float color3;
unsigned int agentNo ;
VEC3 velocity_;
......@@ -88,6 +92,7 @@ public:
VEC3 meanPos_;
Simulator* sim_;
bool alive;
};
#endif
......@@ -11,16 +11,16 @@ namespace CityGenerator
{
template <typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark);
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark);
template <typename PFP>
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> generateGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
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> generateTrianGrid(typename PFP::MAP& map, typename PFP::TVEC3& position, unsigned int cX, unsigned int cY, float sideLength, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<FACE>& buildingMark, float height);
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& 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,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize);
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize);
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, Dart dLower,Dart dUpper);
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& position, Dart dLower,Dart dUpper);
/*******************************************************************************/
template <typename PFP>
void generatePlanet(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float radius, unsigned int nbSquares);
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float radius, unsigned int nbSquares);
/*******************************************************************************/
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position);
template <typename PFP>
bool isAnEar(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart dd, float& area);
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area);
template <typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<EDGE>& obstacleMark);
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& obstacleMark);
template <typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark);
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark);
template <typename PFP>
void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float height);
void installGuardRail(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float height);
}
......@@ -68,3 +68,4 @@ void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>
#include "env_generator.hpp"
#endif
......@@ -10,7 +10,7 @@ namespace CityGenerator
{
template <typename PFP>
bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark)
bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark)
{
Dart dd = d;
do
......@@ -24,7 +24,7 @@ bool notAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& b
}
template <typename PFP>
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<FACE>& buildingMark)
bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker& buildingMark)
{
Dart dd = d;
do
......@@ -38,21 +38,22 @@ bool notDiagonalAdjacentToAnObstacle(typename PFP::MAP& map, Dart d, CellMarker<
}
template <typename PFP>
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> 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> prim(map, position);
prim.grid_topo(cX, cY);
Dart boundary;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(map.isBoundaryMarked(map.phi2(d)))
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
obstacleMark.mark(d);
boundary = map.phi2(d);
if(map.isBoundaryMarked(d))
{
obstacleMark.mark(d);
boundary = d;
}
}
}
buildingMark.mark(boundary);
// buildingMark.mark(boundary);
prim.embedGrid(sideLength * cX, sideLength * cY);
......@@ -60,7 +61,7 @@ Algo::Modelisation::Polyhedron<PFP> generateGrid(typename PFP::MAP& map, VertexA
}
template <typename PFP>
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> 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> prim(map, position);
prim.grid_topo(cX, cY);
......@@ -158,7 +159,7 @@ Algo::Modelisation::Polyhedron<PFP> generateTrianGrid(typename PFP::MAP& map, Ve
}
template <typename PFP>
Dart extrudeFaceAndMark(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<FACE>& buildingMark, float height)
Dart extrudeFaceAndMark(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& buildingMark, float height)
{
Dart dRoof = Algo::Modelisation::extrudeFace<PFP>(map, position, d, height);
buildingMark.mark(dRoof);
......@@ -176,11 +177,11 @@ template <typename PFP>
bool animateCity(EnvMap* envMap)
{
typename PFP::MAP& map = envMap->map;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
typename PFP::TVEC3& position = envMap->position;
typename PFP::TAB_AGENTVECT& agents = envMap->agentvect;
typename PFP::TAB_AGENTVECT& agentNeighbors = envMap->neighborAgentvect;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
std::vector<Dart>& newBuildings = envMap->newBuildings;
unsigned int state = rand() % 10;
......@@ -257,19 +258,19 @@ bool animateCity(EnvMap* envMap)
#endif
//template <typename PFP>
//Dart generateBuilding(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, float height, unsigned int buildingType, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
//Dart generateBuilding(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, float height, unsigned int buildingType, CellMarker& obstacleMark, CellMarker& buildingMark)
//template <typename PFP>
//void generateCity(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize, unsigned int nbSquares)
//void generateCity(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& 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;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
typename PFP::TVEC3& position = envMap->position;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
// mark the face as obstacle before extrusion
Dart dd = d;
......@@ -307,7 +308,14 @@ Dart generateBuilding(EnvMap* envMap, Dart d, float height, unsigned int buildin
pos += step ;
}
#else
envMap->pushObstacleInCells(o, map.phi2(dd));
Dart x =map.phi2(dd);
if(!map.isBoundaryMarked(x))
{
envMap->pushObstacleInCells(o, x);
if(!map.isBoundaryMarked(map.phi2(map.phi1(x))))envMap->pushObstacleInCells(o, map.phi2(map.phi1(x)));
if(!map.isBoundaryMarked(map.phi2(map.phi_1(x))))envMap->pushObstacleInCells(o, map.phi2(map.phi_1(x)));
}
#endif
dd = map.phi1(dd);
......@@ -378,9 +386,9 @@ template <typename PFP>
void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares)
{
typename PFP::MAP& map = envMap->map;
VertexAttribute<typename PFP::VEC3>& position = envMap->position;
CellMarker<EDGE>& obstacleMark = envMap->obstacleMark;
CellMarker<FACE>& buildingMark = envMap->buildingMark;
typename PFP::TVEC3& position = envMap->position;
CellMarker& obstacleMark = envMap->obstacleMark;
CellMarker& buildingMark = envMap->buildingMark;
unsigned int nbBuilding = 1000;
float height = sideSize / 2.0f;
......@@ -402,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);
generateBuilding<PFP>(envMap, d, (1+(rand()%3)) * height / 2.0f, rand() % 4); /////////////////commentaire temporaire/////////
--nbBuilding;
// }
}
......@@ -410,7 +418,7 @@ void generateCity(EnvMap* envMap, float sideSize, unsigned int nbSquares)
}
template <typename PFP>
void generateMall(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float sideSize)
void generateMall(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float sideSize)
{
unsigned int side = 5;
std::vector<Algo::Modelisation::Polyhedron<PFP> > floors;
......@@ -424,7 +432,7 @@ void generateMall(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& po
{
float floorHeight = 100;
typename PFP::VEC3 transl(0,0,floorHeight);
CellMarker<VERTEX> m(map) ;
CellMarker m(map, VERTEX) ;
for(Dart d=map.begin();d!=map.end();map.next(d))
{
......@@ -464,7 +472,7 @@ void generateMall(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& po
}
template <typename PFP>
void generatePathToUpperStair(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, Dart dLower,Dart dUpper)
void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& 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;
......@@ -523,7 +531,7 @@ void generatePathToUpperStair(typename PFP::MAP& map,VertexAttribute<typename PF
}
template <typename PFP>
void generatePlanet(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float radius, unsigned int nbSquares)
void generatePlanet(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float radius, unsigned int nbSquares)
{
Algo::Modelisation::Polyhedron<PFP> prim(map, position);
prim.cylinder_topo(nbSquares, nbSquares, true, true);
......@@ -532,19 +540,19 @@ void generatePlanet(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>&
}
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark)
{
typedef typename PFP::VEC3 VEC3;
typedef std::multimap<float, Dart> VEC_D_A;
FaceAutoAttribute<float> tableArea(map);
EdgeAutoAttribute<CGoGN::NoMathIONameAttribute<VEC_D_A::iterator> > tableIt(map);
AutoAttributeHandler<float> tableArea(map, FACE);
AutoAttributeHandler<CGoGN::NoMathIONameAttribute<VEC_D_A::iterator> > tableIt(map, EDGE);
VEC_D_A orderedD;
// compute all heuristic and construct multimap
Algo::Geometry::computeAreaFaces<PFP>(map, position, tableArea);
CellMarker<EDGE> eM(map);
CellMarker eM(map, EDGE);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!eM.isMarked(d) && !obstacleMark.isMarked(d) && !buildingMark.isMarked(d))
......@@ -704,7 +712,7 @@ void simplifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC
}
template <typename PFP>
bool isAnEar(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart dd, float& area)
bool isAnEar(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart dd, float& area)
{
typedef typename PFP::VEC3 VEC3;
......@@ -738,7 +746,7 @@ bool isAnEar(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& positi
}
template <typename PFP>
bool canRemoveEdgeConvex(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, Dart d, CellMarker<EDGE>& obstacleMark)
bool canRemoveEdgeConvex(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& obstacleMark)
{
typedef typename PFP::VEC3 VEC3;
......@@ -765,12 +773,12 @@ bool canRemoveEdgeConvex(typename PFP::MAP& map, VertexAttribute<typename PFP::V
}
template <typename PFP>
void convexifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark)
void convexifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark)
{
typedef typename PFP::VEC3 VEC3;
float area;
CellMarker<FACE> m(map);
CellMarker m(map, FACE);
for(Dart d = map.begin();d != map.end(); map.next(d))
{
......@@ -834,10 +842,10 @@ void convexifyFreeSpace(typename PFP::MAP& map, VertexAttribute<typename PFP::VE
}
template <typename PFP>
void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>& position, CellMarker<EDGE>& obstacleMark, CellMarker<FACE>& buildingMark, float height)
void installGuardRail(typename PFP::MAP& map,typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark, float height)
{
CellMarker<EDGE> cm(map);
CellMarkerNoUnmark<EDGE> railVert(map);
CellMarker cm(map,EDGE);
CellMarkerNoUnmark railVert(map,EDGE);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!cm.isMarked(d))
......@@ -898,3 +906,4 @@ void installGuardRail(typename PFP::MAP& map,VertexAttribute<typename PFP::VEC3>
}
}
......@@ -27,6 +27,7 @@ using namespace CGoGN;
class Agent;
class Obstacle;
class MovingObstacle;
struct PFP: public PFP_STANDARD
{
......@@ -37,10 +38,13 @@ struct PFP: public PFP_STANDARD
// definition des listes d'agent
typedef std::vector<Agent*> AGENTS;
typedef std::vector<Obstacle*> OBSTACLES;
typedef std::vector<MovingObstacle*> MOVINGOBSTACLES;
typedef NoMathIONameAttribute<AGENTS> AGENTVECT;
typedef NoMathIONameAttribute<OBSTACLES> OBSTACLEVECT;
typedef AttributeHandler<AGENTVECT, FACE> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT, FACE> TAB_OBSTACLEVECT;
typedef NoMathIONameAttribute<MOVINGOBSTACLES> MOVINGOBSTACLEVECT;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT> TAB_OBSTACLEVECT;
typedef NoMathIONameAttribute<std::pair<bool,bool> > BOOLATTRIB;
};
......@@ -53,7 +57,9 @@ public :
EnvMap();
void markPedWay();
float max_for_obstacles;
float sideSize;
unsigned int nbSquares;
unsigned int mapMemoryCost();
void scale(float scaleVal);
......@@ -70,6 +76,7 @@ public :
void foreach_neighborFace(Dart d, FunctorType& f);
void registerObstaclesInFaces();
void registerWallInFaces();
void addNeighborObstacles(PFP::OBSTACLES& obst, Dart d, bool edgeNeighbor);
void setAgentNeighborsAndObstacles(Agent* agent);
......@@ -83,7 +90,16 @@ public :
void popObstacleInCells(Obstacle* o, Dart d);
void obstacleChangeFace(Obstacle* agent, Dart newFace, Dart oldFace);
void clearUpdateCandidates();
//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 pushObstNeighborInCells(Obstacle* o, Dart d);
void popObstNeighborInCells(Obstacle* o, Dart d);
void find_next(Dart * d);
void clearUpdateCandidates();
void updateMap();
void resetAgentInFace(Agent* agent);
......@@ -91,35 +107,39 @@ public :
PFP::MAP map;
VertexAttribute<VEC3> position;
VertexAttribute<VEC3> normal;
PFP::TVEC3 position;
PFP::TVEC3 normal;
PFP::MAP mapScenary;
VertexAttribute<VEC3> positionScenary;
VertexAttribute<VEC3> normalScenary;
CellMarker<EDGE> obstacleMarkS;
CellMarker<FACE> buildingMarkS;
PFP::TVEC3 positionScenary;
PFP::TVEC3 normalScenary;
CellMarker obstacleMarkS;
CellMarker buildingMarkS;
std::vector<Dart> newBuildings;
#ifndef SPATIAL_HASHING
AttributeHandler<PFP::BOOLATTRIB, FACE> subdivisableFace;
AttributeHandler<PFP::BOOLATTRIB> subdivisableFace;
PFP::TAB_AGENTVECT agentvect;
PFP::TAB_AGENTVECT neighborAgentvect;
PFP::TAB_OBSTACLEVECT obstvect;
#endif
PFP::TAB_OBSTACLEVECT neighborObstvect;
CellMarker<EDGE> obstacleMark;
CellMarker<FACE> buildingMark;
CellMarker<FACE> pedWayMark;
#endif
CellMarker obstacleMark;
CellMarker buildingMark;
CellMarker pedWayMark;
CellMarker MovingObstMark;
CellMarker OneRingMark;
#ifndef SPATIAL_HASHING
static const unsigned int nbAgentsToSubdivide = 5;
static const unsigned int nbAgentsToSimplify = 4;
CellMarker<FACE> refineMark;
CellMarker<FACE> coarsenMark;
CellMarker refineMark;
CellMarker coarsenMark;
std::vector<Dart> refineCandidate;
std::vector<Dart> coarsenCandidate;
#endif
......@@ -149,6 +169,13 @@ public :
#endif
};
void update_registration(Obstacle * o);
void register_pop(Obstacle* o, int n);
void register_add(Obstacle* o, int n);
void resetObstInFace(Obstacle* o);
void resetObstPartInFace(Obstacle* o, Dart d);
void resetPart(MovingObstacle * mo, Dart d);
/**************************************
* INLINE FUNCTIONS *
**************************************/
......@@ -209,37 +236,193 @@ inline void EnvMap::popAgentInCells(Agent* agent, Dart d)
} while(dd != d);
}
inline void EnvMap::pushObstacleInCells(Obstacle* o, Dart d)
//ajout moving obst///////////////////////////////////////////////////////////////////////////////////////////////////////
inline void EnvMap::addObstAsNeighbor (Obstacle * o, std::list<Dart> belonging_cells, std::list<Dart> *neighbor_cells)
{
assert(map.getCurrentLevel() == map.getMaxLevel());
assert(!buildingMark.isMarked(d));
(*neighbor_cells).clear();
MovingObstMark.unmarkAll();
OneRingMark.unmarkAll();
obstvect[d].push_back(o);
for(std::list<Dart>::iterator it= belonging_cells.begin();it!=belonging_cells.end();++it)
{
MovingObstMark.mark(*it);
}
// obstvect[map.phi<12>(d)].push_back(o);
// obstvect[map.phi2(map.phi_1(d))].push_back(o);
// Dart dd = d;
// do
// {
// Dart ddd = map.alpha1(map.alpha1(dd));
// while(ddd != dd)
std::list<Dart>::iterator it=belonging_cells.begin();
Dart beg = NIL;
Dart first =NIL;
Dart d=NIL;
Dart dd=NIL;
int rd1=0,rd2=0,rd3=0;
// CGoGNout << "debut"<<CGoGNendl;
//boucle pour trouver la premiere case
do {
rd3++;
if (rd3>10000) {
CGoGNout<< "infini dans addneighbor obst rd3"<<CGoGNendl;break;
}
beg = *it;
first = NIL;
d=beg;
// CGoGNout << "d = "<<d<<CGoGNendl;
do{
// CGoGNout << "first = "<<first<<CGoGNendl;
if (rd2>10000) {
CGoGNout<< "infini dans addneighbor obst rd2"<<CGoGNendl;break;
}
dd=map.alpha1(map.alpha1(d));
do {
if (rd1>10000) {
CGoGNout<< "infini dans addneighbor obst rd1"<<CGoGNendl;break;
}
if (!MovingObstMark.isMarked(dd))
{
first = dd;
// CGoGNout << "dd1 = "<<first<<CGoGNendl;
}
dd=map.alpha1(dd);
rd1++;
}while (dd!=d && first==NIL);
// CGoGNout << "dd = "<<dd<<CGoGNendl;
d=map.phi1(d);
rd2++;
// CGoGNout << "d2 = "<<d<<" beg = "<< beg<<CGoGNendl;
}while(first==NIL && d!=beg);
++it;
}while((it!=belonging_cells.end())&&first==NIL);
// CGoGNout << "debut2 : first : "<<first <<CGoGNendl;
// CGoGNout << "coucou je suis la2 et " << "first = "<< first << " et est ce un obstacle ?"<< MovingObstMark.isMarked(first)<< CGoGNendl;
int round = 0;
d=first;
// int tour =0;
do{
// CGoGNout << "d = "<< d <<CGoGNendl;
if (!OneRingMark.isMarked(d))
{
OneRingMark.mark(d);
(*neighbor_cells).push_back(d);
// CGoGNout << "Dart marquée : "<< d<< CGoGNendl;
}
find_next(&d);
round ++;
// CGoGNout << "Dart suivante : "<< d<< CGoGNendl;
// tour++;
if(round>10000) {
CGoGNout << "infini calcul voisins"<<CGoGNendl;
break;
}
}while(!map.sameFace(d,first));
// CGoGNout << "fin"<<CGoGNendl;
// Dart dd = belonging_cells[0];
// do
// {
// obstvect[ddd].push_back(o);
// ddd = map.alpha1(ddd);
// }
// Dart ddd = map.alpha1(map.alpha1(dd));
// while(ddd != dd)
// {
// removeElementFromVector<Agent* >(neighborAgentvect[ddd], agent);
// ddd = map.alpha1(ddd);