add dummy pedestrians when numPeds < 3

parent f6bb29e8
Pipeline #17432 failed with stages
in 39 seconds
......@@ -161,6 +161,7 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodD = args->GetStopFramesMethodD();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesD=args->GetIsPlotTimeSeriesD();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
}
if(args->GetIsMethodI()) {
_DoesUseMethodI = true;
......@@ -173,6 +174,7 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodI = args->GetStopFramesMethodI();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesI=args->GetIsPlotTimeSeriesI();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
}
_deltaF = args->GetDelatT_Vins();
......@@ -186,7 +188,6 @@ void Analysis::InitArgs(ArgumentParser* args)
_IgnoreBackwardMovement =args->GetIgnoreBackwardMovement();
_grid_size_X = int(args->GetGridSizeX());
_grid_size_Y = int(args->GetGridSizeY());
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
_geometryFileName=args->GetGeometryFilename();
_projectRootDir=args->GetProjectRootDir();
_trajFormat=args->GetFileFormat();
......@@ -199,11 +200,11 @@ void Analysis::InitArgs(ArgumentParser* args)
std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, const std::vector<MeasurementArea_B*>& areas)
{
_building = new Building();
_building->LoadGeometry(geometryFile.string());
// create the polygons
_building->InitGeometry();
// _building->AddSurroundingRoom();
double geo_minX = FLT_MAX;
double geo_minY = FLT_MAX;
......@@ -221,10 +222,8 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
for (auto&& it_sub : it_room.second->GetAllSubRooms())
{
SubRoom* subroom = it_sub.second.get();
point_2d point(0,0);
boost::geometry::centroid(area->_poly,point);
//check if the area is contained in the obstacle
if(subroom->IsInSubRoom(Point(point.x()/M2CM,point.y()/M2CM)))
{
......@@ -245,7 +244,6 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
geoPoly[area->_id].inners().resize(k++);
geoPoly[area->_id].inners().back();
model::ring<point_2d>& inner = geoPoly[area->_id].inners().back();
for(auto&& tmp_point:obst->GetPolygon())
{
append(inner, make<point_2d>(tmp_point._x*M2CM, tmp_point._y*M2CM));
......@@ -267,9 +265,8 @@ std::map<int, polygon_2d> Analysis::ReadGeometry(const fs::path& geometryFile, c
_highVertexY = geo_maxY;
_lowVertexX = geo_minX;
_lowVertexY = geo_minY;
// using boost::geometry::dsv;
using boost::geometry::dsv;
// cout<<"INFO: \tGeometry polygon is:\t" << dsv(geoPoly[1])<<endl;
return geoPoly;
}
......@@ -488,7 +485,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
bool result_I = method_I.Process(data,_scriptsLocation, _areaForMethod_I[i]->_zPos);
if(result_I)
{
Log->Write("INFO:\tSuccess with Method I uing measurement area id %d!\n",_areaForMethod_I[i]->_id);
Log->Write("INFO:\tSuccess with Method I using measurement area id %d!\n",_areaForMethod_I[i]->_id);
std::cout << "INFO:\tSuccess with Method I using measurement area id "<< _areaForMethod_I[i]->_id << "\n";
if(_plotTimeseriesI[i])
{
......
This diff is collapsed.
......@@ -49,11 +49,39 @@ VoronoiDiagram::~VoronoiDiagram()
std::vector<std::pair<polygon_2d, int> > VoronoiDiagram::getVoronoiPolygons(vector<double>& XInFrame, vector<double>& YInFrame,
vector<double>& VInFrame, vector<int>& IdInFrame, const double Bound_Max)
{
const int numPedsInFrame = IdInFrame.size();
int numPedsInFrame = IdInFrame.size();
vector<int> XInFrame_temp;
vector<int> YInFrame_temp;
vector<double> VInFrame_temp;
vector<int> IdInFrame_temp;
// in case 1 or 2 pedestrians are in the geometry
// add dummy pedestrians around to enable voronoi calculations
// @todo: maybe use negative ids for these dummy pedestrians to exclude
// them from any analysis.
if(numPedsInFrame == 1 || numPedsInFrame == 2)
{
numPedsInFrame += 4;
// up right
XInFrame.push_back(XInFrame[0]+10);
YInFrame.push_back(YInFrame[0]+10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+1);
// up left
XInFrame.push_back(XInFrame[0]-10);
YInFrame.push_back(YInFrame[0]+10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+2);
// down right
XInFrame.push_back(XInFrame[0]+10);
YInFrame.push_back(YInFrame[0]-10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+3);
// down left
XInFrame.push_back(XInFrame[0]-10);
YInFrame.push_back(YInFrame[0]-10);
VInFrame.push_back(VInFrame[0]);
IdInFrame.push_back(IdInFrame[0]+4);
}
for (int i = 0; i < numPedsInFrame; i++)
{
......@@ -64,6 +92,7 @@ std::vector<std::pair<polygon_2d, int> > VoronoiDiagram::getVoronoiPolygons(vect
IdInFrame_temp.push_back(IdInFrame[i]);
}
VD voronoidiagram;
construct_voronoi(points.begin(), points.end(), &voronoidiagram);
int Ncell = 0;
......
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