Commit 6d261c0e authored by Ulrich Kemloh's avatar Ulrich Kemloh

Version 0.6 and minor formating.

parent 6af96ae6
...@@ -89,53 +89,53 @@ void OutputHandler::ProgressBar(double TotalPeds, double NowPeds) ...@@ -89,53 +89,53 @@ void OutputHandler::ProgressBar(double TotalPeds, double NowPeds)
} }
void OutputHandler::Write(const char* message,...) void OutputHandler::Write(const char* message,...)
{ {
char msg[CLENGTH]=""; char msg[CLENGTH]="";
va_list ap; va_list ap;
va_start(ap, message); va_start(ap, message);
vsprintf(msg, message, ap); vsprintf(msg, message, ap);
va_end(ap); va_end(ap);
string str(msg); string str(msg);
if (str.find("ERROR") != string::npos) if (str.find("ERROR") != string::npos)
{ {
cerr << msg << endl; cerr << msg << endl;
cerr.flush(); cerr.flush();
incrementErrors(); incrementErrors();
} }
else if (str.find("WARNING") != string::npos) else if (str.find("WARNING") != string::npos)
{ {
cerr << msg << endl; cerr << msg << endl;
cerr.flush(); cerr.flush();
incrementWarnings(); incrementWarnings();
} }
else else
{ // infos { // infos
cout << msg << endl; cout << msg << endl;
cout.flush(); cout.flush();
} }
} }
void STDIOHandler::Write(const string& str) void STDIOHandler::Write(const string& str)
{ {
if (str.find("ERROR") != string::npos) if (str.find("ERROR") != string::npos)
{ {
cerr << str << endl; cerr << str << endl;
cerr.flush(); cerr.flush();
incrementErrors(); incrementErrors();
} }
else if (str.find("WARNING") != string::npos) else if (str.find("WARNING") != string::npos)
{ {
cerr << str << endl; cerr << str << endl;
cerr.flush(); cerr.flush();
incrementWarnings(); incrementWarnings();
} }
else else
{ // infos { // infos
cout << str << endl; cout << str << endl;
cout.flush(); cout.flush();
} }
} }
FileHandler::FileHandler(const char *fn) FileHandler::FileHandler(const char *fn)
...@@ -156,19 +156,19 @@ FileHandler::~FileHandler() ...@@ -156,19 +156,19 @@ FileHandler::~FileHandler()
void FileHandler::Write(const string& str) void FileHandler::Write(const string& str)
{ {
if (this != NULL) { if (this != NULL) {
_pfp << str << endl; _pfp << str << endl;
_pfp.flush(); _pfp.flush();
} }
if (str.find("ERROR") != string::npos) if (str.find("ERROR") != string::npos)
{ {
incrementErrors(); incrementErrors();
} }
else if (str.find("WARNING") != string::npos) else if (str.find("WARNING") != string::npos)
{ {
incrementWarnings(); incrementWarnings();
} }
} }
void FileHandler::Write(const char* str_msg,...) void FileHandler::Write(const char* str_msg,...)
...@@ -184,11 +184,11 @@ void FileHandler::Write(const char* str_msg,...) ...@@ -184,11 +184,11 @@ void FileHandler::Write(const char* str_msg,...)
string str(msg); string str(msg);
if (str.find("ERROR") != string::npos) if (str.find("ERROR") != string::npos)
{ {
incrementErrors(); incrementErrors();
} }
else if (str.find("WARNING") != string::npos) else if (str.find("WARNING") != string::npos)
{ {
incrementWarnings(); incrementWarnings();
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* *
* *
**/ **/
#ifndef OUTPUT_HANDLER_H_ #ifndef OUTPUT_HANDLER_H_
#define OUTPUT_HANDLER_H_ #define OUTPUT_HANDLER_H_
......
...@@ -129,7 +129,7 @@ ArgumentParser::ArgumentParser() ...@@ -129,7 +129,7 @@ ArgumentParser::ArgumentParser()
bool ArgumentParser::ParseArgs(int argc, char **argv) bool ArgumentParser::ParseArgs(int argc, char **argv)
{ {
//special case of the default configuration ini.xml //special case of the default configuration ini.xml
if (argc == 1) if (argc == 1)
...@@ -241,8 +241,8 @@ bool ArgumentParser::ParseIniFile(const string& inifile) ...@@ -241,8 +241,8 @@ bool ArgumentParser::ParseIniFile(const string& inifile)
} }
else else
{ {
Log->Write("Error: \tthe given trajectory format is not supported. Supply '.xml' or '.txt' format!"); Log->Write("Error: \tthe given trajectory format is not supported. Supply '.xml' or '.txt' format!");
return false; return false;
} }
string unit = xmltoa(xMainNode->FirstChildElement("trajectories")->Attribute("unit"), "m"); string unit = xmltoa(xMainNode->FirstChildElement("trajectories")->Attribute("unit"), "m");
...@@ -283,9 +283,9 @@ bool ArgumentParser::ParseIniFile(const string& inifile) ...@@ -283,9 +283,9 @@ bool ArgumentParser::ParseIniFile(const string& inifile)
// ignore the project root in this case // ignore the project root in this case
if ( (boost::algorithm::contains(_trajectoriesLocation,":")==false) && //windows if ( (boost::algorithm::contains(_trajectoriesLocation,":")==false) && //windows
(boost::algorithm::starts_with(_trajectoriesLocation,"/") ==false)) //linux (boost::algorithm::starts_with(_trajectoriesLocation,"/") ==false)) //linux
// &&() osx // &&() osx
{ {
_trajectoriesLocation=_projectRootDir+_trajectoriesLocation; _trajectoriesLocation=_projectRootDir+_trajectoriesLocation;
} }
// in the case no file was specified, collect all xml files in the specified directory // in the case no file was specified, collect all xml files in the specified directory
...@@ -302,11 +302,11 @@ bool ArgumentParser::ParseIniFile(const string& inifile) ...@@ -302,11 +302,11 @@ bool ArgumentParser::ParseIniFile(const string& inifile)
if (boost::algorithm::ends_with(filename, fmt)) if (boost::algorithm::ends_with(filename, fmt))
//if (filename.find(fmt)!=std::string::npos) //if (filename.find(fmt)!=std::string::npos)
{ {
//_trajectoriesFiles.push_back(_projectRootDir+filename); //_trajectoriesFiles.push_back(_projectRootDir+filename);
_trajectoriesFiles.push_back(filename); _trajectoriesFiles.push_back(filename);
Log->Write("INFO: \tInput trajectory file is\t<"+ (filename)+">"); Log->Write("INFO: \tInput trajectory file is\t<"+ (filename)+">");
} }
} }
closedir (dir); closedir (dir);
} }
...@@ -417,10 +417,10 @@ bool ArgumentParser::ParseIniFile(const string& inifile) ...@@ -417,10 +417,10 @@ bool ArgumentParser::ParseIniFile(const string& inifile)
_timeIntervalA = xmltoi(xMethod_A->FirstChildElement("timeInterval")->GetText()); _timeIntervalA = xmltoi(xMethod_A->FirstChildElement("timeInterval")->GetText());
Log->Write("INFO: \ttime interval used in Method A is <%d> frame",_timeIntervalA); Log->Write("INFO: \ttime interval used in Method A is <%d> frame",_timeIntervalA);
for(TiXmlElement* xMeasurementArea=xMainNode->FirstChildElement("method_A")->FirstChildElement("measurementArea"); for(TiXmlElement* xMeasurementArea=xMainNode->FirstChildElement("method_A")->FirstChildElement("measurementArea");
xMeasurementArea; xMeasurementArea = xMeasurementArea->NextSiblingElement("measurementArea")) xMeasurementArea; xMeasurementArea = xMeasurementArea->NextSiblingElement("measurementArea"))
{ {
_areaIDforMethodA.push_back(xmltoi(xMeasurementArea->Attribute("id"))); _areaIDforMethodA.push_back(xmltoi(xMeasurementArea->Attribute("id")));
Log->Write("INFO: \tMeasurement area id <%d> will be used for analysis", xmltoi(xMeasurementArea->Attribute("id"))); Log->Write("INFO: \tMeasurement area id <%d> will be used for analysis", xmltoi(xMeasurementArea->Attribute("id")));
} }
} }
} }
......
...@@ -48,90 +48,90 @@ extern OutputHandler* Log; ...@@ -48,90 +48,90 @@ extern OutputHandler* Log;
class ArgumentParser { class ArgumentParser {
private: private:
std::string _geometryFileName; std::string _geometryFileName;
std::string _errorLogFile; std::string _errorLogFile;
std::string _trajectoriesLocation; std::string _trajectoriesLocation;
std::string _trajectoriesFilename; std::string _trajectoriesFilename;
std::string _projectRootDir; std::string _projectRootDir;
FileFormat _fileFormat; FileFormat _fileFormat;
std::vector<std::string> _trajectoriesFiles; std::vector<std::string> _trajectoriesFiles;
char _vComponent; char _vComponent;
bool _isMethodA; bool _isMethodA;
bool _isMethodB; bool _isMethodB;
bool _isMethodC; bool _isMethodC;
bool _isMethodD; bool _isMethodD;
bool _isCutByCircle; bool _isCutByCircle;
double _cutRadius; double _cutRadius;
int _circleEdges; int _circleEdges;
bool _isOutputGraph; bool _isOutputGraph;
bool _isIndividualFD; bool _isIndividualFD;
bool _isGetProfile; bool _isGetProfile;
double _steadyStart; double _steadyStart;
double _steadyEnd; double _steadyEnd;
int _delatTVInst; int _delatTVInst;
int _timeIntervalA; int _timeIntervalA;
std::vector<int> _areaIDforMethodA; std::vector<int> _areaIDforMethodA;
std::vector<int> _areaIDforMethodB; std::vector<int> _areaIDforMethodB;
std::vector<int> _areaIDforMethodC; std::vector<int> _areaIDforMethodC;
std::vector<int> _areaIDforMethodD; std::vector<int> _areaIDforMethodD;
float _scaleX; float _scaleX;
float _scaleY; float _scaleY;
int _log; int _log;
std::map <int, MeasurementArea*> _measurementAreas; std::map <int, MeasurementArea*> _measurementAreas;
void Usage(const std::string file); void Usage(const std::string file);
public: public:
// Konstruktor // Konstruktor
ArgumentParser(); ArgumentParser();
const std::string& GetTrajectoriesFilename() const; const std::string& GetTrajectoriesFilename() const;
const std::vector<std::string>& GetTrajectoriesFiles() const; const std::vector<std::string>& GetTrajectoriesFiles() const;
const std::string& GetTrajectoriesLocation() const; const std::string& GetTrajectoriesLocation() const;
const FileFormat& GetFileFormat() const; const FileFormat& GetFileFormat() const;
const std::string& GetGeometryFilename() const; const std::string& GetGeometryFilename() const;
const std::string& GetErrorLogFile() const; const std::string& GetErrorLogFile() const;
const std::string& GetProjectRootDir() const; const std::string& GetProjectRootDir() const;
double GetLengthMeasurementArea() const; double GetLengthMeasurementArea() const;
polygon_2d GetMeasureArea() const; polygon_2d GetMeasureArea() const;
double GetLineStartX() const; double GetLineStartX() const;
double GetLineStartY() const; double GetLineStartY() const;
double GetLineEndX() const; double GetLineEndX() const;
double GetLineEndY() const; double GetLineEndY() const;
char GetVComponent() const; char GetVComponent() const;
int GetDelatT_Vins() const; int GetDelatT_Vins() const;
int GetTimeIntervalA() const; int GetTimeIntervalA() const;
bool GetIsMethodA() const; bool GetIsMethodA() const;
bool GetIsMethodB() const; bool GetIsMethodB() const;
bool GetIsMethodC() const; bool GetIsMethodC() const;
bool GetIsMethodD() const; bool GetIsMethodD() const;
std::vector<int> GetAreaIDforMethodA() const; std::vector<int> GetAreaIDforMethodA() const;
std::vector<int> GetAreaIDforMethodB() const; std::vector<int> GetAreaIDforMethodB() const;
std::vector<int> GetAreaIDforMethodC() const; std::vector<int> GetAreaIDforMethodC() const;
std::vector<int> GetAreaIDforMethodD() const; std::vector<int> GetAreaIDforMethodD() const;
bool GetIsCutByCircle() const; bool GetIsCutByCircle() const;
double GetCutRadius() const; double GetCutRadius() const;
int GetCircleEdges() const; int GetCircleEdges() const;
bool GetIsOutputGraph() const; bool GetIsOutputGraph() const;
bool GetIsIndividualFD() const; bool GetIsIndividualFD() const;
double GetSteadyStart() const; double GetSteadyStart() const;
double GetSteadyEnd() const; double GetSteadyEnd() const;
bool GetIsGetProfile() const; bool GetIsGetProfile() const;
float GetScaleX() const; float GetScaleX() const;
float GetScaleY() const; float GetScaleY() const;
int GetLog() const; int GetLog() const;
bool ParseArgs(int argc, char **argv); bool ParseArgs(int argc, char **argv);
MeasurementArea* GetMeasurementArea(int id); MeasurementArea* GetMeasurementArea(int id);
/** /**
* parse the initialization file * parse the initialization file
* @param inifile * @param inifile
*/ */
bool ParseIniFile(const std::string& inifile); bool ParseIniFile(const std::string& inifile);
}; };
#endif /*ARGPARSER_H_*/ #endif /*ARGPARSER_H_*/
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* *
* *
**/ **/
#ifndef _MACROS_H #ifndef _MACROS_H
#define _MACROS_H #define _MACROS_H
...@@ -117,12 +117,12 @@ enum RoutingStrategy { ...@@ -117,12 +117,12 @@ enum RoutingStrategy {
}; };
enum OperativModels { enum OperativModels {
MODEL_GFCM=1, MODEL_GFCM=1,
MODEL_GOMPERTZ, MODEL_GOMPERTZ,
// MODEL_ORCA, // MODEL_ORCA,
// MODEL_CFM, // MODEL_CFM,
// MODEL_VELO // MODEL_VELO
// MODEL_GNM // MODEL_GNM
}; };
enum AgentColorMode { enum AgentColorMode {
...@@ -247,26 +247,26 @@ inline std::string concatenate(std::string const& name, int i) { ...@@ -247,26 +247,26 @@ inline std::string concatenate(std::string const& name, int i) {
inline void _printDebugLine(const std::string& fileName, int lineNumber) inline void _printDebugLine(const std::string& fileName, int lineNumber)
{ {
unsigned found = fileName.find_last_of("/\\"); unsigned found = fileName.find_last_of("/\\");
std::cerr << "["<< lineNumber << "]: ---"<< fileName.substr(found+1)<< " ---"<<std::endl; std::cerr << "["<< lineNumber << "]: ---"<< fileName.substr(found+1)<< " ---"<<std::endl;
} }
#define dtrace(...) \ #define dtrace(...) \
(_printDebugLine(__FILE__, __LINE__), \ (_printDebugLine(__FILE__, __LINE__), \
fprintf(stderr, __VA_ARGS__), \ fprintf(stderr, __VA_ARGS__), \
(void) fprintf(stderr, "\n")) (void) fprintf(stderr, "\n"))
#define derror(...) \ #define derror(...) \
(_printDebugLine(__FILE__, __LINE__), \ (_printDebugLine(__FILE__, __LINE__), \
fprintf(stderr, "ERROR: "), \ fprintf(stderr, "ERROR: "), \
fprintf(stderr, __VA_ARGS__) \ fprintf(stderr, __VA_ARGS__) \
) )
#else #else
#define dtrace(...) ((void) 0) #define dtrace(...) ((void) 0)
#define derror(...) \ #define derror(...) \
(fprintf(stderr, __VA_ARGS__) \ (fprintf(stderr, __VA_ARGS__) \
) )
#endif /* TRACE_LOGGING */ #endif /* TRACE_LOGGING */
#endif /* _MACROS_H */ #endif /* _MACROS_H */
...@@ -34,14 +34,14 @@ using std::vector; ...@@ -34,14 +34,14 @@ using std::vector;
Method_B::Method_B() Method_B::Method_B()
{ {
_xCor = NULL; _xCor = NULL;
_yCor = NULL; _yCor = NULL;
_tIn = NULL; _tIn = NULL;
_tOut = NULL; _tOut = NULL;
_DensityPerFrame = NULL; _DensityPerFrame = NULL;
_fps = 10; _fps = 10;
_NumPeds =0; _NumPeds =0;
_areaForMethod_B = NULL; _areaForMethod_B = NULL;
} }
Method_B::~Method_B() Method_B::~Method_B()
...@@ -51,100 +51,100 @@ Method_B::~Method_B() ...@@ -51,100 +51,100 @@ Method_B::~Method_B()
bool Method_B::Process (const PedData& peddata) bool Method_B::Process (const PedData& peddata)
{ {
_trajName = peddata.GetTrajName(); _trajName = peddata.GetTrajName();
_projectRootDir = peddata.GetProjectRootDir(); _projectRootDir = peddata.GetProjectRootDir();
_fps =peddata.GetFps(); _fps =peddata.GetFps();
_peds_t = peddata.GetPedsFrame(); _peds_t = peddata.GetPedsFrame();
_NumPeds = peddata.GetNumPeds(); _NumPeds = peddata.GetNumPeds();
_xCor = peddata.GetXCor(); _xCor = peddata.GetXCor();
_yCor = peddata.GetYCor(); _yCor = peddata.GetYCor();
_measureAreaId = boost::lexical_cast<string>(_areaForMethod_B->_id); _measureAreaId = boost::lexical_cast<string>(_areaForMethod_B->_id);
_tIn = new int[_NumPeds]; // Record the time of each pedestrian entering measurement area _tIn = new int[_NumPeds]; // Record the time of each pedestrian entering measurement area
_tOut = new int[_NumPeds]; _tOut = new int[_NumPeds];
for (int i=0; i<_NumPeds; i++) for (int i=0; i<_NumPeds; i++)
{ {
_tIn[i] = 0; _tIn[i] = 0;
_tOut[i] = 0; _tOut[i] = 0;
} }
GetTinTout(peddata.GetNumFrames()); GetTinTout(peddata.GetNumFrames());
Log->Write("------------------------Analyzing with Method B-----------------------------"); Log->Write("------------------------Analyzing with Method B-----------------------------");
if(_areaForMethod_B->_length<0) if(_areaForMethod_B->_length<0)
{ {
Log->Write("Error:\tThe measurement area length for method B is not assigned!"); Log->Write("Error:\tThe measurement area length for method B is not assigned!");
exit(0); exit(0);
} }
else else
{ {
GetFundamentalTinTout(_DensityPerFrame,_areaForMethod_B->_length); GetFundamentalTinTout(_DensityPerFrame,_areaForMethod_B->_length);
} }
delete []_tIn; delete []_tIn;
delete []_tOut; delete []_tOut;
return true; return true;
} }
void Method_B::GetTinTout(int numFrames) void Method_B::GetTinTout(int numFrames)
{ {
bool* IsinMeasurezone = new bool[_NumPeds]; bool* IsinMeasurezone = new bool[_NumPeds];
for (int i=0; i<_NumPeds; i++) for (int i=0; i<_NumPeds; i++)
{ {
IsinMeasurezone[i] = false; IsinMeasurezone[i] = false;
} }
_DensityPerFrame = new double[numFrames]; _DensityPerFrame = new double[numFrames];
Method_C method_C; Method_C method_C;
for(int frameNr = 0; frameNr < numFrames; frameNr++ ) for(int frameNr = 0; frameNr < numFrames; frameNr++ )
{ {
vector<int> ids=_peds_t[frameNr]; vector<int> ids=_peds_t[frameNr];
int pedsinMeasureArea=0; int pedsinMeasureArea=0;
for(unsigned int i=0; i< ids.size(); i++) for(unsigned int i=0; i< ids.size(); i++)
{ {
int ID = ids[i]; int ID = ids[i];
int x = _xCor[ID][frameNr]; int x = _xCor[ID][frameNr];
int y = _yCor[ID][frameNr]; int y = _yCor[ID][frameNr];
if(within(make<point_2d>( (x), (y)), _areaForMethod_B->_poly)) if(within(make<point_2d>( (x), (y)), _areaForMethod_B->_poly))
{ {
pedsinMeasureArea++; pedsinMeasureArea++;
} }
if(within(make<point_2d>( (x), (y)), _areaForMethod_B->_poly)&&!(IsinMeasurezone[ID])) { if(within(make<point_2d>( (x), (y)), _areaForMethod_B->_poly)&&!(IsinMeasurezone[ID])) {
_tIn[ID]=frameNr; _tIn[ID]=frameNr;
IsinMeasurezone[ID] = true; IsinMeasurezone[ID] = true;
} }