From 9b496d47dda1f884c316ec3951be7975b11c4192 Mon Sep 17 00:00:00 2001 From: Mohcine Chraibi <m.chraibi@fz-juelich.de> Date: Sat, 6 Apr 2019 15:28:41 +0200 Subject: [PATCH] distinguish between absolute geometry files --- src/MainWindow.cpp | 4 +++- src/SaxParser.cpp | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8f46d9c..648d966 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -765,8 +765,10 @@ bool MainWindow::addPedestrianGroup(int groupID,QString fileName) if(! SaxParser::parseGeometryJPS(geometry_file,geometry)) { int res = QMessageBox::warning(this, "Errors in Geometry. Continue Parsing?", "JuPedSim has detected an error in the supplied geometry.\n" + "<" + +geometry_file+ + ">" "The simulation will likely fail using this geometry.\n" - "Also make sure to validate your file.\n" "More information are provided in the log file:\n" +SystemSettings::getLogfile()+ "\n\nShould I try to parse and display what I can?" diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index 585686f..145e247 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -678,16 +678,21 @@ bool SaxParser::parseGeometryJPS(QString fileName, GeometryFactory& geoFac) Debug::Messages( "Enter SaxParser::parseGeometryJPS with filename <%s>",fileName.toStdString().c_str()); double captionsColor=0;//red - if(!fileName.endsWith(".xml",Qt::CaseInsensitive)) return false; + QDir fileDir(fileName); QString wd; QDir dir(wd); SystemSettings::getWorkingDirectory(wd); - QString s = dir.relativeFilePath(fileName); - fileName=wd + QDir::separator() + s; + + if(!fileName.endsWith(".xml",Qt::CaseInsensitive)) return false; + if(!fileDir.isAbsolute()) + { + QString s = dir.relativeFilePath(fileName); + fileName=wd + QDir::separator() + s; + } + // QString = QDir::cleanPath(wd + QDir::separator() + fileName); Debug::Messages("filename: <%s)", fileName.toStdString().c_str()); Debug::Messages("wd: <%s>",wd.toStdString().c_str()); - Building* building = new Building(); string geometrypath = fileName.toStdString(); // read the geometry -- GitLab