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

Fixes #207

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