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 53281d25 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

Merge cgogn:~jund/CGoGN_Apps/SocialAgents2

Conflicts:
	CMakeLists.txt
	graphData/graphBenchMemoryCircles1000.svg
	src/env_map.cpp
	src/simulator.cpp
parents 5da65bb7 9c6edaab
......@@ -43,6 +43,14 @@ 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);
/*******************************************************************************/
template <typename PFP>
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, typename PFP::TVEC3& position);
......
......@@ -493,6 +493,15 @@ void generatePathToUpperStair(typename PFP::MAP& map,typename PFP::TVEC3& positi
} while(dd!=dInBetweenDown);
}
template <typename PFP>
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);
prim.embedSphere(radius);
}
template <typename PFP>
void simplifyFreeSpace(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& obstacleMark, CellMarker& buildingMark)
{
......
......@@ -60,7 +60,7 @@ public :
void subdivideAllToMaxLevel();
void subdivideToProperLevel();
void init();
void init(unsigned int config);
void foreach_neighborFace(Dart d, FunctorType& f);
......
......@@ -85,6 +85,8 @@ public:
~Simulator();
void init(unsigned int config, float dimension, bool enablePathFinding=false);
void doStep();
bool reachedGoal();
......@@ -97,6 +99,7 @@ public:
void addPathToCorner();
void addPathsToAgents();
void addPathsToAgents_height();
bool importAgents(std::string filename);
bool exportAgents(std::string filename);
......
......@@ -32,44 +32,6 @@ EnvMap::EnvMap() :
refineCandidate.reserve(100);
coarsenCandidate.reserve(100);
// std::string filename = "/home/jund/Desktop/drawingQuads.svg";
// std::string filename = "/home/jund/Desktop/drawingTest.svg";
// std::string filename = "/home/jund/Desktop/drawingSimple.svg";
// std::string filename = "/home/jund/Desktop/drawingLines.svg";
// std::string filename = "/home/jund/Desktop/mapKrutSimple.svg";
// std::string filename = "/home/jund/Desktop/mapKrutVid.svg";
// std::string filename = "/home/jund/Desktop/mapKrut.svg";
// Algo::Import::importSVG<PFP>(map,filename,position, obstacleMark, buildingMark,false,true);
// markPedWay();
// positionScenary = mapScenary.addAttribute<PFP::VEC3>(VERTEX, "positionS");
// normalScenary = mapScenary.addAttribute<PFP::VEC3>(VERTEX, "normalS");
// Algo::Import::importSVG<PFP>(mapScenary,filename,positionScenary, obstacleMarkS, buildingMarkS,true,false);
// scale(3.2808399f);
// CellMarker faceM(mapScenary, FACE);
// Dart end = mapScenary.end();
// for(Dart d = mapScenary.begin(); d != end; mapScenary.next(d))
// {
// if(!faceM.isMarked(d))
// {
// faceM.mark(d);
// if(Algo::Geometry::faceNormal<PFP>(mapScenary, d, positionScenary)[2] > 0)
// {
// float height = 10 + rand()%50;
// if(!Algo::Geometry::isFaceConvex<PFP>(mapScenary,d, positionScenary))
// Algo::Modelisation::extrudeFace<PFP>(mapScenary, positionScenary, d, height);
// else
// CityGenerator::generateBuilding<PFP>(mapScenary, positionScenary, d, (1+(rand()%3)) * height / 2.0f, 3, obstacleMarkS, buildingMarkS);
// }
// }
// }
// Algo::BooleanOperator::mergeVertices<PFP>(map,position);
// Algo::Modelisation::CatmullClarkSubdivision<PFP>(map,position);
// Algo::Modelisation::computeDual<PFP>(map);
}
void EnvMap::markPedWay()
......@@ -261,16 +223,40 @@ Dart EnvMap::getBelongingCell(const PFP::VEC3& pos)
return map.begin();
}
void EnvMap::init()
void EnvMap::init(unsigned int config)
{
float sideSize = 70.0f;
unsigned int nbSquares = 20;
unsigned int nbSquares = 24;
CityGenerator::generateGrid<PFP>(map, position, nbSquares, nbSquares, sideSize, obstacleMark, buildingMark);
// CityGenerator::generateCorridor<PFP>(map, position, obstacleMark, buildingMark, 50, nbSquares);
// CityGenerator::generateCity<PFP>(this, sideSize, nbSquares);
// CityGenerator::generateTrianGrid<PFP>(map, position, nbSquares, nbSquares, sideSize, obstacleMark, buildingMark);
// CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
switch(config)
{
case 0 : CityGenerator::generateGrid<PFP>(map, position, nbSquares, nbSquares, sideSize, obstacleMark, buildingMark);
break;
case 1 : CityGenerator::generateCity<PFP>(this, sideSize, nbSquares);
break;
case 2 : CityGenerator::generateMall<PFP>(map, position, obstacleMark, buildingMark, sideSize);
break;
case 3 :
{
// std::string filename = "/home/jund/Desktop/drawingQuads.svg";
// std::string filename = "/home/jund/Desktop/drawingTest.svg";
// std::string filename = "/home/jund/Desktop/drawingSimple.svg";
// std::string filename = "/home/jund/Desktop/drawingLines.svg";
// std::string filename = "/home/jund/Desktop/mapKrutSimple.svg";
std::string filename = "/home/jund/Desktop/mapKrut.svg";
Algo::Import::importSVG<PFP>(map,filename,position, obstacleMark, buildingMark);
scale(3.2808399f);
Algo::BooleanOperator::mergeVertices<PFP>(map,position);
DartMarker amelk(map);
map.closeMap(amelk);
Algo::Modelisation::CatmullClarkSubdivision<PFP>(map,position);
Algo::Modelisation::computeDual<PFP>(map);
}
break;
case 4 : CityGenerator::generatePlanet<PFP>(map, position, obstacleMark, buildingMark, 200.0f, nbSquares);
break;
}
// CityGenerator::simplifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
// CityGenerator::convexifyFreeSpace<PFP>(map, position, obstacleMark, buildingMark);
......
......@@ -5,20 +5,45 @@ Simulator::Simulator() : timeStep_(0.2f), globalTime_(0.0f), nbSteps_(0)
srand(10);
nbStepsPerUnit_ = 1 / timeStep_;
envMap_.init();
init(0,2.0f);
}
Simulator::~Simulator()
{
for (unsigned int i = 0; i < agents_.size(); ++i)
delete agents_[i];
}
void Simulator::init(unsigned int config, float dimension, bool enablePathFinding)
{
envMap_.init(config);
std::cout << "setup scenario" << std::endl;
// importAgents("myAgents.pos");
setupScenario(1000);
// setupCircleScenario(1000);
// setupCityScenario(
// -1.0f * (24 * (70.0f / 2.0f) - 10),
// -1.0f * (24 * (70.0f / 2.0f) - 10),
// 20,
// 20
// );
// addPathsToAgents();
switch(config)
{
case 0 : setupCircleScenario(1000);
break;
case 1 : importAgents("myAgents.pos");
break;
case 2 : setupScenario(700);
break;
case 3 : setupCityScenario(
-1.0f * (12 * (70.0f / 2.0f) - 10),
-1.0f * (12 * (70.0f / 2.0f) - 10),
20,
20
);
break;
}
if(enablePathFinding)
{
if(dimension==2.0f)
addPathsToAgents();
else if(dimension==2.5f)
addPathsToAgents_height();
}
// setupMovingObstacle(1);
......@@ -40,12 +65,6 @@ Simulator::Simulator() : timeStep_(0.2f), globalTime_(0.0f), nbSteps_(0)
envMap_.subdivideToProperLevel();
}
Simulator::~Simulator()
{
for (unsigned int i = 0; i < agents_.size(); ++i)
delete agents_[i];
}
void Simulator::doStep()
{
envMap_.clearUpdateCandidates();
......@@ -349,6 +368,57 @@ void Simulator::addPathsToAgents()
}
}
void Simulator::addPathsToAgents_height()
{
//city
unsigned int dartDistForPath = 50;
for(unsigned int i = 0; i < agents_.size(); ++i)
{
agents_[i]->goals_.clear();
Dart dStart = agents_[i]->part_.d;
Dart dStop = dStart;
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop) || j < dartDistForPath+rand()*20 || envMap_.map.sameFace(dStop,dStart); ++j)
{
envMap_.map.next(dStop);
if(dStop == envMap_.map.end())
dStop = envMap_.map.begin();
}
std::vector<Dart> path = CGoGN::PathFinder::pathFindAStar<PFP>(envMap_.map, envMap_.position, dStart, dStop, envMap_.buildingMark);
for(std::vector<Dart>::iterator it = path.begin(); it != path.end(); ++it)
{
VEC3 dest = Algo::Geometry::faceCentroid<PFP>(envMap_.map, *it, envMap_.position);
agents_[i]->goals_.push_back(dest);
}
Dart dStop2 = dStop;
for(unsigned int j = 0; envMap_.buildingMark.isMarked(dStop2) || j < dartDistForPath+rand()*20 || envMap_.map.sameFace(dStop,dStop2) || envMap_.map.sameFace(dStop2,dStart); ++j)
{
envMap_.map.next(dStop2);
if(dStop2 == envMap_.map.end())
dStop2 = envMap_.map.begin();
}
path = CGoGN::PathFinder::pathFindAStar<PFP>(envMap_.map, envMap_.position, dStop, dStop2, envMap_.buildingMark);
for(std::vector<Dart>::iterator it = path.begin(); it!=path.end();++it)
{
VEC3 dest = Algo::Geometry::faceCentroid<PFP>(envMap_.map, *it, envMap_.position);
agents_[i]->goals_.push_back(dest);
}
path = CGoGN::PathFinder::pathFindAStar<PFP>(envMap_.map, envMap_.position, dStop2, dStart, envMap_.buildingMark);
for(std::vector<Dart>::iterator it = path.begin(); it!=path.end();++it)
{
VEC3 dest = Algo::Geometry::faceCentroid<PFP>(envMap_.map, *it, envMap_.position);
agents_[i]->goals_.push_back(dest);
}
}
}
bool Simulator::importAgents(std::string filename)
{
std::ifstream myfile(filename.c_str(), std::ios::in);
......@@ -456,5 +526,3 @@ void Simulator::setupMovingObstacle( unsigned int nbMovingObstacles)
MovingObstacle* mo = new MovingObstacle(&envMap_, vPos);
movingObstacles_.push_back(mo);
}
......@@ -178,7 +178,7 @@ void SocialAgents::cb_redraw()
{
glColor3f((*it)->part_.state / 3.0f, (*it)->part_.state % 2, 0.0f);
glLineWidth(5.0f);
renderPredictionTriangle(sim.envMap_, (*it)->part_.d, (*it)->part_.m_position);
renderPredictionTriangle(sim.envMap_, (*it)->part_.d, (*it)->getPosition());
}
}
......@@ -502,23 +502,6 @@ void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
}
}
// if(j==0) {
// out << "object {" << " Sheriff_animated_ " << std::endl;
// out << "scale 0.165745856" << std::endl;
// }
// else if(j%7==0) {
// out << "object {" << " Cowbow_animated_ " << std::endl;
// out << "scale 0.170454545" << std::endl;
// }
// else if(j%7<5) {
// out << "object {" << " sombrero2_highres_ " << std::endl;
// out << "scale 0.127659574" << std::endl;
// }
// else {
// out << "object {" << " sombrero3_highres_ " << std::endl;
// out << "scale 0.132743363" << std::endl;
// }
out << "cylinder {" << " <0,0,0>, <0,6,0>, 1.5 " << std::endl;
out << "scale 0.5" << std::endl;
......@@ -573,24 +556,6 @@ void SocialAgents::exportInfoFace(std::ofstream& out, Dart d)
}
}
// if(j==0) {
// out << "object {" << " Sheriff_animated_ " << std::endl;
// out << "scale 0.165745856" << std::endl;
// }
// else if(j%7==0) {
// out << "object {" << " Cowbow_animated_ " << std::endl;
// out << "scale 0.170454545" << std::endl;
// }
// else if(j%7<5) {
// out << "object {" << " sombrero2_highres_ " << std::endl;
// out << "scale 0.127659574" << std::endl;
// }
// else {
// out << "object {" << " sombrero3_highres_ " << std::endl;
// out << "scale 0.132743363" << std::endl;
//
// }
out << "cylinder {" << " <0,0,0>, <0,6,0>, 1.5 " << std::endl;
out << "scale 0.5" << std::endl;
......
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