Commit 3b388897 authored by tobias schroedter's avatar tobias schroedter

Merging 302 and 307

parents d6611b95 ac39c9af
Pipeline #18651 passed with stages
in 19 minutes and 2 seconds
......@@ -584,20 +584,20 @@ routing/ai_router/perception/sign.cpp
routing/ai_router/Cortex.cpp
#AI router trips
routing/ai_router_trips/AIRouterTrips.cpp
routing/ai_router_trips/BrainStorage.cpp
routing/ai_router_trips/cognitiveMap/associations.cpp
routing/ai_router_trips/cognitiveMap/connection.cpp
routing/ai_router_trips/cognitiveMap/cognitivemap.cpp
routing/ai_router_trips/cognitiveMap/landmark.cpp
routing/ai_router_trips/cognitiveMap/region.cpp
routing/ai_router_trips/cognitiveMap/landmarknetwork.cpp
routing/ai_router_trips/cognitiveMap/internnavigationnetwork.cpp
routing/ai_router_trips/perception/visualsystem.cpp
routing/ai_router_trips/perception/visibleenvironment.cpp
routing/ai_router_trips/perception/cgalgeometry.cpp
routing/ai_router_trips/perception/sign.cpp
routing/ai_router_trips/Cortex.cpp
#routing/ai_router_trips/AIRouterTrips.cpp
#routing/ai_router_trips/BrainStorage.cpp
#routing/ai_router_trips/cognitiveMap/associations.cpp
#routing/ai_router_trips/cognitiveMap/connection.cpp
#routing/ai_router_trips/cognitiveMap/cognitivemap.cpp
#routing/ai_router_trips/cognitiveMap/landmark.cpp
#routing/ai_router_trips/cognitiveMap/region.cpp
#routing/ai_router_trips/cognitiveMap/landmarknetwork.cpp
#routing/ai_router_trips/cognitiveMap/internnavigationnetwork.cpp
#routing/ai_router_trips/perception/visualsystem.cpp
#routing/ai_router_trips/perception/visibleenvironment.cpp
#routing/ai_router_trips/perception/cgalgeometry.cpp
#routing/ai_router_trips/perception/sign.cpp
#routing/ai_router_trips/Cortex.cpp
)
SET(AIROUTER_HDR
......
......@@ -75,10 +75,10 @@ bool GeoFileParser::LoadGeometry(Building* building)
return false;
}
if (xRootNode->Attribute("unit")) if (std::string(xRootNode->Attribute("unit"))!="m") {
Log->Write("ERROR:\tOnly the unit m (meters) is supported. \n\tYou supplied [%s]",
xRootNode->Attribute("unit"));
return false;
}
Log->Write("ERROR:\tOnly the unit m (meters) is supported. \n\tYou supplied [%s]",
xRootNode->Attribute("unit"));
return false;
}
double version = xmltof(xRootNode->Attribute("version"), -1);
......@@ -284,63 +284,49 @@ bool GeoFileParser::LoadGeometry(Building* building)
// all rooms are read, now proceed with transitions
TiXmlNode* xTransNode = xRootNode->FirstChild("transitions");
if (xTransNode)
{
for (TiXmlElement* xTrans = xTransNode->FirstChildElement("transition"); xTrans;
xTrans = xTrans->NextSiblingElement("transition")) {
int id = xmltoi(xTrans->Attribute("id"), -1);
// string caption = "door " + id;
std::string caption = "door ";
caption += std::to_string(id);
caption = xmltoa(xTrans->Attribute("caption"), caption.c_str());
int room1_id = xmltoi(xTrans->Attribute("room1_id"), -1);
int room2_id = xmltoi(xTrans->Attribute("room2_id"), -1);
int subroom1_id = xmltoi(xTrans->Attribute("subroom1_id"), -1);
int subroom2_id = xmltoi(xTrans->Attribute("subroom2_id"), -1);
std::string type = xmltoa(xTrans->Attribute("type"), "normal");
double x1 = xmltof(xTrans->FirstChildElement("vertex")->Attribute("px"));
double y1 = xmltof(xTrans->FirstChildElement("vertex")->Attribute("py"));
double x2 = xmltof(xTrans->LastChild("vertex")->ToElement()->Attribute("px"));
double y2 = xmltof(xTrans->LastChild("vertex")->ToElement()->Attribute("py"));
Transition* t = new Transition();
t->SetID(id);
t->SetCaption(caption);
t->SetPoint1(Point(x1, y1));
t->SetPoint2(Point(x2, y2));
t->SetType(type);
if (room1_id!=-1 && subroom1_id!=-1) {
//Room* room = _rooms[room1_id];
Room* room = building->GetRoom(room1_id);
SubRoom* subroom = room->GetSubRoom(subroom1_id);
//subroom->AddGoalID(t->GetUniqueID());
//MPI
room->AddTransitionID(t->GetUniqueID());
t->SetRoom1(room);
t->SetSubRoom1(subroom);
//new implementation
subroom->AddTransition(t);
Transition * t = parseTransitionNode(xTrans, building);
building->AddTransition(t);
}
TiXmlNode * xNodeFile = xTransNode->FirstChild("file");
if(xNodeFile)
{
std::string transFilename = xNodeFile->FirstChild()->ValueStr();
Log->Write("INFO:\tParsing transition from file <%s>", transFilename.c_str());
TiXmlDocument docTrans(transFilename);
if (!docTrans.LoadFile()) {
Log->Write("ERROR: \t%s", docTrans.ErrorDesc());
Log->Write("ERROR: \t could not parse the transitions file.");
return false;
}
if (room2_id!=-1 && subroom2_id!=-1) {
Room* room = building->GetRoom(room2_id);
SubRoom* subroom = room->GetSubRoom(subroom2_id);
//subroom->AddGoalID(t->GetUniqueID());
//MPI
room->AddTransitionID(t->GetUniqueID());
t->SetRoom2(room);
t->SetSubRoom2(subroom);
//new implementation
subroom->AddTransition(t);
TiXmlElement* xRootNodeTrans = docTrans.RootElement();
if (!xRootNodeTrans) {
Log->Write("ERROR:\tRoot element does not exist in transitions file.");
return false;
}
if (xRootNodeTrans->ValueStr() != "JPScore") {
Log->Write("ERROR:\tParsing transitions file. Root element value is not 'JPScore'.");
return false;
}
TiXmlNode* xTransNodeFile = xRootNodeTrans->FirstChild("transitions");
if (!xTransNodeFile) {
Log->Write("ERROR:\tNo Transitions in file found.");
return false;
}
for (TiXmlElement* xTrans = xTransNodeFile->FirstChildElement("transition"); xTrans;
xTrans = xTrans->NextSiblingElement("transition")) {
Transition * t = parseTransitionNode(xTrans, building);
building->AddTransition(t);
}
building->AddTransition(t);
}
else{
Log->Write("INFO:\tNot parsing transition from file %s");
}
Log->Write("INFO:\tGot %d transitions", building-> GetAllTransitions().size());
}// xTransNode
Log->Write("INFO: \tLoading building file successful!!!\n");
//everything went fine
......@@ -371,176 +357,154 @@ bool GeoFileParser::LoadRoutingInfo(Building* building)
//load goals and routes
TiXmlNode* xGoalsNode = xRootNode->FirstChild("routing")->FirstChild("goals");
if (xGoalsNode) {
// Trips trips;
// ---- parse goals from inifile
for (TiXmlElement* e = xGoalsNode->FirstChildElement("goal"); e;
e = e->NextSiblingElement("goal")) {
int id = xmltoi(e->Attribute("id"), -1);
int isFinal = std::string(e->Attribute("final"))=="true" ? true : false;
std::string caption = xmltoa(e->Attribute("caption"), "-1");
int room_id = xmltoi(e->Attribute("room_id"), -1);
int subroom_id = xmltoi(e->Attribute("subroom_id"), -1);
Goal* goal = new Goal();
goal->SetId(id);
goal->SetCaption(caption);
goal->SetIsFinalGoal(isFinal);
goal->SetRoomID(room_id);
goal->SetSubRoomID(subroom_id);
//looking for polygons (walls)
for (TiXmlElement* xPolyVertices = e->FirstChildElement("polygon"); xPolyVertices;
xPolyVertices = xPolyVertices->NextSiblingElement("polygon")) {
for (TiXmlElement* xVertex = xPolyVertices->FirstChildElement(
"vertex");
xVertex && xVertex!=xPolyVertices->LastChild("vertex");
xVertex = xVertex->NextSiblingElement("vertex")) {
double x1 = xmltof(xVertex->Attribute("px"));
double y1 = xmltof(xVertex->Attribute("py"));
double x2 = xmltof(xVertex->NextSiblingElement("vertex")->Attribute("px"));
double y2 = xmltof(xVertex->NextSiblingElement("vertex")->Attribute("py"));
goal->AddWall(Wall(Point(x1, y1), Point(x2, y2)));
}
Goal * goal = parseGoalNode(e);
if (goal) {
building->AddGoal(goal);
_configuration->GetRoutingEngine()->AddFinalDestinationID(goal->GetId());
}
if (!goal->ConvertLineToPoly())
return false;
building->AddGoal(goal);
_configuration->GetRoutingEngine()->AddFinalDestinationID(goal->GetId());
// trips.addGoal(goal->GetId());
}
// ---- parse waiting areas from inifile
for (TiXmlElement* e = xGoalsNode->FirstChildElement("waiting_area"); e;
e = e->NextSiblingElement("waiting_area")) {
// Read valus from ini File
int id = xmltoi(e->Attribute("id"), -1);
int min_peds = xmltoi(e->Attribute("min_peds"), -1);
int max_peds = xmltoi(e->Attribute("max_peds"), -1);
int waiting_time = xmltoi(e->Attribute("waiting_time"), -1);
int transition_id = xmltoi(e->Attribute("transition_id"), -1);
int room_id = xmltoi(e->Attribute("room_id"), -1);
int subroom_id = xmltoi(e->Attribute("subroom_id"), -1);
bool open = strcmp(xmltoa(e->Attribute("is_open"), "false"), "true") == 0;
bool global_timer = strcmp(xmltoa(e->Attribute("global_timer"), "false"), "true") == 0;
std::string caption = xmltoa(e->Attribute("caption"), "-1");
Goal* wa = new WaitingArea();
WaitingArea* waitingArea = static_cast<WaitingArea*>(wa);
waitingArea->SetIsFinalGoal(0);
waitingArea->SetId(id);
waitingArea->SetCaption(caption);
waitingArea->setOpen(open);
waitingArea->setGlobalTimer(global_timer);
waitingArea->setMinNumPed(min_peds);
waitingArea->setMaxNumPed(max_peds);
waitingArea->setWaitingTime(waiting_time);
waitingArea->setTransitionID(transition_id);
waitingArea->SetRoomID(room_id);
waitingArea->SetSubRoomID(subroom_id);
std::map<int, double> nextGoals;
//looking for next_wa
for (TiXmlElement* nextWa = e->FirstChildElement("next_wa"); nextWa;
nextWa = nextWa->NextSiblingElement("next_wa")) {
int nextWaId = xmltoi(nextWa->Attribute("id"));
double nextWaP = xmltof(nextWa->Attribute("p"));
nextGoals.insert(std::pair<int, double>(nextWaId, nextWaP));
Goal * goal = parseWaitingAreaNode(e);
if (goal) {
building->AddGoal(goal);
_configuration->GetRoutingEngine()->AddFinalDestinationID(goal->GetId());
}
if (!waitingArea->setNextGoals(nextGoals)){
std::cout << "wa setNextGoals!";
}
// ---- parse goals/waiting areas from external file
TiXmlNode* xGoalsNodeFile = xGoalsNode->FirstChild("file");
if(xGoalsNodeFile)
{
std::string goalFilename = xGoalsNodeFile->FirstChild()->ValueStr();
Log->Write("INFO:\tGoal file <%s> will be parsed", goalFilename.c_str());
TiXmlDocument docGoal(goalFilename);
if (!docGoal.LoadFile()) {
Log->Write("ERROR: \t%s", docGoal.ErrorDesc());
Log->Write("ERROR: \t could not parse the goal file.");
return false;
};
//looking for polygons (walls)
for (TiXmlElement* xPolyVertices = e->FirstChildElement("polygon"); xPolyVertices;
xPolyVertices = xPolyVertices->NextSiblingElement("polygon")) {
for (TiXmlElement* xVertex = xPolyVertices->FirstChildElement(
"vertex");
xVertex && xVertex!=xPolyVertices->LastChild("vertex");
xVertex = xVertex->NextSiblingElement("vertex")) {
double x1 = xmltof(xVertex->Attribute("px"));
double y1 = xmltof(xVertex->Attribute("py"));
double x2 = xmltof(xVertex->NextSiblingElement("vertex")->Attribute("px"));
double y2 = xmltof(xVertex->NextSiblingElement("vertex")->Attribute("py"));
wa->AddWall(Wall(Point(x1, y1), Point(x2, y2)));
}
TiXmlElement* xRootNodeGoal = docGoal.RootElement();
if (!xRootNodeGoal) {
Log->Write("ERROR:\tRoot element does not exist in goal file.");
return false;
}
if (xRootNodeGoal->ValueStr() != "JPScore") {
Log->Write("ERROR:\tParsing goal file. Root element value is not 'JPScore'.");
return false;
}
TiXmlNode* xGoal = xRootNodeGoal->FirstChild("goals");
if (!xGoal) {
Log->Write("ERROR:\tNo Goals in file found.");
return false;
}
for (TiXmlElement* e = xGoal->FirstChildElement("goal"); e;
e = e->NextSiblingElement("goal")) {
Goal * goal = parseGoalNode(e);
if (goal) {
building->AddGoal(goal);
_configuration->GetRoutingEngine()->AddFinalDestinationID(goal->GetId());
}
}
if (!waitingArea->ConvertLineToPoly()){
std::cout << "wa convertLineToPoly!";
return false;
for (TiXmlElement* e = xGoal->FirstChildElement("waiting_area"); e;
e = e->NextSiblingElement("waiting_area")) {
Goal * goal = parseWaitingAreaNode(e);
if (goal) {
building->AddGoal(goal);
_configuration->GetRoutingEngine()->AddFinalDestinationID(goal->GetId());
}
}
// for (auto& room : building->GetAllRooms()){
// for (auto& subroomMap : room.second->GetAllSubRooms()){
// std::cout << "check if wa " << wa->GetId() << " is in subroom " << subroomMap.second->GetSubRoomID() << std::endl;
// std::cout << "wa centroid " << wa->GetCentroid().toString() << std::endl;
//
// if (subroomMap.second->IsInSubRoom(wa->GetCentroid()) || subroomMap.second->GetSubRoomID() == 3){
// subroomMap.second->AddGoalID(wa->GetId());
// }
// }
// }
building->AddGoal(wa);
_configuration->GetRoutingEngine()->AddFinalDestinationID(wa->GetId());
}
// building->AddTrip(trips);
// _configuration->GetRoutingEngine()->AddTrip(trips);
else
Log->Write("INFO:\tGoal file not parsed");
} //xgoalsNode
Log->Write("INFO:\tdone with loading extra routing information");
return true;
}
bool GeoFileParser::parseDoorNode(TiXmlElement * xDoor, int id, Building* building)
{
bool result = false;// this return value is not needed.
// maybe in the future it might be...
std::string str("INFO:\tParsed Door: \n");
char tmp[100];
sprintf(tmp, "\t>> ID: %d\n", id);
str.append(tmp);
//------------------ state
std::string stateStr = xmltoa(xDoor->Attribute("state"), "open");
DoorState state = StringToDoorState(stateStr);
//store transition in a map and call getTransition/getCrossing
switch (state) {
case DoorState::OPEN:
building->GetTransition(id)->Open();
break;
case DoorState::CLOSE:
building->GetTransition(id)->Close();
break;
case DoorState::TEMP_CLOSE:
building->GetTransition(id)->TempClose();
break;
case DoorState::ERROR:
Log->Write("WARNING:\t Unknown door state: <%s>. open or close. Default: open",
stateStr.c_str());
building->GetTransition(id)->Open();
break;
}
sprintf(tmp, "\t>> state: %s\n", stateStr.c_str());
str.append(tmp);
//------------------ outflow
double outflow = xmltof(xDoor->Attribute("outflow"), -1.0);
if(outflow >= 0)
{
building->GetTransition(id)->SetOutflowRate(outflow);
sprintf(tmp, "\t>> ouflow: %.2f\n", outflow);
str.append(tmp);
}
//----------------- dt
double DT = xmltof(xDoor->Attribute("dt"), -1.0);
if(DT >= 0)
{
building->GetTransition(id)->SetDT(DT);
}
//----------------- dn
int DN = xmltof(xDoor->Attribute("dn"), -1.0);
if(DN >= 0)
{
building->GetTransition(id)->SetDN(DN);
sprintf(tmp, "\t>> dn: %d\n", DN);
str.append(tmp);
}
//load routes
// TiXmlNode* xTripsNode = xRootNode->FirstChild("routing")->FirstChild("routes");
//
// if (xTripsNode)
// for (TiXmlElement* trip = xTripsNode->FirstChildElement("route"); trip;
// trip = trip->NextSiblingElement("route")) {
//
// double id = xmltof(trip->Attribute("id"), -1);
// if (id==-1) {
// Log->Write("ERROR:\t id missing for trip");
// return false;
// }
// std::string sTrip = trip->FirstChild()->ValueStr();
// std::vector<std::string> vTrip;
// vTrip.clear();
//
// char* str = (char*) sTrip.c_str();
// char* p = strtok(str, ":");
// while (p) {
// vTrip.push_back(xmltoa(p));
// p = strtok(NULL, ":");
// }
// _configuration->GetRoutingEngine()->AddTrip(vTrip);
// }
Log->Write("INFO:\tdone with loading extra routing information");
return true;
//------------------ max door usage
int mdu = xmltof(xDoor->Attribute("max_agents"), -1);
if(mdu >= 0)
{
building->GetTransition(id)->SetMaxDoorUsage(mdu);
sprintf(tmp, "\t>> max_agents: %d\n", mdu);
str.append(tmp);
}
//-----------------
Log->Write(str);
result = true;
return result;
}
bool GeoFileParser::LoadTrafficInfo(Building* building)
{
Log->Write("INFO:\tLoading the traffic info file");
Log->Write("INFO:\tLoading the traffic info");
TiXmlDocument doc(_configuration->GetProjectFile());
if (!doc.LoadFile()) {
......@@ -566,111 +530,257 @@ bool GeoFileParser::LoadTrafficInfo(Building* building)
RoomState status = (state=="good") ? ROOM_CLEAN : ROOM_SMOKED;
building->GetRoom(id)->SetState(status);
}
else
Log->Write("Info:\t no room info found in inifile");
//processing the doors node
TiXmlNode* xDoorsNode = xRootNode->FirstChild("doors");
if (xDoorsNode)
if(xDoorsNode)
{
bool res_parseDoor;
for (TiXmlElement* xDoor = xDoorsNode->FirstChildElement("door"); xDoor;
xDoor = xDoor->NextSiblingElement("door")) {
int id = xmltoi(xDoor->Attribute("trans_id"), -1);
if (id!=-1) {
std::string str("INFO:\tParsed Door: \n");
char tmp[100];
sprintf(tmp, "\t>> ID: %d\n", id);
str.append(tmp);
//------------------ state
std::string stateStr = xmltoa(xDoor->Attribute("state"), "open");
DoorState state = StringToDoorState(stateStr);
//store transition in a map and call getTransition/getCrossing
switch (state) {
case DoorState::OPEN:
building->GetTransition(id)->Open();
break;
case DoorState::CLOSE:
building->GetTransition(id)->Close();
break;
case DoorState::TEMP_CLOSE:
building->GetTransition(id)->TempClose();
break;
case DoorState::ERROR:
Log->Write("WARNING:\t Unknown door state: <%s>. open or close. Default: open",
stateStr.c_str());
building->GetTransition(id)->Open();
break;
}
// if (state=="open") {
// building->GetTransition(id)->Open();
// }
// else if (state=="close") {
// building->GetTransition(id)->Close();
// }
// else {
// Log->Write("WARNING:\t Unknown door state: <%s>. open or close. Default: open", state.c_str());
// }
// }
sprintf(tmp, "\t>> state: %s\n", stateStr.c_str());
str.append(tmp);
//------------------ outflow
double outflow = xmltof(xDoor->Attribute("outflow"), -1.0);
if(outflow >= 0)
{
building->GetTransition(id)->SetOutflowRate(outflow);
sprintf(tmp, "\t>> ouflow: %.2f\n", outflow);
str.append(tmp);
}
//----------------- dt
double DT = xmltof(xDoor->Attribute("dt"), -1.0);
if(DT >= 0)
{
building->GetTransition(id)->SetDT(DT);
}
//----------------- dn
int DN = xmltof(xDoor->Attribute("dn"), -1.0);
if(DN >= 0)
{
building->GetTransition(id)->SetDN(DN);
sprintf(tmp, "\t>> dn: %d\n", DN);
str.append(tmp);
}
//------------------ max door usage
int mdu = xmltof(xDoor->Attribute("max_agents"), -1);
if(mdu >= 0)
{
building->GetTransition(id)->SetMaxDoorUsage(mdu);
sprintf(tmp, "\t>> max_agents: %d\n", mdu);
str.append(tmp);
}
//-----------------
Log->Write(str);
if (id!=-1 && building->GetTransition(id)) {
res_parseDoor = parseDoorNode(xDoor, id, building);
if(!res_parseDoor)
return false;
}
else {
id = xmltoi(xDoor->Attribute("cross_id"), -1);
if (id!=-1) {
std::string state = xmltoa(xDoor->Attribute("state"), "open");
//store transition in a map and call getTransition/getCrossin
if (state=="open") {
building->GetCrossing(id)->Open();
}
else if (state=="close") {
building->GetCrossing(id)->Close();
}
else {
Log->Write("WARNING:\t Unknown door state: %s", state.c_str());
}
}//for xDoor
}
else
Log->Write("Info:\t no door info found in inifile");
// processing file node
TiXmlNode* xFileNode = xRootNode->FirstChild("file");
if(xFileNode)
{
std::string trafficFilename = xFileNode->FirstChild()->ValueStr();
Log->Write("Info:\t traffic file found <%s>", trafficFilename.c_str());
TiXmlDocument docTraffic(trafficFilename);
if (!docTraffic.LoadFile()) {
Log->Write("ERROR: \t%s", docTraffic.ErrorDesc());
Log->Write("ERROR: \t could not parse the traffic file.");
return false;
}
TiXmlElement* xRootNodeTraffic = docTraffic.RootElement();
if (!xRootNodeTraffic) {
Log->Write("ERROR:\tRoot element does not exist.");
return false;
}
if (xRootNodeTraffic->ValueStr() != "JPScore") {
Log->Write("ERROR:\tRoot element value is not 'JPScore'.");
return false;
}
TiXmlNode* xTraffic = xRootNodeTraffic->FirstChild("traffic_constraints");
if (!xTraffic) {
Log->Write("ERROR:\tNo traffic constraints in file found.");
return false;
}
TiXmlNode* xDoorsNodeF = xTraffic->FirstChild("doors");
if(xDoorsNodeF)
{
bool res_parseDoor;
for (TiXmlElement* xDoor = xDoorsNodeF->FirstChildElement("door"); xDoor;
xDoor = xDoor->NextSiblingElement("door")) {
int id = xmltoi(xDoor->Attribute("trans_id"), -1);
if (id!=-1 && building->GetTransition(id)) {
res_parseDoor = parseDoorNode(xDoor, id, building);
if(!res_parseDoor)
return false;
}
else
Log->Write("WARNING:\t Unknown door id");
}
}//for xDoor
}
else
Log->Write("Info:\t no door info found in traffic file");
}
else
Log->Write("Info:\t no traffic file found.");
Log->Write("INFO:\tDone with loading traffic info file");
return true;
}
Transition* GeoFileParser::parseTransitionNode(TiXmlElement * xTrans, Building * building)
{
int id = xmltoi(xTrans->Attribute("id"), -1);
// string caption = "door " + id;
std::string caption = "door ";
caption += std::to_string(id);
caption = xmltoa(xTrans->Attribute("caption"), caption.c_str());
int room1_id = xmltoi(xTrans->Attribute("room1_id"), -1);
int room2_id = xmltoi(xTrans->Attribute("room2_id"), -1);
int subroom1_id = xmltoi(xTrans->Attribute("subroom1_id"), -1);
int subroom2_id = xmltoi(xTrans->Attribute("subroom2_id"), -1);
std::string type = xmltoa(xTrans->Attribute("type"), "normal");
double x1 = xmltof(xTrans->FirstChildElement("vertex")->Attribute("px"));
double y1 = xmltof(xTrans->FirstChildElement("vertex")->Attribute("py"));
double x2 = xmltof(xTrans->LastChild("vertex")->ToElement()->Attribute("px"));
double y2 = xmltof(xTrans->LastChild("vertex")->ToElement()->Attribute("py"));
Transition* t = new Transition();
t->SetID(id);
t->SetCaption(caption);
t->SetPoint1(Point(x1, y1));
t->SetPoint2(Point(x2, y2));
t->SetType(type);
//--- danger area
if (room1_id!=-1 && subroom1_id!=-1) {
//Room* room = _rooms[room1_id];
Room* room = building->GetRoom(room1_id);
SubRoom* subroom = room->GetSubRoom(subroom1_id);
//subroom->AddGoalID(t->GetUniqueID());
//MPI
room->AddTransitionID(t->GetUniqueID());
t->SetRoom1(room);
t->SetSubRoom1(subroom);
//new implementation
subroom->AddTransition(t);
}
if (room2_id!=-1 && subroom2_id!=-1) {
Room* room = building->GetRoom(room2_id);
SubRoom* subroom = room->GetSubRoom(subroom2_id);
//subroom->AddGoalID(t->GetUniqueID());
//MPI
room->AddTransitionID(t->GetUniqueID());
t->SetRoom2(room);
t->SetSubRoom2(subroom);
//new implementation
subroom->AddTransition(t);
}
return t;
}
Goal* GeoFileParser::parseGoalNode(TiXmlElement * e)
{
Log->Write("INFO:\tLoading goal");
int id = xmltoi(e->Attribute("id"), -1);
int isFinal = std::string(e->Attribute("final"))=="true" ? true : false;
std::string caption = xmltoa(e->Attribute("caption"), "-1");
int room_id = xmltoi(e->Attribute("room_id"), -1);
int subroom_id = xmltoi(e->Attribute("subroom_id"), -1);
Log->Write("INFO:\t Goal id: %d", id);
Log->Write("INFO:\t Goal caption: %s", caption.c_str());
Log->Write("INFO:\t Goal room_id: %d", room_id);
Log->Write("INFO:\t Goal subroom_id: %d", subroom_id);
Goal* goal = new Goal();
goal->SetId(id);
goal->SetCaption(caption);
goal->SetIsFinalGoal(isFinal);
goal->SetRoomID(room_id);
goal->SetSubRoomID(subroom_id);
//looking for polygons (walls)
for (TiXmlElement* xPolyVertices = e->FirstChildElement("polygon"); xPolyVertices;
xPolyVertices = xPolyVertices->NextSiblingElement("polygon")) {
for (TiXmlElement* xVertex = xPolyVertices->FirstChildElement(