Commit 50537e39 authored by Ulrich Kemloh's avatar Ulrich Kemloh

changing functions signature from void to bool.

Geometry functions now return false on failure.
parent a5161e99
...@@ -315,9 +315,9 @@ void TrajectoriesJPSV04::WriteFrame(int frameNr, Building* building) ...@@ -315,9 +315,9 @@ void TrajectoriesJPSV04::WriteFrame(int frameNr, Building* building)
string caption = r->GetCaption(); string caption = r->GetCaption();
if ((rooms_to_plot.empty() == false) if ((rooms_to_plot.empty() == false)
&& (IsElementInVector(rooms_to_plot, caption) == false)) { && (IsElementInVector(rooms_to_plot, caption) == false)) {
continue; continue;
} }
data.append(WritePed(ped)); data.append(WritePed(ped));
} }
...@@ -341,6 +341,7 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories() ...@@ -341,6 +341,7 @@ TrajectoriesFLAT::TrajectoriesFLAT() : Trajectories()
void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, int seed) void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, int seed)
{ {
(void) seed; (void) nPeds;
char tmp[CLENGTH] = ""; char tmp[CLENGTH] = "";
Write("#description: my super simulation"); Write("#description: my super simulation");
sprintf(tmp, "#framerate: %0.2f",fps); sprintf(tmp, "#framerate: %0.2f",fps);
...@@ -356,7 +357,7 @@ void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, in ...@@ -356,7 +357,7 @@ void TrajectoriesFLAT::WriteHeader(int nPeds, double fps, Building* building, in
void TrajectoriesFLAT::WriteGeometry(Building* building) void TrajectoriesFLAT::WriteGeometry(Building* building)
{ {
(void) building;
} }
void TrajectoriesFLAT::WriteFrame(int frameNr, Building* building) void TrajectoriesFLAT::WriteFrame(int frameNr, Building* building)
...@@ -392,6 +393,8 @@ TrajectoriesVTK::TrajectoriesVTK() ...@@ -392,6 +393,8 @@ TrajectoriesVTK::TrajectoriesVTK()
void TrajectoriesVTK::WriteHeader(int nPeds, double fps, Building* building, int seed) void TrajectoriesVTK::WriteHeader(int nPeds, double fps, Building* building, int seed)
{ {
//suppress unused warnings
(void) nPeds; (void) fps ; (void) seed;
Write("# vtk DataFile Version 4.0"); Write("# vtk DataFile Version 4.0");
Write(building->GetCaption()); Write(building->GetCaption());
Write("ASCII"); Write("ASCII");
...@@ -447,6 +450,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building) ...@@ -447,6 +450,7 @@ void TrajectoriesVTK::WriteGeometry(Building* building)
void TrajectoriesVTK::WriteFrame(int frameNr, Building* building) void TrajectoriesVTK::WriteFrame(int frameNr, Building* building)
{ {
(void) frameNr; (void)building;
} }
void TrajectoriesVTK::WriteFooter() void TrajectoriesVTK::WriteFooter()
...@@ -481,24 +485,24 @@ void TrajectoriesJPSV06::WriteHeader(int nPeds, double fps, Building* building, ...@@ -481,24 +485,24 @@ void TrajectoriesJPSV06::WriteHeader(int nPeds, double fps, Building* building,
void TrajectoriesJPSV06::WriteGeometry(Building* building) void TrajectoriesJPSV06::WriteGeometry(Building* building)
{ {
// just put a link to the geometry file // just put a link to the geometry file
// string embed_geometry; // string embed_geometry;
// embed_geometry.append("\t<geometry>\n"); // embed_geometry.append("\t<geometry>\n");
// char file_location[CLENGTH] = ""; // char file_location[CLENGTH] = "";
// sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str()); // sprintf(file_location, "\t<file location= \"%s\"/>\n", building->GetGeometryFilename().c_str());
// embed_geometry.append(file_location); // embed_geometry.append(file_location);
// //embed_geometry.append("\t</geometry>\n"); // //embed_geometry.append("\t</geometry>\n");
// //
// const map<int, Hline*>& hlines=building->GetAllHlines(); // const map<int, Hline*>& hlines=building->GetAllHlines();
// if(hlines.size()>0){ // if(hlines.size()>0){
// //embed_geometry.append("\t<geometry>\n"); // //embed_geometry.append("\t<geometry>\n");
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it) // for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// { // {
// embed_geometry.append(it->second->WriteElement()); // embed_geometry.append(it->second->WriteElement());
// } // }
// //embed_geometry.append("\t</geometry>\n"); // //embed_geometry.append("\t</geometry>\n");
// } // }
// embed_geometry.append("\t</geometry>\n"); // embed_geometry.append("\t</geometry>\n");
// Write(embed_geometry); // Write(embed_geometry);
//set the content of the file //set the content of the file
string fileName=building->GetProjectRootDir()+"/"+building->GetGeometryFilename().c_str(); string fileName=building->GetProjectRootDir()+"/"+building->GetGeometryFilename().c_str();
...@@ -510,51 +514,51 @@ void TrajectoriesJPSV06::WriteGeometry(Building* building) ...@@ -510,51 +514,51 @@ void TrajectoriesJPSV06::WriteGeometry(Building* building)
buffer << t.rdbuf(); buffer << t.rdbuf();
embed_geometry=buffer.str(); embed_geometry=buffer.str();
Write(embed_geometry); Write(embed_geometry);
// //
// //
// //collecting the hlines // //collecting the hlines
// std::stringstream hlines_buffer; // std::stringstream hlines_buffer;
// // add the header // // add the header
// hlines_buffer<<" <routing version=\"0.5\" " // hlines_buffer<<" <routing version=\"0.5\" "
// <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " // <<"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
// <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl // <<"xsi:noNamespaceSchemaLocation=\"http://134.94.2.137/jps_routing.xsd\" >"<<endl
// <<"<Hlines> "<<endl; // <<"<Hlines> "<<endl;
// //
// const map<int, Hline*>& hlines=building->GetAllHlines(); // const map<int, Hline*>& hlines=building->GetAllHlines();
// for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it) // for (std::map<int, Hline*>::const_iterator it=hlines.begin(); it!=hlines.end(); ++it)
// { // {
// Hline* hl=it->second; // Hline* hl=it->second;
// hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID() // hlines_buffer <<"\t<Hline id=\""<< hl->GetID()<<"\" room_id=\""<<hl->GetRoom1()->GetID()
// <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl; // <<"\" subroom_id=\""<< hl->GetSubRoom1()->GetSubRoomID()<<"\">"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl; // hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint1()._x<<"\" py=\""<< hl->GetPoint1()._y<<"\" />"<<endl;
// hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl; // hlines_buffer <<"\t\t<vertex px=\""<< hl->GetPoint2()._x<<"\" py=\""<< hl->GetPoint2()._y<<"\" />"<<endl;
// hlines_buffer <<"\t</Hline>"<<endl; // hlines_buffer <<"\t</Hline>"<<endl;
// } // }
// hlines_buffer<<"</Hlines> "<<endl; // hlines_buffer<<"</Hlines> "<<endl;
// hlines_buffer<<"</routing> "<<endl; // hlines_buffer<<"</routing> "<<endl;
// //
// string hline_string=hlines_buffer.str(); // string hline_string=hlines_buffer.str();
// string to_replace="</geometry>"; // string to_replace="</geometry>";
// hline_string.append(to_replace); // hline_string.append(to_replace);
// //
// size_t start_pos = embed_geometry.find(to_replace); // size_t start_pos = embed_geometry.find(to_replace);
// if(start_pos == std::string::npos) // if(start_pos == std::string::npos)
// { // {
// Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str()); // Log->Write("WARNING:\t missing %s tag while writing the geometry in the trajectory file.",to_replace.c_str());
// } // }
// //
// embed_geometry.replace(start_pos, to_replace.length(), hline_string); // embed_geometry.replace(start_pos, to_replace.length(), hline_string);
// Write(embed_geometry); // Write(embed_geometry);
// Write("\t<AttributeDescription>"); // Write("\t<AttributeDescription>");
// Write("\t\t<property tag=\"x\" description=\"xPosition\"/>"); // Write("\t\t<property tag=\"x\" description=\"xPosition\"/>");
// Write("\t\t<property tag=\"y\" description=\"yPosition\"/>"); // Write("\t\t<property tag=\"y\" description=\"yPosition\"/>");
// Write("\t\t<property tag=\"z\" description=\"zPosition\"/>"); // Write("\t\t<property tag=\"z\" description=\"zPosition\"/>");
// Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>"); // Write("\t\t<property tag=\"rA\" description=\"radiusA\"/>");
// Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>"); // Write("\t\t<property tag=\"rB\" description=\"radiusB\"/>");
// Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>"); // Write("\t\t<property tag=\"eC\" description=\"ellipseColor\"/>");
// Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>"); // Write("\t\t<property tag=\"eO\" description=\"ellipseOrientation\"/>");
// Write("\t</AttributeDescription>\n"); // Write("\t</AttributeDescription>\n");
} }
void TrajectoriesJPSV06::WriteFrame(int frameNr, Building* building) void TrajectoriesJPSV06::WriteFrame(int frameNr, Building* building)
......
This diff is collapsed.
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
/** /**
* Read parameters from the argument parser class. * Read parameters from the argument parser class.
*/ */
void InitArgs(ArgumentParser *args); bool InitArgs(ArgumentParser *args);
/** /**
* @return the total simulated/evacuation time * @return the total simulated/evacuation time
......
...@@ -22,10 +22,10 @@ EventManager::EventManager(Building *_b){ ...@@ -22,10 +22,10 @@ EventManager::EventManager(Building *_b){
_lastUpdateTime=0; _lastUpdateTime=0;
_deltaT=0; _deltaT=0;
if(!_file){ if(!_file){
Log->Write("INFO:\tDatei events.txt nicht gefunden. Dynamisches Eventhandling nicht moeglich."); Log->Write("INFO:\tFiles 'events.txt' missing. Realtime interaction with the simulation not possible.");
} }
else{ else{
Log->Write("INFO:\tDatei events.txt gefunden. Dynamisches Eventhandling moeglich."); Log->Write("INFO:\tFile 'events.txt' will be monitored for new events.");
_dynamic=true; _dynamic=true;
} }
} }
...@@ -42,7 +42,7 @@ void EventManager::SetProjectRootDir(const std::string &filename){ ...@@ -42,7 +42,7 @@ void EventManager::SetProjectRootDir(const std::string &filename){
} }
void EventManager::readEventsXml(){ void EventManager::readEventsXml(){
Log->Write("INFO: \tLooking for events"); Log->Write("INFO: \tLooking for pre-defined events in other files");
//get the geometry filename from the project file //get the geometry filename from the project file
TiXmlDocument doc(_projectFilename); TiXmlDocument doc(_projectFilename);
if (!doc.LoadFile()){ if (!doc.LoadFile()){
...@@ -97,16 +97,19 @@ void EventManager::readEventsXml(){ ...@@ -97,16 +97,19 @@ void EventManager::readEventsXml(){
Log->Write("INFO: \tEvents were read\n"); Log->Write("INFO: \tEvents were read\n");
} }
void EventManager::listEvents(){ void EventManager::listEvents()
if(_event_times.size()==0){ {
Log->Write("INFO: \tNo events in the events.xml"); if (_event_times.size() == 0) {
} //this notification was already printed ealier
else{ //Log->Write("INFO: \tNo events in the events.xml");
char buf[10],buf2[10]; } else {
for(unsigned int i=0;i<_event_times.size();i++){ char buf[10], buf2[10];
sprintf(buf,"%f",_event_times[i]); for (unsigned int i = 0; i < _event_times.size(); i++) {
sprintf(buf2,"%d",_event_ids[i]); sprintf(buf, "%f", _event_times[i]);
Log->Write("INFO: \tAfter "+string(buf)+" sec: "+_event_types[i]+" "+string(buf2)+" "+_event_states[i]); sprintf(buf2, "%d", _event_ids[i]);
Log->Write(
"INFO: \tAfter " + string(buf) + " sec: " + _event_types[i]
+ " " + string(buf2) + " " + _event_states[i]);
} }
} }
......
...@@ -162,4 +162,7 @@ template<typename A> ...@@ -162,4 +162,7 @@ template<typename A>
return true; return true;
} }
} }
//another useful macro
//#define UNUSED(expr) (void)(expr)
#endif /* _MACROS_H */ #endif /* _MACROS_H */
...@@ -259,7 +259,7 @@ void Building::AddSurroundingRoom() ...@@ -259,7 +259,7 @@ void Building::AddSurroundingRoom()
} }
void Building::InitGeometry() bool Building::InitGeometry()
{ {
Log->Write("INFO: \tInit Geometry"); Log->Write("INFO: \tInit Geometry");
for (int i = 0; i < GetNumberOfRooms(); i++) { for (int i = 0; i < GetNumberOfRooms(); i++) {
...@@ -284,7 +284,8 @@ void Building::InitGeometry() ...@@ -284,7 +284,8 @@ void Building::InitGeometry()
} }
// initialize the poly // initialize the poly
s->ConvertLineToPoly(goals); if(! s->ConvertLineToPoly(goals))
return false;
s->CalculateArea(); s->CalculateArea();
goals.clear(); goals.clear();
...@@ -292,11 +293,14 @@ void Building::InitGeometry() ...@@ -292,11 +293,14 @@ void Building::InitGeometry()
const vector<Obstacle*>& obstacles = s->GetAllObstacles(); const vector<Obstacle*>& obstacles = s->GetAllObstacles();
for (unsigned int obs = 0; obs < obstacles.size(); ++obs) { for (unsigned int obs = 0; obs < obstacles.size(); ++obs) {
if (obstacles[obs]->GetClosed() == 1) if (obstacles[obs]->GetClosed() == 1)
obstacles[obs]->ConvertLineToPoly(); if(!obstacles[obs]->ConvertLineToPoly())
return false;
} }
} }
} }
Log->Write("INFO: \tInit Geometry successful!!!\n"); Log->Write("INFO: \tInit Geometry successful!!!\n");
return true;
} }
...@@ -324,7 +328,7 @@ const std::string& Building::GetGeometryFilename() const ...@@ -324,7 +328,7 @@ const std::string& Building::GetGeometryFilename() const
return _geometryFilename; return _geometryFilename;
} }
void Building::LoadGeometry(const std::string &geometryfile) bool Building::LoadGeometry(const std::string &geometryfile)
{ {
//get the geometry filename from the project file //get the geometry filename from the project file
string geoFilenameWithPath= _projectRootDir + geometryfile; string geoFilenameWithPath= _projectRootDir + geometryfile;
...@@ -335,7 +339,7 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -335,7 +339,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
if (!doc.LoadFile()) { if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc()); Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("\t could not parse the project file"); Log->Write("\t could not parse the project file");
exit(EXIT_FAILURE); return false;
} }
Log->Write("INFO: \tParsing the geometry file"); Log->Write("INFO: \tParsing the geometry file");
...@@ -352,23 +356,23 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -352,23 +356,23 @@ void Building::LoadGeometry(const std::string &geometryfile)
if (!docGeo.LoadFile()) { if (!docGeo.LoadFile()) {
Log->Write("ERROR: \t%s", docGeo.ErrorDesc()); Log->Write("ERROR: \t%s", docGeo.ErrorDesc());
Log->Write("\t could not parse the geometry file"); Log->Write("\t could not parse the geometry file");
exit(EXIT_FAILURE); return false;
} }
TiXmlElement* xRootNode = docGeo.RootElement(); TiXmlElement* xRootNode = docGeo.RootElement();
if( ! xRootNode ) { if( ! xRootNode ) {
Log->Write("ERROR:\tRoot element does not exist"); Log->Write("ERROR:\tRoot element does not exist");
exit(EXIT_FAILURE); return false;
} }
if( xRootNode->ValueStr () != "geometry" ) { if( xRootNode->ValueStr () != "geometry" ) {
Log->Write("ERROR:\tRoot element value is not 'geometry'."); Log->Write("ERROR:\tRoot element value is not 'geometry'.");
exit(EXIT_FAILURE); return false;
} }
if(xRootNode->Attribute("unit")) if(xRootNode->Attribute("unit"))
if(string(xRootNode->Attribute("unit")) != "m") { if(string(xRootNode->Attribute("unit")) != "m") {
Log->Write("ERROR:\tOnly the unit m (meters) is supported. \n\tYou supplied [%s]",xRootNode->Attribute("unit")); Log->Write("ERROR:\tOnly the unit m (meters) is supported. \n\tYou supplied [%s]",xRootNode->Attribute("unit"));
exit(EXIT_FAILURE); return false;
} }
double version = xmltof(xRootNode->Attribute("version"), -1); double version = xmltof(xRootNode->Attribute("version"), -1);
...@@ -377,7 +381,7 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -377,7 +381,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
Log->Write(" \tWrong geometry version!"); Log->Write(" \tWrong geometry version!");
Log->Write(" \tOnly version >= %s supported",JPS_VERSION); Log->Write(" \tOnly version >= %s supported",JPS_VERSION);
Log->Write(" \tPlease update the version of your geometry file to %s",JPS_VERSION); Log->Write(" \tPlease update the version of your geometry file to %s",JPS_VERSION);
exit(EXIT_FAILURE); return false;
} }
_caption = xmltoa(xRootNode->Attribute("caption"), "virtual building"); _caption = xmltoa(xRootNode->Attribute("caption"), "virtual building");
...@@ -388,7 +392,7 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -388,7 +392,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
TiXmlNode* xRoomsNode = xRootNode->FirstChild("rooms"); TiXmlNode* xRoomsNode = xRootNode->FirstChild("rooms");
if (!xRoomsNode) { if (!xRoomsNode) {
Log->Write("ERROR: \tThe geometry should have at least one room and one subroom"); Log->Write("ERROR: \tThe geometry should have at least one room and one subroom");
exit(EXIT_FAILURE); return false;
} }
for(TiXmlElement* xRoom = xRoomsNode->FirstChildElement("room"); xRoom; for(TiXmlElement* xRoom = xRoomsNode->FirstChildElement("room"); xRoom;
...@@ -431,7 +435,7 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -431,7 +435,7 @@ void Building::LoadGeometry(const std::string &geometryfile)
if(xSubRoom->FirstChildElement("up")==NULL) { if(xSubRoom->FirstChildElement("up")==NULL) {
Log->Write("ERROR:\t the attribute <up> and <down> are missing for the stair"); Log->Write("ERROR:\t the attribute <up> and <down> are missing for the stair");
Log->Write("ERROR:\t check your geometry file"); Log->Write("ERROR:\t check your geometry file");
exit(EXIT_FAILURE); return false;
} }
double up_x = xmltof( xSubRoom->FirstChildElement("up")->Attribute("px"), 0.0); double up_x = xmltof( xSubRoom->FirstChildElement("up")->Attribute("px"), 0.0);
double up_y = xmltof( xSubRoom->FirstChildElement("up")->Attribute("py"), 0.0); double up_y = xmltof( xSubRoom->FirstChildElement("up")->Attribute("py"), 0.0);
...@@ -601,8 +605,10 @@ void Building::LoadGeometry(const std::string &geometryfile) ...@@ -601,8 +605,10 @@ void Building::LoadGeometry(const std::string &geometryfile)
AddTransition(t); AddTransition(t);
} }
Log->Write("INFO: \tLoading building file successful!!!\n"); Log->Write("INFO: \tLoading building file successful!!!\n");
//everything went fine
return true;
} }
...@@ -851,18 +857,21 @@ bool Building::IsVisible(const Point& p1, const Point& p2, bool considerHlines) ...@@ -851,18 +857,21 @@ bool Building::IsVisible(const Point& p1, const Point& p2, bool considerHlines)
return true; return true;
} }
void Building::SanityCheck() bool Building::SanityCheck()
{ {
Log->Write("INFO: \tChecking the geometry for artifacts"); Log->Write("INFO: \tChecking the geometry for artifacts");
bool status = true;
for (unsigned int i = 0; i < _rooms.size(); i++) { for (unsigned int i = 0; i < _rooms.size(); i++) {
Room* room = _rooms[i]; Room* room = _rooms[i];
for (int j = 0; j < room->GetNumberOfSubRooms(); j++) { for (int j = 0; j < room->GetNumberOfSubRooms(); j++) {
SubRoom* sub = room->GetSubRoom(j); SubRoom* sub = room->GetSubRoom(j);
sub->SanityCheck(); if (!sub->SanityCheck())
status = false;
} }
} }
Log->Write("INFO: \t...Done!!!\n"); Log->Write("INFO: \t...Done!!!\n");
return status;
} }
...@@ -938,25 +947,25 @@ void Building::InitGrid(double cellSize) ...@@ -938,25 +947,25 @@ void Building::InitGrid(double cellSize)
Log->Write("INFO: \tDone with Initializing the grid "); Log->Write("INFO: \tDone with Initializing the grid ");
} }
void Building::LoadRoutingInfo(const string &filename) bool Building::LoadRoutingInfo(const string &filename)
{ {
Log->Write("INFO:\tLoading extra routing information"); Log->Write("INFO:\tLoading extra routing information");
if (filename == "") { if (filename == "") {
Log->Write("INFO:\t No file supplied !"); Log->Write("INFO:\t No file supplied !");
Log->Write("INFO:\t done with loading extra routing information"); Log->Write("INFO:\t done with loading extra routing information");
return; return true;
} }
TiXmlDocument docRouting(filename); TiXmlDocument docRouting(filename);
if (!docRouting.LoadFile()) { if (!docRouting.LoadFile()) {
Log->Write("ERROR: \t%s", docRouting.ErrorDesc()); Log->Write("ERROR: \t%s", docRouting.ErrorDesc());
Log->Write("ERROR: \t could not parse the routing file"); Log->Write("ERROR: \t could not parse the routing file");
exit(EXIT_FAILURE); return false;
} }
TiXmlElement* xRootNode = docRouting.RootElement(); TiXmlElement* xRootNode = docRouting.RootElement();
if( ! xRootNode ) { if( ! xRootNode ) {
Log->Write("ERROR:\tRoot element does not exist"); Log->Write("ERROR:\tRoot element does not exist");
exit(EXIT_FAILURE); return false;
} }
//load goals and routes //load goals and routes
...@@ -993,7 +1002,9 @@ void Building::LoadRoutingInfo(const string &filename) ...@@ -993,7 +1002,9 @@ void Building::LoadRoutingInfo(const string &filename)
} }
} }
goal->ConvertLineToPoly(); if(!goal->ConvertLineToPoly())
return false;
AddGoal(goal); AddGoal(goal);
_routingEngine->AddFinalDestinationID(goal->GetId()); _routingEngine->AddFinalDestinationID(goal->GetId());
} }
...@@ -1008,7 +1019,7 @@ void Building::LoadRoutingInfo(const string &filename) ...@@ -1008,7 +1019,7 @@ void Building::LoadRoutingInfo(const string &filename)
double id = xmltof(trip->Attribute("id"), -1); double id = xmltof(trip->Attribute("id"), -1);
if (id == -1) { if (id == -1) {
Log->Write("ERROR:\t id missing for trip"); Log->Write("ERROR:\t id missing for trip");
exit(EXIT_FAILURE); return false;
} }
string sTrip = trip->FirstChild()->ValueStr(); string sTrip = trip->FirstChild()->ValueStr();
vector<string> vTrip; vector<string> vTrip;
...@@ -1023,9 +1034,10 @@ void Building::LoadRoutingInfo(const string &filename) ...@@ -1023,9 +1034,10 @@ void Building::LoadRoutingInfo(const string &filename)
_routingEngine->AddTrip(vTrip); _routingEngine->AddTrip(vTrip);
} }
Log->Write("INFO:\tdone with loading extra routing information"); Log->Write("INFO:\tdone with loading extra routing information");
return true;
} }
void Building::LoadTrafficInfo() bool Building::LoadTrafficInfo()
{ {
Log->Write("INFO:\tLoading the traffic info file"); Log->Write("INFO:\tLoading the traffic info file");
...@@ -1035,14 +1047,13 @@ void Building::LoadTrafficInfo() ...@@ -1035,14 +1047,13 @@ void Building::LoadTrafficInfo()
if (!doc.LoadFile()) { if (!doc.LoadFile()) {
Log->Write("ERROR: \t%s", doc.ErrorDesc()); Log->Write("ERROR: \t%s", doc.ErrorDesc());
Log->Write("ERROR: \t could not parse the project file"); Log->Write("ERROR: \t could not parse the project file");
exit(EXIT_FAILURE); return false;
} }
TiXmlNode* xRootNode = doc.RootElement()->FirstChild("traffic_constraints"); TiXmlNode* xRootNode = doc.RootElement()->FirstChild("traffic_constraints");
if( ! xRootNode ) { if( ! xRootNode ) {
Log->Write("WARNING:\tcould not find any traffic information"); Log->Write("WARNING:\tcould not find any traffic information");
return; return true;
//exit(EXIT_FAILURE);
} }
//processing the rooms node