Commit cb7fd2f2 authored by Gregor Jaeger's avatar Gregor Jaeger

solution for issue 108, modification for issue 105 (Method I) and issue 88 (Method D)

parent 9edacfef
Pipeline #21612 passed with stages
in 34 seconds
......@@ -166,7 +166,8 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodD = args->GetStopFramesMethodD();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesD=args->GetIsPlotTimeSeriesD();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
_geoPolyMethodD = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_D);
}
if(args->GetIsMethodI()) {
_DoesUseMethodI = true;
......@@ -179,14 +180,19 @@ void Analysis::InitArgs(ArgumentParser* args)
_StopFramesMethodI = args->GetStopFramesMethodI();
_IndividualFDFlags = args->GetIndividualFDFlags();
_plotTimeseriesI=args->GetIsPlotTimeSeriesI();
_geoPoly = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
_geoPolyMethodI = ReadGeometry(args->GetGeometryFilename(), _areaForMethod_I);
}
if( _DoesUseMethodD && _DoesUseMethodI)
{
Log->Write("Warning:\t Using both method D and I is not safe!");
// because ReadGeomtry() may be called twice
}
// ToDo: obsolete ?
// if( _DoesUseMethodD && _DoesUseMethodI)
// {
// Log->Write("Warning:\t Using both method D and I is not safe!");
// // because ReadGeometry() may be called twice (line 169 and 182)
// // overwrite _geoPoly -> new value for each Method
// Log->Write("Info:\t Using both method D and I is safe! :-)");
// }
_deltaF = args->GetDelatT_Vins();
_cutByCircle = args->GetIsCutByCircle();
_getProfile = args->GetIsGetProfile();
......@@ -336,6 +342,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_A)
{
Log->Write("INFO:\tSuccess with Method A using measurement area id %d!\n",_areaForMethod_A[i]->_id);
std::cout << "INFO:\tSuccess with Method A using measurement area id "<< _areaForMethod_A[i]->_id << "\n";
}
else
{
......@@ -361,6 +368,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_B)
{
Log->Write("INFO:\tSuccess with Method B using measurement area id %d!\n",_areaForMethod_B[i]->_id);
std::cout << "INFO:\tSuccess with Method B using measurement area id "<< _areaForMethod_B[i]->_id << "\n";
}
else
{
......@@ -385,6 +393,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
if(result_C)
{
Log->Write("INFO:\tSuccess with Method C using measurement area id %d!\n",_areaForMethod_C[i]->_id);
std::cout << "INFO:\tSuccess with Method C using measurement area id "<< _areaForMethod_C[i]->_id << "\n";
if(_plotTimeseriesC[i])
{
string parameters_Timeseries=" " + _scriptsLocation.string()+
......@@ -417,7 +426,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_D.SetStartFrame(_StartFramesMethodD[i]);
method_D.SetStopFrame(_StopFramesMethodD[i]);
method_D.SetCalculateIndividualFD(_IndividualFDFlags[i]);
method_D.SetGeometryPolygon(_geoPoly[_areaForMethod_D[i]->_id]);
method_D.SetGeometryPolygon(_geoPolyMethodD[_areaForMethod_D[i]->_id]);
method_D.SetGeometryFileName(_geometryFileName);
method_D.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_D.SetGridSize(_grid_size_X, _grid_size_Y);
......@@ -470,7 +479,7 @@ int Analysis::RunAnalysis(const fs::path& filename, const fs::path& path)
method_I.SetStartFrame(_StartFramesMethodI[i]);
method_I.SetStopFrame(_StopFramesMethodI[i]);
method_I.SetCalculateIndividualFD(_IndividualFDFlags[i]);
method_I.SetGeometryPolygon(_geoPoly[_areaForMethod_I[i]->_id]);
method_I.SetGeometryPolygon(_geoPolyMethodI[_areaForMethod_I[i]->_id]);
method_I.SetGeometryFileName(_geometryFileName);
method_I.SetGeometryBoundaries(_lowVertexX, _lowVertexY, _highVertexX, _highVertexY);
method_I.SetGridSize(_grid_size_X, _grid_size_Y);
......
......@@ -111,7 +111,8 @@ private:
Building* _building;
//polygon_2d _geoPoly;
std::map<int, polygon_2d> _geoPoly;
std::map<int, polygon_2d> _geoPolyMethodD;
std::map<int, polygon_2d> _geoPolyMethodI;
double _grid_size_X; // the size of the grid
double _grid_size_Y;
......
......@@ -140,6 +140,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
vector<int> IdInFrame = peddata.GetIdInFrame(frameNr, ids, zPos_measureArea);
vector<double> XInFrame = peddata.GetXInFrame(frameNr, ids, zPos_measureArea);
vector<double> YInFrame = peddata.GetYInFrame(frameNr, ids, zPos_measureArea);
vector<double> ZInFrame = peddata.GetZInFrame(frameNr, ids, zPos_measureArea);
vector<double> VInFrame = peddata.GetVInFrame(frameNr, ids, zPos_measureArea);
//vector int to_remove
//------------------------------Remove peds outside geometry------------------------------------------
......@@ -151,6 +152,7 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
IdInFrame.erase(IdInFrame.begin() + i);
XInFrame.erase(XInFrame.begin() + i);
YInFrame.erase(YInFrame.begin() + i);
ZInFrame.erase(ZInFrame.begin() + i);
VInFrame.erase(VInFrame.begin() + i);
i--;
}
......@@ -189,7 +191,8 @@ bool Method_D::Process (const PedData& peddata,const fs::path& scriptsLocation,
{
if(!_isOneDimensional)
{
GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid); // TODO polygons_id
// GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid); // TODO polygons_id
GetIndividualFD(polygons,VInFrame, IdInFrame, _areaForMethod_D->_poly, str_frid, XInFrame, YInFrame, ZInFrame);
}
}
if(_getProfile)
......@@ -257,7 +260,7 @@ bool Method_D::OpenFileIndividualFD()
{
fs::path trajFileName("_id_"+_measureAreaId+".dat");
fs::path indFDPath("Fundamental_Diagram");
indFDPath = _outputLocation / indFDPath / "IndividualFD" / (_trajName.string() + trajFileName.string());
indFDPath = _outputLocation / indFDPath / "IndividualFD" / ("IFD_D_" +_trajName.string() + trajFileName.string());
string Individualfundment=indFDPath.string();
if((_fIndividualFD=Analysis::CreateFile(Individualfundment))==nullptr)
{
......@@ -268,11 +271,11 @@ bool Method_D::OpenFileIndividualFD()
{
if(_isOneDimensional)
{
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PedId \t Individual density(m^(-1)) \t Individual velocity(m/s) \t Headway(m)\n",_fps);
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tIndividual density(m^(-1))\tIndividual velocity(m/s)\tHeadway(m)\n",_fps);
}
else
{
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PedId \t Individual density(m^(-2)) \t Individual velocity(m/s) \t Voronoi Polygon \t Intersection Polygon\n",_fps);
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tx/m\ty/m\tz/m\tIndividual density(m^(-2))\tIndividual velocity(m/s)\tVoronoi Polygon\tIntersection Polygon\n",_fps);
}
return true;
}
......@@ -561,10 +564,11 @@ void Method_D::OutputVoroGraph(const string & frameId, std::vector<std::pair<po
return polygon_str;
}*/
void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid)
void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const polygon_2d& measureArea, const string& frid, vector<double>& XInFrame, vector<double>& YInFrame, vector<double>& ZInFrame)
{
double uniquedensity=0;
double uniquevelocity=0;
double x, y, z;
int uniqueId=0;
int temp=0;
for (const auto & polygon_iterator:polygon)
......@@ -581,9 +585,15 @@ void Method_D::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
uniquedensity=1.0/(area(polygon_iterator)*CMtoM*CMtoM);
uniquevelocity=Velocity[temp];
uniqueId=Id[temp];
fprintf(_fIndividualFD,"%s\t%d\t%.3f\t%.3f\t%s\t%s\n",
x = XInFrame[temp]*CMtoM;
y = YInFrame[temp]*CMtoM;
z = ZInFrame[temp]*CMtoM;
fprintf(_fIndividualFD,"%s\t %d\t %.4f\t %.4f\t %.4f\t %.4f\t %.4f\t%s\t%s\n",
frid.c_str(),
uniqueId,
x,
y,
z,
uniquedensity,
uniquevelocity,
polygon_str.c_str(),
......
......@@ -103,7 +103,7 @@ private:
std::tuple<double,double> GetVoronoiDensityVelocity(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const polygon_2d & measureArea);
void GetProfiles(const std::string& frameId, const std::vector<polygon_2d>& polygons, const std::vector<double>& velocity);
void OutputVoroGraph(const std::string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons, int numPedsInFrame,const std::vector<double>& VInFrame);
void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const polygon_2d& measureArea, const std::string& frid);
void GetIndividualFD(const std::vector<polygon_2d>& polygon, const std::vector<double>& Velocity, const std::vector<int>& Id, const polygon_2d& measureArea, const std::string& frid, std::vector<double>& XInFrame, std::vector<double>& YInFrame, std::vector<double>& ZInFrame);
/**
* Reduce the precision of the points to two digits
* @param polygon
......
......@@ -199,10 +199,12 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
GetIndividualFD(polygons,VInFrame, IdInFrame, str_frid, XInFrame, YInFrame, ZInFrame); //
}
}
// ToDo: is obsolete
// if(_getProfile)
// { // field analysis
// GetProfiles(str_frid, polygons, VInFrame); // TODO polygons_id
// }
// ToDo: is obsolete
// if(_outputVoronoiCellData)
// { // output the Voronoi polygons of a frame
// OutputVoroGraph(str_frid, polygons_id, NumPeds,VInFrame);
......@@ -225,13 +227,15 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
return return_value;
}
// ToDo: this function OpenFileMethodI is obsolete - can be deleted
// bool Method_I::OpenFileMethodI()
// {
//
// std::string voroLocation(VORO_LOCATION);
// fs::path tmp("_id_"+_measureAreaId+".dat");
// tmp = _outputLocation / voroLocation / ("rho_v_Voronoi_" + _trajName.string() + tmp.string());
//// _outputLocation.string() + voroLocation+"rho_v_Voronoi_"+_trajName+"_id_"+_measureAreaId+".dat";
// // _outputLocation.string() + voroLocation+"rho_v_Voronoi_"+_trajName+"_id_"+_measureAreaId+".dat";
// string results_V= tmp.string();
//
//
......@@ -254,11 +258,13 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
// }
// }
bool Method_I::OpenFileIndividualFD()
{
fs::path trajFileName("_id_"+_measureAreaId+".dat");
fs::path indFDPath("Fundamental_Diagram");
indFDPath = _outputLocation / indFDPath / "IndividualFD" / (_trajName.string() + trajFileName.string());
indFDPath = _outputLocation / indFDPath / "IndividualFD" / ("IFD_I_" +_trajName.string() + trajFileName.string());
string Individualfundment=indFDPath.string();
if((_fIndividualFD=Analysis::CreateFile(Individualfundment))==nullptr)
{
......@@ -269,11 +275,11 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
{
if(_isOneDimensional)
{
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PersID \t Individual density(m^(-1)) \t Individual velocity(m/s) \t Headway(m)\n",_fps);
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tIndividual density(m^(-1))\tIndividual velocity(m/s)\tHeadway(m)\n",_fps);
}
else
{
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame \t PersID \t x/m \t y/m \t z/m \t Individual density(m^(-2)) \t Individual velocity(m/s) \t Voronoi Polygon\n",_fps);
fprintf(_fIndividualFD,"#framerate (fps):\t%.2f\n\n#Frame\tPersID\tx/m\ty/m\tz/m\tIndividual density(m^(-2))\tIndividual velocity(m/s)\tVoronoi Polygon\n",_fps);
}
return true;
}
......@@ -294,19 +300,22 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
//todo HH
polygons_id = vd.cutPolygonsWithGeometry(polygons_id, _geoPoly, XInFrame, YInFrame);
// todo HH
// std:: cout << dsv(_geoPoly) << "\n";
// std:: cout << dsv(_geoPoly) << "\n"; // ToDo: obsolete ?
for(auto && p:polygons_id)
{
poly = p.first;
ReducePrecision(poly);
// TODO update polygon_id?
}
// std:: cout << " GetPolygons leave " << polygons_id.size() << "\n";
// std:: cout << " GetPolygons leave " << polygons_id.size() << "\n"; // ToDo: obsolete ?
return polygons_id;
}
/**
* Output the Voronoi density and velocity in the corresponding file
*/
// ToDo: this function OutputVoronoiResults is obsolete - can be deleted
// void Method_I::OutputVoronoiResults(const vector<polygon_2d>& polygons, const string& frid, const vector<double>& VInFrame)
// {
// double VoronoiVelocity=1;
......@@ -320,34 +329,39 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
* input: voronoi cell and velocity of each pedestrian and the measurement area
* output: the voronoi density and velocity in the measurement area (tuple)
*/
std::tuple<double,double> Method_I::GetVoronoiDensityVelocity(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const polygon_2d & measureArea)
{
double meanV=0;
double density=0;
int temp=0;
for (auto && polygon_iterator:polygon)
{
polygon_list v;
intersection(measureArea, polygon_iterator, v);
if(!v.empty())
{
meanV+=Velocity[temp]*area(v[0]);
density+=area(v[0])/area(polygon_iterator);
if((area(v[0]) - area(polygon_iterator))>J_EPS)
{
std::cout<<"----------------------Now calculating density-velocity!!!-----------------\n ";
std::cout<<"measure area: \t"<<std::setprecision(16)<<dsv(measureArea)<<"\n";
std::cout<<"Original polygon:\t"<<std::setprecision(16)<<dsv(polygon_iterator)<<"\n";
std::cout<<"intersected polygon: \t"<<std::setprecision(16)<<dsv(v[0])<<"\n";
std::cout<<"this is a wrong result in density calculation\t "<<area(v[0])<<'\t'<<area(polygon_iterator)<< " (diff=" << (area(v[0]) - area(polygon_iterator)) << ")" << "\n";
}
}
temp++;
}
meanV = meanV/area(measureArea);
density = density/(area(measureArea)*CMtoM*CMtoM);
return std::make_tuple(density, meanV);
}
// ToDo: this function GetVoronoiDensityVelocity obsolete - can be deleted
// std::tuple<double,double> Method_I::GetVoronoiDensityVelocity(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const polygon_2d & measureArea)
// {
// double meanV=0;
// double density=0;
// int temp=0;
// for (auto && polygon_iterator:polygon)
// {
// polygon_list v;
// intersection(measureArea, polygon_iterator, v);
// if(!v.empty())
// {
// meanV+=Velocity[temp]*area(v[0]);
// density+=area(v[0])/area(polygon_iterator);
// if((area(v[0]) - area(polygon_iterator))>J_EPS)
// {
// std::cout<<"----------------------Now calculating density-velocity!!!-----------------\n ";
// std::cout<<"measure area: \t"<<std::setprecision(16)<<dsv(measureArea)<<"\n";
// std::cout<<"Original polygon:\t"<<std::setprecision(16)<<dsv(polygon_iterator)<<"\n";
// std::cout<<"intersected polygon: \t"<<std::setprecision(16)<<dsv(v[0])<<"\n";
// std::cout<<"this is a wrong result in density calculation\t "<<area(v[0])<<'\t'<<area(polygon_iterator)<< " (diff=" << (area(v[0]) - area(polygon_iterator)) << ")" << "\n";
// }
// }
// temp++;
// }
// meanV = meanV/area(measureArea);
// density = density/(area(measureArea)*CMtoM*CMtoM);
// return std::make_tuple(density, meanV);
// }
// ToDo: this function GetProfiles is obsolete - can be deleted
// and velocity is calculated for every frame
// void Method_I::GetProfiles(const string& frameId, const vector<polygon_2d>& polygons, const vector<double>& velocity)
// {
......@@ -404,136 +418,135 @@ bool Method_I::Process(const PedData& peddata,const fs::path& scriptsLocation, c
// fclose(Prf_density);
// }
// ToDo Wird nicht benötigt
/*
void Method_I::OutputVoroGraph(const string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons_id, int numPedsInFrame,const vector<double>& VInFrame)
{
//string voronoiLocation=_projectRootDir+"./Output/Fundamental_Diagram/Classical_Voronoi/VoronoiCell/id_"+_measureAreaId;
fs::path voroLocPath(_outputLocation);
fs::path voro_location_path (VORO_LOCATION); // TODO: convert
// this MACRO to
// path. Maybe
// remove the MACRO?
voroLocPath = voroLocPath / voro_location_path / "VoronoiCell";
polygon_2d poly;
if(!fs::exists(voroLocPath))
{
if(!fs::create_directories(voroLocPath))
{
Log->Write("ERROR:\tcan not create directory <%s>", voroLocPath.string().c_str());
std::cout << "can not create directory "<< voroLocPath.string().c_str() << "\n";
exit(EXIT_FAILURE);
}
else
std::cout << "create directory "<< voroLocPath.string().c_str() << "\n";
}
// ToDo: this function OutputVoroGraph is obsolete - can be deleted
fs::path polygonPath=voroLocPath / "polygon";
if(!fs::exists(polygonPath))
{
if(!fs::create_directory(polygonPath))
{
Log->Write("ERROR:\tcan not create directory <%s>", polygonPath.string().c_str());
exit(EXIT_FAILURE);
}
}
fs::path trajFileName(_trajName.string()+"_id_"+_measureAreaId+"_"+frameId+".dat");
fs::path p = polygonPath / trajFileName;
string polygon = p.string();
ofstream polys (polygon.c_str());
// void Method_I::OutputVoroGraph(const string & frameId, std::vector<std::pair<polygon_2d, int> >& polygons_id, int numPedsInFrame,const vector<double>& VInFrame)
// {
// //string voronoiLocation=_projectRootDir+"./Output/Fundamental_Diagram/Classical_Voronoi/VoronoiCell/id_"+_measureAreaId;
//
// fs::path voroLocPath(_outputLocation);
// fs::path voro_location_path (VORO_LOCATION); //
// // this MACRO to
// // path. Maybe
// // remove the MACRO?
// voroLocPath = voroLocPath / voro_location_path / "VoronoiCell";
// polygon_2d poly;
// if(!fs::exists(voroLocPath))
// {
// if(!fs::create_directories(voroLocPath))
// {
// Log->Write("ERROR:\tcan not create directory <%s>", voroLocPath.string().c_str());
// std::cout << "can not create directory "<< voroLocPath.string().c_str() << "\n";
// exit(EXIT_FAILURE);
// }
// else
// std::cout << "create directory "<< voroLocPath.string().c_str() << "\n";
// }
//
// fs::path polygonPath=voroLocPath / "polygon";
// if(!fs::exists(polygonPath))
// {
// if(!fs::create_directory(polygonPath))
// {
// Log->Write("ERROR:\tcan not create directory <%s>", polygonPath.string().c_str());
// exit(EXIT_FAILURE);
// }
// }
// fs::path trajFileName(_trajName.string()+"_id_"+_measureAreaId+"_"+frameId+".dat");
// fs::path p = polygonPath / trajFileName;
// string polygon = p.string();
// ofstream polys (polygon.c_str());
//
// if(polys.is_open())
// {
// //for(vector<polygon_2d> polygon_iterator=polygons.begin(); polygon_iterator!=polygons.end(); polygon_iterator++)
// for(auto && polygon_id:polygons_id)
// {
// poly = polygon_id.first;
// for(auto&& point:poly.outer())
// {
// point.x(point.x()*CMtoM);
// point.y(point.y()*CMtoM);
// }
// for(auto&& innerpoly:poly.inners())
// {
// for(auto&& point:innerpoly)
// {
// point.x(point.x()*CMtoM);
// point.y(point.y()*CMtoM);
// }
// }
// polys << polygon_id.second << " | " << dsv(poly) << endl;
// //polys <<dsv(poly)<< endl;
// }
// }
// else
// {
// Log->Write("ERROR:\tcannot create the file <%s>",polygon.c_str());
// exit(EXIT_FAILURE);
// }
// fs::path speedPath=voroLocPath / "speed";
// if(!fs::exists(speedPath))
// if(!fs::create_directory(speedPath))
// {
// Log->Write("ERROR:\tcan not create directory <%s>", speedPath.string().c_str());
// exit(EXIT_FAILURE);
// }
// fs::path pv = speedPath /trajFileName;
// string v_individual= pv.string();
// ofstream velo (v_individual.c_str());
// if(velo.is_open())
// {
// for(int pts=0; pts<numPedsInFrame; pts++)
// {
// velo << fabs(VInFrame[pts]) << endl;
// }
// }
// else
// {
// Log->Write("ERROR:\tcannot create the file <%s>",pv.string().c_str());
// exit(EXIT_FAILURE);
// }
//
// *//*string point=voronoiLocation+"/points"+_trajName+"_id_"+_measureAreaId+"_"+frameId+".dat";
// ofstream points (point.c_str());
// if( points.is_open())
// {
// for(int pts=0; pts<numPedsInFrame; pts++)
// {
// points << XInFrame[pts]*CMtoM << "\t" << YInFrame[pts]*CMtoM << endl;
// }
// }
// else
// {
// Log->Write("ERROR:\tcannot create the file <%s>",point.c_str());
// exit(EXIT_FAILURE);
// }
//
// if(_plotVoronoiCellData)
// {
// string parameters_rho=" " + _scriptsLocation.string()+"/_Plot_cell_rho.py -f \""+ voroLocPath.string() + "\" -n "+ _trajName.string()+"_id_"+_measureAreaId+"_"+frameId+
// " -g "+_geometryFileName.string()+" -p "+_trajectoryPath.string();
// string parameters_v=" " + _scriptsLocation.string()+"/_Plot_cell_v.py -f \""+ voroLocPath.string() + "\" -n "+ _trajName.string() + "_id_"+_measureAreaId+"_"+frameId+
// " -g "+_geometryFileName.string()+" -p "+_trajectoryPath.string();
//
// if(_plotVoronoiIndex)
// parameters_rho += " -i";
//
// Log->Write("INFO:\t%s",parameters_rho.c_str());
// Log->Write("INFO:\tPlotting Voronoi Cell at the frame <%s>",frameId.c_str());
// parameters_rho = PYTHON + parameters_rho;
// parameters_v = PYTHON + parameters_v;
// system(parameters_rho.c_str());
// system(parameters_v.c_str());
// }
// //points.close();
// polys.close();
// velo.close();
// }
if(polys.is_open())
{
//for(vector<polygon_2d> polygon_iterator=polygons.begin(); polygon_iterator!=polygons.end(); polygon_iterator++)
for(auto && polygon_id:polygons_id)
{
poly = polygon_id.first;
for(auto&& point:poly.outer())
{
point.x(point.x()*CMtoM);
point.y(point.y()*CMtoM);
}
for(auto&& innerpoly:poly.inners())
{
for(auto&& point:innerpoly)
{
point.x(point.x()*CMtoM);
point.y(point.y()*CMtoM);
}
}
polys << polygon_id.second << " | " << dsv(poly) << endl;
//polys <<dsv(poly)<< endl;
}
}
else
{
Log->Write("ERROR:\tcannot create the file <%s>",polygon.c_str());
exit(EXIT_FAILURE);
}
fs::path speedPath=voroLocPath / "speed";
if(!fs::exists(speedPath))
if(!fs::create_directory(speedPath))
{
Log->Write("ERROR:\tcan not create directory <%s>", speedPath.string().c_str());
exit(EXIT_FAILURE);
}
fs::path pv = speedPath /trajFileName;
string v_individual= pv.string();
ofstream velo (v_individual.c_str());
if(velo.is_open())
{
for(int pts=0; pts<numPedsInFrame; pts++)
{
velo << fabs(VInFrame[pts]) << endl;
}
}
else
{
Log->Write("ERROR:\tcannot create the file <%s>",pv.string().c_str());
exit(EXIT_FAILURE);
}
*//*string point=voronoiLocation+"/points"+_trajName+"_id_"+_measureAreaId+"_"+frameId+".dat";
ofstream points (point.c_str());
if( points.is_open())
{
for(int pts=0; pts<numPedsInFrame; pts++)
{
points << XInFrame[pts]*CMtoM << "\t" << YInFrame[pts]*CMtoM << endl;
}
}
else
{
Log->Write("ERROR:\tcannot create the file <%s>",point.c_str());
exit(EXIT_FAILURE);
}
// ToDo: _plotVoronoiCellData wird nicht benötigt
if(_plotVoronoiCellData)
{
//@todo: use fs::path
string parameters_rho=" " + _scriptsLocation.string()+"/_Plot_cell_rho.py -f \""+ voroLocPath.string() + "\" -n "+ _trajName.string()+"_id_"+_measureAreaId+"_"+frameId+
" -g "+_geometryFileName.string()+" -p "+_trajectoryPath.string();
string parameters_v=" " + _scriptsLocation.string()+"/_Plot_cell_v.py -f \""+ voroLocPath.string() + "\" -n "+ _trajName.string() + "_id_"+_measureAreaId+"_"+frameId+
" -g "+_geometryFileName.string()+" -p "+_trajectoryPath.string();
if(_plotVoronoiIndex)
parameters_rho += " -i";
Log->Write("INFO:\t%s",parameters_rho.c_str());
Log->Write("INFO:\tPlotting Voronoi Cell at the frame <%s>",frameId.c_str());
parameters_rho = PYTHON + parameters_rho;
parameters_v = PYTHON + parameters_v;
system(parameters_rho.c_str());
system(parameters_v.c_str());
}
//points.close();
polys.close();
velo.close();
}
*/
// ToDo: this function GetIndividualFD is obsolete - can be deleted
// void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<double>& Velocity, const vector<int>& Id, const string& frid)
// {
......@@ -639,6 +652,9 @@ void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
_grid_size_Y = y;
}
// ToDo: obsolete ?
// void Method_I::SetCalculateProfiles(bool calcProfile)
// {
// _getProfile = false ;
......@@ -649,12 +665,12 @@ void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
_outputVoronoiCellData = outputCellData;
}
// ToDo wird nicht benötigt
/* void Method_I::SetPlotVoronoiGraph(bool plotVoronoiGraph)
*{
* _plotVoronoiCellData = plotVoronoiGraph;
* }
*/
// ToDo: obsolete ?
// void Method_I::SetPlotVoronoiGraph(bool plotVoronoiGraph)
// {
// _plotVoronoiCellData = plotVoronoiGraph;
// }
void Method_I::SetPlotVoronoiIndex(bool plotVoronoiIndex)
{
_plotVoronoiIndex = plotVoronoiIndex;
......@@ -679,6 +695,8 @@ void Method_I::GetIndividualFD(const vector<polygon_2d>& polygon, const vector<d
}
}
// ToDo: obsolete ?
// bool Method_I::IsPedInGeometry(int frames, int peds, double **Xcor, double **Ycor, int *firstFrame, int *lastFrame)
// {
// for(int i=0; i<peds; i++)
......
......@@ -51,9 +51,9 @@ public:
void SetGeometryFileName(const fs::path& geometryFile);
void SetGeometryBoundaries(double minX, double minY, double maxX, double maxY);
void SetGridSize(double x, double y);
void SetCalculateProfiles(bool calcProfile);
void SetCalculateProfiles(bool calcProfile); // ToDo: obsolete ?
void SetOutputVoronoiCellData(bool outputCellData);
void SetPlotVoronoiGraph(bool plotVoronoiGraph);
void SetPlotVoronoiGraph(bool plotVoronoiGraph); // ToDo: obsolete ?
void SetPlotVoronoiIndex(bool plotVoronoiIndex);
void SetMeasurementArea (MeasurementArea_B* area);
void SetDimensional (bool dimension);
......@@ -70,11 +70,11 @@ private:
fs::path _outputLocation;
fs::path _scriptsLocation;
bool _calcIndividualFD;
polygon_2d _areaIndividualFD;
bool _getProfile;
bool _outputVoronoiCellData;
bool _plotVoronoiCellData;
bool _plotVoronoiIndex;
polygon_2d _areaIndividualFD; // ToDo: obsolete ?
bool _getProfile; // ToDo: obsolete ?