diff --git a/src/InteractorStyle.cpp b/src/InteractorStyle.cpp index 73407d175d2893d86c9fbdf059e13f1735d7fc83..6be369cb60e3b0c2f799c9e1de3efbb1f44989ff 100644 --- a/src/InteractorStyle.cpp +++ b/src/InteractorStyle.cpp @@ -107,7 +107,6 @@ void InteractorStyle::OnChar() { case 27: extern_fullscreen_enable = false; extern_force_system_update = true; - std::cout << "esc pressed" << std::endl; break; case 'a': { diff --git a/src/SaxParser.cpp b/src/SaxParser.cpp index 6279414181619ae8223d07c745bd6a83a59383c2..c421ec284f4fd7cd7721116a372385629f28bec1 100644 --- a/src/SaxParser.cpp +++ b/src/SaxParser.cpp @@ -59,10 +59,9 @@ SaxParser::SaxParser(FacilityGeometry* geo, SyncData* data, double* fps){ geometry=geo; dataset=data; para=fps; + parsingWalls=false; dataset->clearFrames(); - - parsingWalls=false; } SaxParser::~SaxParser() { @@ -869,4 +868,124 @@ void SaxParser::parseGeometryTRAV(QString content, FacilityGeometry *geometry,QD } } +void SaxParser::parseGeometryXMLV04(QString filename, FacilityGeometry *geo){ + QDomDocument doc(""); + + QFile file(filename); + if (!file.open(QIODevice::ReadOnly)) { + qDebug()<<"could not open the file: "<<filename<<endl; + return ; + } + QString *errorCode = new QString(); + if (!doc.setContent(&file, errorCode)) { + file.close(); + qDebug()<<errorCode<<endl; + return ; + } + QDomElement root= doc.documentElement(); + + //only parsing the geometry node + if(root.tagName()!="geometry") return; + + + double version =root.attribute("version","-1").toDouble(); + + if(version<0.4){ + QMessageBox::warning(0, QObject::tr("Parsing Error"), + QObject::tr("Only geometry version >= 0.4 supported")); + } + + //parsing the subrooms + QDomNodeList xSubRoomsNodeList=doc.elementsByTagName("subroom"); + //parsing the walls + for (unsigned int i = 0; i < xSubRoomsNodeList.length(); i++) { + QDomElement xPoly = xSubRoomsNodeList.item(i).firstChildElement("polygon"); + while(!xPoly.isNull()) { + //wall thickness, default to 30 cm + double thickness = xPoly.attribute("thickness","15").toDouble(); + //wall height default to 250 cm + double height = xPoly.attribute("height","250").toDouble(); + //wall color default to blue + double color = xPoly.attribute("color","0").toDouble(); + + QDomNodeList xVertices=xPoly.elementsByTagName("vertex"); + for( int i=0;i<xVertices.count()-1;i++){ + double x1=xVertices.item(i).toElement().attribute("px", "0").toDouble(); + double y1=xVertices.item(i).toElement().attribute("py", "0").toDouble(); + double z1=xVertices.item(i).toElement().attribute("pz", "0").toDouble(); + double x2=xVertices.item(i+1).toElement().attribute("px", "0").toDouble(); + double y2=xVertices.item(i+1).toElement().attribute("py", "0").toDouble(); + geo->addWall(x1, y1, x2, y2,z1,thickness,height,color); + } + xPoly = xPoly.nextSiblingElement("polygon"); + } + } + + QDomNodeList xObstaclesList=doc.elementsByTagName("obstacle"); + for (unsigned int i = 0; i < xObstaclesList.length(); i++) { + QDomElement xPoly = xObstaclesList.item(i).firstChildElement("polygon"); + while(!xPoly.isNull()) { + //wall thickness, default to 30 cm + double thickness = xPoly.attribute("thickness","15").toDouble(); + //wall height default to 250 cm + double height = xPoly.attribute("height","250").toDouble(); + //wall color default to blue + double color = xPoly.attribute("color","0").toDouble(); + + QDomNodeList xVertices=xPoly.elementsByTagName("vertex"); + for( int i=0;i<xVertices.count()-1;i++){ + double x1=xVertices.item(i).toElement().attribute("px", "0").toDouble(); + double y1=xVertices.item(i).toElement().attribute("py", "0").toDouble(); + double z1=xVertices.item(i).toElement().attribute("pz", "0").toDouble(); + + double x2=xVertices.item(i+1).toElement().attribute("px", "0").toDouble(); + double y2=xVertices.item(i+1).toElement().attribute("py", "0").toDouble(); + geo->addWall(x1, y1, x2, y2,z1,thickness,height,color); + } + xPoly = xPoly.nextSiblingElement("polygon"); + } + } + + QDomNodeList xCrossingsList=doc.elementsByTagName("crossing"); + for (unsigned int i = 0; i < xCrossingsList.length(); i++) { + QDomElement xCrossing = xCrossingsList.item(i).toElement(); + QDomNodeList xVertices=xCrossing.elementsByTagName("vertex"); + + ///door thickness, default to 15 cm + double thickness = xCrossing.attribute("thickness","15").toDouble(); + //door height default to 250 cm + double height = xCrossing.attribute("height","250").toDouble(); + //door color default to blue + double color = xCrossing.attribute("color","255").toDouble(); + + double x1=xVertices.item(0).toElement().attribute("px", "0").toDouble(); + double y1=xVertices.item(0).toElement().attribute("py", "0").toDouble(); + double z1=xVertices.item(0).toElement().attribute("pz", "0").toDouble(); + + double x2=xVertices.item(1).toElement().attribute("px", "0").toDouble(); + double y2=xVertices.item(1).toElement().attribute("py", "0").toDouble(); + geo->addDoor(x1, y1, x2, y2,z1,thickness,height,color); + } + + QDomNodeList xTransitionsList=doc.elementsByTagName("transition"); + for (unsigned int i = 0; i < xTransitionsList.length(); i++) { + QDomElement xTransition = xTransitionsList.item(i).toElement(); + QDomNodeList xVertices=xTransition.elementsByTagName("vertex"); + + ///door thickness, default to 15 cm + double thickness = xTransition.attribute("thickness","15").toDouble(); + //door height default to 250 cm + double height = xTransition.attribute("height","250").toDouble(); + //door color default to blue + double color = xTransition.attribute("color","255").toDouble(); + + double x1=xVertices.item(0).toElement().attribute("px", "0").toDouble(); + double y1=xVertices.item(0).toElement().attribute("py", "0").toDouble(); + double z1=xVertices.item(0).toElement().attribute("pz", "0").toDouble(); + + double x2=xVertices.item(1).toElement().attribute("px", "0").toDouble(); + double y2=xVertices.item(1).toElement().attribute("py", "0").toDouble(); + geo->addDoor(x1, y1, x2, y2,z1,thickness,height,color); + } +} diff --git a/src/SaxParser.h b/src/SaxParser.h index 83752e612fc646e26c85e28451de2d5d5ae09fb7..be322fe3a0d3bb7ac34e3b645fb6a80e08892fc8 100644 --- a/src/SaxParser.h +++ b/src/SaxParser.h @@ -68,6 +68,9 @@ public: /// provided for convenience and will be removed in the next version static void parseGeometryPG3(QString content, FacilityGeometry *geo); + /// provided for convenience and will be removed in the next version + static void parseGeometryXMLV04(QString content, FacilityGeometry *geo); + /// provided for convenience and will be removed in the next version static void parseGeometryTRAV(QString content, FacilityGeometry *geo,QDomNode geoNode=NULL); diff --git a/src/geometry/FacilityGeometry.h b/src/geometry/FacilityGeometry.h index 58abedae0f59fece81b95963568dcd03feee9f51..adf7b5fdfa45f3eb1740bf7b99a17bb8ebe22ccd 100644 --- a/src/geometry/FacilityGeometry.h +++ b/src/geometry/FacilityGeometry.h @@ -33,7 +33,7 @@ #ifndef FACILITYGEOMETRY_H_ #define FACILITYGEOMETRY_H_ -#include<string> +#include <string> //forwarded classes class vtkPolyData; diff --git a/src/travisto.cpp b/src/travisto.cpp index 57edee9d54437591f2b369f5b0b2519e94a8d424..3cf0668525a68bdc92a37f2d0f178291678fc999 100644 --- a/src/travisto.cpp +++ b/src/travisto.cpp @@ -266,10 +266,10 @@ void TraVisTo::slotHelpAbout() { QMessageBox::about( this, "About TraVisTo", - "Version 0.2 build with QT 4.6 and VTK 5.4\n\n" + "Version 0.4 build with QT 4.6 and VTK 5.4\n\n" "TraVisTo stands for Trajectories Visualisation Tool. It is a tool for visualizing pedestrians motion\n" - "developped at the Forschungszentrum Juelich, Germany\n\n" - "Copyright 2009-2011.\n" + "developped at the Forschungszentrum Juelich GmbH, Germany\n\n" + "Copyright 2009-2012.\n" "Authors: Ulrich Kemloh\n\n" "For questions, contact +49-40-246161-4193 \nor mail at \n" "u.kemloh@fz-juelich.de\n"); @@ -579,14 +579,14 @@ bool TraVisTo::addPedestrianGroup(int groupID,QString fileName){ { //geometry=parseGeometryPG3(fileName); SaxParser::parseGeometryPG3(fileName,geometry); - } - // // if jul is detected, just load and show the geometry then exit - // if(fileName.endsWith(".jul",Qt::CaseInsensitive)){ - // slotLoadParseShowGeometry(fileName); - // return false; - // } + // if xml is detected, just load and show the geometry then exit + else if(fileName.endsWith(".xml",Qt::CaseInsensitive)){ + SaxParser::parseGeometryXMLV04(fileName,geometry); + //slotLoadParseShowGeometry(fileName); + //return false; + } QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) {