Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit e5aa38ee authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

correction critere subdivision (taille / rayon)

parent c6aee824
......@@ -49,13 +49,13 @@ public:
std::vector<VEC3> goals_;
unsigned int curGoal_;
size_t maxNeighbors_;
float maxSpeed_;
float neighborDistSq_;
float radius_;
float timeHorizon_;
float timeHorizonObst_;
float rangeSq_;
static size_t maxNeighbors_;
static float maxSpeed_;
static float neighborDistSq_;
static float radius_;
static float timeHorizon_;
static float timeHorizonObst_;
static float rangeSq_;
VEC3 velocity_;
VEC3 newVelocity_;
......
......@@ -40,6 +40,8 @@ struct PFP: public PFP_STANDARD
typedef NoMathIONameAttribute<OBSTACLES> OBSTACLEVECT;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
typedef AttributeHandler<OBSTACLEVECT> TAB_OBSTACLEVECT;
typedef NoMathIONameAttribute<std::pair<bool,bool> > BOOLATTRIB;
};
typedef PFP::VEC3 VEC3;
......@@ -70,7 +72,7 @@ public :
void addRefineCandidate(Dart d);
void addCoarsenCandidate(Dart d);
void clearUpdateCandidates();
void updateMap();
void resetAgentInFace(Agent* agent);
......@@ -80,6 +82,8 @@ public :
PFP::TVEC3 position;
PFP::TVEC3 normal;
AttributeHandler<PFP::BOOLATTRIB> subdivisableFace;
PFP::TAB_AGENTVECT agentvect;
PFP::TAB_AGENTVECT neighborAgentvect;
......@@ -88,7 +92,7 @@ public :
CellMarker obstacleMark;
CellMarker buildingMark;
static const unsigned int nbAgentsToSubdivide = 3;
static const unsigned int nbAgentsToSubdivide = 7;
static const unsigned int nbAgentsToSimplify = 7;
std::map<unsigned int, Dart> refineCandidate;
......
......@@ -21,7 +21,7 @@ inline float det2D(const VEC3& vector1, const VEC3& vector2)
return vector1[0] * vector2[1] - vector1[1] * vector2[0];
}
inline float distSqPointLineSegment( VEC3 a1, VEC3 b1, const VEC3& c1)
inline float distSqPointLineSegment(VEC3 a1, VEC3 b1, const VEC3& c1)
{
a1[2] = 0;
b1[2] = 0;
......
#include "agent.h"
#include "simulator.h"
size_t Agent::maxNeighbors_ = 10;
float Agent::maxSpeed_ = 2.0f;
float Agent::neighborDistSq_ = 15.0f * 15.0f;
float Agent::radius_ = 1.5f;
float Agent::timeHorizon_ = 10.0f;
float Agent::timeHorizonObst_ = 10.0f;
float Agent::rangeSq_ = (timeHorizonObst_ * maxSpeed_ + radius_) * (timeHorizonObst_ * maxSpeed_ + radius_);
Agent::Agent(Simulator* sim, const VEC3& position, Dart d) :
part_(sim->envMap_.map, d, position, sim->envMap_.position),
curGoal_(-1),
maxNeighbors_(10),
maxSpeed_(2.0f),
neighborDistSq_(15.0f * 15.0f),
radius_(1.5f),
timeHorizon_(10.0f),
timeHorizonObst_(10.0f),
velocity_(0),
newVelocity_(0),
prefVelocity_(0),
sim_(sim)
{
rangeSq_ = (timeHorizonObst_ * maxSpeed_ + radius_) * (timeHorizonObst_ * maxSpeed_ + radius_);
}
{}
VEC3 Agent::getPosition()
{
......
......@@ -16,6 +16,7 @@ EnvMap::EnvMap() : obstacleMark(map, EDGE_CELL), buildingMark(map, FACE_CELL)
agentvect = map.addAttribute<PFP::AGENTVECT>(FACE_ORBIT, "agents");
neighborAgentvect = map.addAttribute<PFP::AGENTVECT>(FACE_ORBIT, "neighborAgents");
obstvect = map.addAttribute<PFP::OBSTACLEVECT>(FACE_ORBIT, "obstacles");
subdivisableFace = map.addAttribute<PFP::BOOLATTRIB>(FACE_ORBIT, "subdivisableFace");
}
unsigned int EnvMap::mapMemoryCost()
......@@ -41,12 +42,14 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
void EnvMap::init()
{
float sideSize = 70.0f;
unsigned int nbSquares = 7;
unsigned int nbSquares = 25;
CityGenerator::generateCity<PFP>(map, position, obstacleMark, buildingMark, sideSize, nbSquares);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
CityGenerator::simplifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
map.init();
registerObstaclesInFaces();
for(unsigned int i = subdivisableFace.begin(); i < subdivisableFace.end(); subdivisableFace.next(i))
subdivisableFace[i].first = false ;
}
void EnvMap::foreach_neighborFace(Dart d, FunctorType& f)
......@@ -225,62 +228,97 @@ void EnvMap::updateMap()
if(agentvect[old].size() > nbAgentsToSubdivide)
{
PFP::AGENTS oldAgents(agentvect[old]);
for(PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
popAgentInCells(*ait, old);
neighborAgentvect[old].clear() ;
map.setCurrentLevel(fLevel) ;
CellMarkerStore newF(map, FACE_CELL);
newF.mark(old);
Algo::IHM::subdivideFace<PFP>(map, old, position) ;
map.setCurrentLevel(map.getMaxLevel()) ;
for(PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
bool subdivisable = true ;
if(subdivisableFace[old].first == true)
{
resetAgentInFace(*ait) ;
pushAgentInCells(*ait, (*ait)->part_.d) ;
subdivisable = subdivisableFace[old].second ;
}
unsigned int degree = 0;
Dart dd = old;
do
else
{
++degree;
Dart d3 = dd;
float maxEdgeSize = Agent::neighborDistSq_ ; // diametre de vision de l'agent au carré
map.setCurrentLevel(fLevel) ;
PFP::VEC3 fCenter = Algo::Geometry::faceCentroid<PFP>(map, old, position) ;
Dart fd = old ;
do
{
Dart d4 = map.alpha1(map.alpha1(d3));
while(d4 != d3)
PFP::VEC3 edge = Algo::Geometry::vectorOutOfDart<PFP>(map, fd, position) ;
PFP::VEC3 proj = fCenter - (position[fd] + (edge * (fCenter - position[fd]) / edge.norm2()) * edge) ;
if(proj.norm2() < maxEdgeSize)
// if(Algo::Geometry::vectorOutOfDart<PFP>(map, fd, position).norm2() < maxEdgeSize)
{
if(!newF.isMarked(d4))
neighborAgentvect[d3].insert(neighborAgentvect[d3].end(), agentvect[d4].begin(), agentvect[d4].end());
d4 = map.alpha1(d4);
subdivisable = false ;
break ;
}
d3 = map.phi1(d3);
} while(d3 != dd);
fd = map.phi1(fd) ;
} while(fd != old) ;
map.setCurrentLevel(map.getMaxLevel()) ;
subdivisableFace[old].first = true ;
subdivisableFace[old].second = subdivisable ;
}
if(subdivisable)
{
subdivisableFace[old].first = false ;
PFP::AGENTS oldAgents(agentvect[old]);
for(PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
popAgentInCells(*ait, old);
neighborAgentvect[old].clear() ;
map.setCurrentLevel(fLevel) ;
dd = map.phi1(dd);
CellMarkerStore newF(map, FACE_CELL);
newF.mark(old);
Algo::IHM::subdivideFace<PFP>(map, old, position) ;
map.setCurrentLevel(map.getMaxLevel()) ;
} while(dd != old);
for(PFP::AGENTS::iterator ait = oldAgents.begin(); ait != oldAgents.end(); ++ait)
{
resetAgentInFace(*ait) ;
pushAgentInCells(*ait, (*ait)->part_.d) ;
}
if(degree == 3)
{
Dart centerFace = map.phi2(map.phi1(old));
Dart d3 = centerFace;
unsigned int degree = 0;
Dart dd = old;
do
{
Dart d4 = map.alpha1(map.alpha1(d3));
while(d4 != d3)
++degree;
Dart d3 = dd;
do
{
if(!newF.isMarked(d4))
neighborAgentvect[d3].insert(neighborAgentvect[d3].end(), agentvect[d4].begin(), agentvect[d4].end());
d4 = map.alpha1(d4);
}
d3 = map.phi1(d3);
} while(d3 != centerFace);
Dart d4 = map.alpha1(map.alpha1(d3));
while(d4 != d3)
{
if(!newF.isMarked(d4))
neighborAgentvect[d3].insert(neighborAgentvect[d3].end(), agentvect[d4].begin(), agentvect[d4].end());
d4 = map.alpha1(d4);
}
d3 = map.phi1(d3);
} while(d3 != dd);
map.setCurrentLevel(fLevel) ;
dd = map.phi1(dd);
map.setCurrentLevel(map.getMaxLevel()) ;
} while(dd != old);
if(degree == 3)
{
Dart centerFace = map.phi2(map.phi1(old));
Dart d3 = centerFace;
do
{
Dart d4 = map.alpha1(map.alpha1(d3));
while(d4 != d3)
{
if(!newF.isMarked(d4))
neighborAgentvect[d3].insert(neighborAgentvect[d3].end(), agentvect[d4].begin(), agentvect[d4].end());
d4 = map.alpha1(d4);
}
d3 = map.phi1(d3);
} while(d3 != centerFace);
}
}
}
}
......
#include "simulator.h"
Simulator::Simulator() : globalTime_(0.0f), timeStep_(0.05f)
Simulator::Simulator() : globalTime_(0.0f), timeStep_(0.25f)
{
srand(10);
envMap_.init();
std::cout << "setup scenario" << std::endl;
// importAgents("myAgents.pos");
setupScenario();
importAgents("myAgents.pos");
// setupScenario();
// addPathsToAgents();
for(unsigned int i = 0; i < agents_.size(); ++i)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment