write out all files with abs path

- Changes to  ProjectRootDir: probable side effects.
--> needs testing
parent bf953a99
Pipeline #21763 passed with stages
in 9 minutes and 18 seconds
...@@ -60,7 +60,9 @@ void GeoFileParser::LoadBuilding(Building* building) ...@@ -60,7 +60,9 @@ void GeoFileParser::LoadBuilding(Building* building)
bool GeoFileParser::LoadGeometry(Building* building) bool GeoFileParser::LoadGeometry(Building* building)
{ {
std::string geoFilenameWithPath = _configuration->GetProjectRootDir()+_configuration->GetGeometryFile(); fs::path rootDir(_configuration->GetProjectRootDir());
std::string geoFilenameWithPath = (rootDir/fs::path(_configuration->GetGeometryFile())).string();
std::cout << "\nLoadGeometry: file: " << geoFilenameWithPath << "\n"; std::cout << "\nLoadGeometry: file: " << geoFilenameWithPath << "\n";
TiXmlDocument docGeo(geoFilenameWithPath); TiXmlDocument docGeo(geoFilenameWithPath);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#define _USE_MATH_DEFINES #define _USE_MATH_DEFINES
using namespace std; using namespace std;
namespace fs = std::filesystem;
IODispatcher::IODispatcher() IODispatcher::IODispatcher()
...@@ -466,6 +467,8 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i ...@@ -466,6 +467,8 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
std::string eventFileName = getEventFileName(building->GetProjectFilename()); std::string eventFileName = getEventFileName(building->GetProjectFilename());
std::string trainTimeTableFileName = getTrainTimeTableFileName(building->GetProjectFilename()); std::string trainTimeTableFileName = getTrainTimeTableFileName(building->GetProjectFilename());
std::string trainTypeFileName = getTrainTypeFileName(building->GetProjectFilename()); std::string trainTypeFileName = getTrainTypeFileName(building->GetProjectFilename());
fs::path projRoot(building->GetProjectRootDir());
(void) seed; (void) nPeds; (void) seed; (void) nPeds;
char tmp[100] = ""; char tmp[100] = "";
sprintf(tmp, "#description: jpscore (%s)", JPSCORE_VERSION); sprintf(tmp, "#description: jpscore (%s)", JPSCORE_VERSION);
...@@ -474,31 +477,37 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i ...@@ -474,31 +477,37 @@ void TrajectoriesFLAT::WriteHeader(long nPeds, double fps, Building* building, i
Write(tmp); Write(tmp);
sprintf(tmp, "#framerate: %0.2f",fps); sprintf(tmp, "#framerate: %0.2f",fps);
Write(tmp); Write(tmp);
sprintf(tmp,"#geometry: %s",building->GetGeometryFilename().c_str()); std::string tmpGeo= (projRoot/fs::path(building->GetGeometryFilename())).string();
sprintf(tmp,"#geometry: %s", tmpGeo.c_str());
Write(tmp); Write(tmp);
if(sourceFileName != "") if(sourceFileName != "")
{ {
sprintf(tmp,"#sources: %s", sourceFileName.c_str()); std::string tmpSource= (projRoot/fs::path(sourceFileName)).string();
sprintf(tmp,"#sources: %s", tmpSource.c_str());
Write(tmp); Write(tmp);
} }
if(goalFileName != "") if(goalFileName != "")
{ {
sprintf(tmp,"#goals: %s", goalFileName.c_str()); std::string tmpGoal= (projRoot/fs::path(goalFileName)).string();
sprintf(tmp,"#goals: %s", tmpGoal.c_str());
Write(tmp); Write(tmp);
} }
if( eventFileName != "") if( eventFileName != "")
{ {
sprintf(tmp,"#events: %s", eventFileName.c_str()); std::string tmpEvent= (projRoot/fs::path(eventFileName)).string();
sprintf(tmp,"#events: %s", tmpEvent.c_str());
Write(tmp); Write(tmp);
} }
if( trainTimeTableFileName != "") if( trainTimeTableFileName != "")
{ {
sprintf(tmp,"#trainTimeTable: %s", trainTimeTableFileName.c_str()); std::string tmpTTT= (projRoot/fs::path(trainTimeTableFileName)).string();
sprintf(tmp,"#trainTimeTable: %s", tmpTTT.c_str());
Write(tmp); Write(tmp);
} }
if( trainTypeFileName != "") if( trainTypeFileName != "")
{ {
sprintf(tmp,"#trainType: %s", trainTypeFileName.c_str()); std::string tmpTT= (projRoot/fs::path(trainTypeFileName)).string();
sprintf(tmp,"#trainType: %s", tmpTT.c_str());
Write(tmp); Write(tmp);
} }
Write("#ID: the agent ID"); Write("#ID: the agent ID");
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <cstring> #include <cstring>
#include <vector> #include <vector>
#include <filesystem>
extern OutputHandler* Log; extern OutputHandler* Log;
class Trajectories; class Trajectories;
......
...@@ -98,15 +98,9 @@ bool IniFileParser::Parse(std::string iniFile) ...@@ -98,15 +98,9 @@ bool IniFileParser::Parse(std::string iniFile)
// and as I just realized, I called it configuration. We should be consistent here anything else // and as I just realized, I called it configuration. We should be consistent here anything else
// is confusing [gl march '16] // is confusing [gl march '16]
fs::path root(iniFile);
fs::path q(iniFile);
//extract and set the project root dir _config->SetProjectRootDir(fs::absolute(q.parent_path()).string());
size_t found = iniFile.find_last_of("/\\");
if (found!=std::string::npos) {
_config->SetProjectRootDir(iniFile.substr(0, found)+"/");
} else {
_config->SetProjectRootDir("./");
}
TiXmlDocument doc(iniFile); TiXmlDocument doc(iniFile);
if (!doc.LoadFile()) { if (!doc.LoadFile()) {
......
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