Commit 05ca3da0 authored by Mohcine Chraibi's avatar Mohcine Chraibi

Fixes #207

parent d193aa1e
...@@ -81,7 +81,7 @@ void AgentsSourcesManager::Run() ...@@ -81,7 +81,7 @@ void AgentsSourcesManager::Run()
long updateFrequency = 2; // 1 = second long updateFrequency = 2; // 1 = second
do do
{ {
int current_time = Pedestrian::GetGlobalTime(); int current_time = (int)Pedestrian::GetGlobalTime();
if ((current_time != _lastUpdateTime) if ((current_time != _lastUpdateTime)
&& ((current_time % updateFrequency) == 0)) && ((current_time % updateFrequency) == 0))
...@@ -108,7 +108,7 @@ bool AgentsSourcesManager::ProcessAllSources() const ...@@ -108,7 +108,7 @@ bool AgentsSourcesManager::ProcessAllSources() const
Log->Write("INFO:\tSource %d generating %d agents (%d remaining)",src->GetId(),peds.size(),src->GetPoolSize()); Log->Write("INFO:\tSource %d generating %d agents (%d remaining)",src->GetId(),peds.size(),src->GetPoolSize());
//ComputeBestPositionRandom(src.get(), peds); //ComputeBestPositionRandom(src.get(), peds);
//todo: compute the optimal position for insertion using voronoi //todo: here every pedestrian needs an exitline
if( !ComputeBestPositionVoronoiBoost(src.get(), peds, _building) ) if( !ComputeBestPositionVoronoiBoost(src.get(), peds, _building) )
Log->Write("INFO:\t there was no place for some pedestrians"); Log->Write("INFO:\t there was no place for some pedestrians");
AgentsQueueIn::Add(peds); AgentsQueueIn::Add(peds);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
//#include <string> //#include <string>
//#include <random> //#include <random>
//#include "boost/polygon/voronoi.hpp" #include "boost/polygon/voronoi.hpp"
using boost::polygon::voronoi_builder; using boost::polygon::voronoi_builder;
using boost::polygon::voronoi_diagram; using boost::polygon::voronoi_diagram;
using boost::polygon::x; using boost::polygon::x;
...@@ -37,24 +37,24 @@ using boost::polygon::high; ...@@ -37,24 +37,24 @@ using boost::polygon::high;
//wrapping the boost objects (just the point object) //wrapping the boost objects (just the point object)
//namespace boost { namespace boost {
//namespace polygon { namespace polygon {
//template <> template <>
//struct geometry_concept<Point> { struct geometry_concept<Point> {
// typedef point_concept type; typedef point_concept type;
//}; };
//
//template <> template <>
//struct point_traits<Point> { struct point_traits<Point> {
// typedef int coordinate_type; typedef int coordinate_type;
//
// static inline coordinate_type get( static inline coordinate_type get(
// const Point& point, orientation_2d orient) { const Point& point, orientation_2d orient) {
// return (orient == HORIZONTAL) ? point._x : point._y; return (orient == HORIZONTAL) ? point._x : point._y;
// } }
//}; };
//} // polygon } // polygon
//} // boost } // boost
using namespace std; using namespace std;
...@@ -282,8 +282,14 @@ void VoronoiAdjustVelocityNeighbour(voronoi_diagram<double>::const_vertex_iterat ...@@ -282,8 +282,14 @@ void VoronoiAdjustVelocityNeighbour(voronoi_diagram<double>::const_vertex_iterat
double no1=0,no2=0; double no1=0,no2=0;
double backup_speed = 0; double backup_speed = 0;
std::size_t index; std::size_t index;
Point v(0,0);
Point v = (ped->GetExitLine()->ShortestPoint(ped->GetPos())- ped->GetPos()).Normalized(); //the direction if(ped->GetExitLine() != nullptr)
v = (ped->GetExitLine()->ShortestPoint(ped->GetPos())- ped->GetPos()).Normalized(); //the direction
else
{
int gotRoute = ped->FindRoute();
if(gotRoute < 0) printf("\nWARNING: source agent %d can not get exit\n", ped->GetID());
}
double speed = 0; double speed = 0;
do do
{ {
......
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