Skip to content
Snippets Groups Projects
Commit c132e6bd authored by Arne Graf's avatar Arne Graf
Browse files

fixed 249 by using correct IsInSubRoom(...)

parent 1d36b4fd
Branches
Tags
1 merge request!10Develop
Pipeline #
...@@ -1358,6 +1358,9 @@ void UnivFFviaFM::writeFF(const std::string& filename, std::vector<int> targetID ...@@ -1358,6 +1358,9 @@ void UnivFFviaFM::writeFF(const std::string& filename, std::vector<int> targetID
//mode is argument, which should not be needed, the info is stored in members like speedmode, ... //mode is argument, which should not be needed, the info is stored in members like speedmode, ...
double UnivFFviaFM::getCostToDestination(const int destID, const Point& position, int mode) { double UnivFFviaFM::getCostToDestination(const int destID, const Point& position, int mode) {
// if (!_grid->includesPoint(position)) {
// Log->Write("Was ist denn hier los?");
// }
assert(_grid->includesPoint(position)); assert(_grid->includesPoint(position));
if (_costFieldWithKey.count(destID)==1 && _costFieldWithKey[destID]) { if (_costFieldWithKey.count(destID)==1 && _costFieldWithKey[destID]) {
return _costFieldWithKey[destID][_grid->getKeyAtPoint(position)]; return _costFieldWithKey[destID][_grid->getKeyAtPoint(position)];
...@@ -1370,7 +1373,7 @@ double UnivFFviaFM::getCostToDestination(const int destID, const Point& position ...@@ -1370,7 +1373,7 @@ double UnivFFviaFM::getCostToDestination(const int destID, const Point& position
} }
addTarget(destID, _costFieldWithKey[destID], _directionFieldWithKey[destID]); addTarget(destID, _costFieldWithKey[destID], _directionFieldWithKey[destID]);
getCostToDestination(destID, position, mode); return getCostToDestination(destID, position, mode);
} else if (!_directCalculation && _doors.count(destID) > 0) { } else if (!_directCalculation && _doors.count(destID) > 0) {
//omp critical //omp critical
#pragma omp critical(UnivFFviaFM_toDo) #pragma omp critical(UnivFFviaFM_toDo)
......
...@@ -456,59 +456,77 @@ int FFRouter::FindExit(Pedestrian* p) ...@@ -456,59 +456,77 @@ int FFRouter::FindExit(Pedestrian* p)
if (_building->GetRoom(p->GetRoomID())->GetSubRoom(p->GetSubRoomID())->IsInSubRoom(p->GetPos())) { if (_building->GetRoom(p->GetRoomID())->GetSubRoom(p->GetSubRoomID())->IsInSubRoom(p->GetPos())) {
//ped is in the subroom, according to its member attribs //ped is in the subroom, according to its member attribs
} else { } else {
// find next crossing / transition and set new room to the OTHER bool located = false;
//candidates of current room (ID) (provided by Room) SubRoom* oldSubRoom = _building->GetRoom(p->GetRoomID())->GetSubRoom(p->GetSubRoomID());
for (auto transUID : _building->GetRoom(p->GetRoomID())->GetAllTransitionsIDs()) { for (auto& room : _building->GetAllRooms()) {
if ((_CroTrByUID.count(transUID) != 0) && (_CroTrByUID[transUID]->IsOpen())) { if (located) {break;}
DoorUIDsOfRoom.emplace_back(transUID); for (auto& subroom : room.second->GetAllSubRooms()) {
} if (subroom.second->IsInSubRoom(p->GetPos()) && subroom.second->IsDirectlyConnectedWith(oldSubRoom)) {
} //maybe room on wrong floor
for (auto &subIPair : _building->GetRoom(p->GetRoomID())->GetAllSubRooms()) { p->SetRoomID(room.second->GetID(), room.second->GetCaption());
for (auto &crossI : subIPair.second->GetAllCrossings()) { p->SetSubRoomID(subroom.second->GetSubRoomID());
if (crossI->IsOpen()) { p->SetSubRoomUID(subroom.second->GetUID());
DoorUIDsOfRoom.emplace_back(crossI->GetUniqueID()); located = true;
} break;
} }
} }
//find closest Door }
int UIDofLinePedStandsOn; if (!located) { //ped is outside
double UIDsDistance = DBL_MAX; return -1;
for (auto dooruid : DoorUIDsOfRoom) { }
if (UIDsDistance > _locffviafm[p->GetRoomID()]->getCostToDestination(dooruid, p->GetPos(), _mode)) { // // find next crossing / transition and set new room to the OTHER
UIDofLinePedStandsOn = dooruid; // //candidates of current room (ID) (provided by Room)
UIDsDistance = _locffviafm[p->GetRoomID()]->getCostToDestination(dooruid, p->GetPos(), _mode); // for (auto transUID : _building->GetRoom(p->GetRoomID())->GetAllTransitionsIDs()) {
} // if ((_CroTrByUID.count(transUID) != 0) && (_CroTrByUID[transUID]->IsOpen())) {
} // DoorUIDsOfRoom.emplace_back(transUID);
// }
//to that doors, find the (room/subroom) tuples of both sides of the door and then choose the one, that is not // }
//equal to "pedTupel" (which is false information). // for (auto &subIPair : _building->GetRoom(p->GetRoomID())->GetAllSubRooms()) {
//@todo: @ar.graf: if no second tupel exists, and pedTupel is false, the agent must be outside, right? // for (auto &crossI : subIPair.second->GetAllCrossings()) {
std::pair<int, int> pedTupel = std::make_pair(p->GetRoomID(), p->GetSubRoomID()); // if (crossI->IsOpen()) {
// DoorUIDsOfRoom.emplace_back(crossI->GetUniqueID());
std::pair<int, int> roomNsub1 = std::make_pair( // }
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetRoomID(), // }
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetSubRoomID()); // }
std::pair<int, int> roomNsub2; // //find closest Door
if (_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()) { // int UIDofLinePedStandsOn;
roomNsub2 = std::make_pair( // double UIDsDistance = DBL_MAX;
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()->GetRoomID(), // for (auto dooruid : DoorUIDsOfRoom) {
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()->GetSubRoomID()); // if (UIDsDistance > _locffviafm[p->GetRoomID()]->getCostToDestination(dooruid, p->GetPos(), _mode)) {
} else { // if no second exists, then door leads to outside and nothing should change, which we do by roomNsub1 == roomNsub2 // UIDofLinePedStandsOn = dooruid;
roomNsub2 = std::make_pair( // UIDsDistance = _locffviafm[p->GetRoomID()]->getCostToDestination(dooruid, p->GetPos(), _mode);
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetRoomID(), // }
_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetSubRoomID()); // }
} //
if (pedTupel == roomNsub1) { // //to that doors, find the (room/subroom) tuples of both sides of the door and then choose the one, that is not
p->SetRoomID(roomNsub2.first, _building->GetRoom(roomNsub2.first)->GetCaption()); // //equal to "pedTupel" (which is false information).
p->SetSubRoomID(roomNsub2.second); // //@todo: @ar.graf: if no second tupel exists, and pedTupel is false, the agent must be outside, right?
p->SetSubRoomUID(_building->GetRoom(roomNsub2.first)->GetSubRoom(roomNsub2.second)->GetUID()); // std::pair<int, int> pedTupel = std::make_pair(p->GetRoomID(), p->GetSubRoomID());
} else { //
p->SetRoomID(roomNsub1.first, _building->GetRoom(roomNsub1.first)->GetCaption()); // std::pair<int, int> roomNsub1 = std::make_pair(
p->SetSubRoomID(roomNsub1.second); // _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetRoomID(),
p->SetSubRoomUID(_building->GetRoom(roomNsub1.first)->GetSubRoom(roomNsub1.second)->GetUID()); // _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetSubRoomID());
} // std::pair<int, int> roomNsub2;
// if (_building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()) {
//Log->Write("ERROR: \tffRouter cannot handle incorrect room/subroom attribs of pedestrian %d!!", p->GetID()); // roomNsub2 = std::make_pair(
// _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()->GetRoomID(),
// _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom2()->GetSubRoomID());
// } else { // if no second exists, then door leads to outside and nothing should change, which we do by roomNsub1 == roomNsub2
// roomNsub2 = std::make_pair(
// _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetRoomID(),
// _building->GetTransOrCrossByUID(UIDofLinePedStandsOn)->GetSubRoom1()->GetSubRoomID());
// }
// if (pedTupel == roomNsub1) {
// p->SetRoomID(roomNsub2.first, _building->GetRoom(roomNsub2.first)->GetCaption());
// p->SetSubRoomID(roomNsub2.second);
// p->SetSubRoomUID(_building->GetRoom(roomNsub2.first)->GetSubRoom(roomNsub2.second)->GetUID());
// } else {
// p->SetRoomID(roomNsub1.first, _building->GetRoom(roomNsub1.first)->GetCaption());
// p->SetSubRoomID(roomNsub1.second);
// p->SetSubRoomUID(_building->GetRoom(roomNsub1.first)->GetSubRoom(roomNsub1.second)->GetUID());
// }
//
// //Log->Write("ERROR: \tffRouter cannot handle incorrect room/subroom attribs of pedestrian %d!!", p->GetID());
} }
DoorUIDsOfRoom.clear(); DoorUIDsOfRoom.clear();
if (!_targetWithinSubroom) { if (!_targetWithinSubroom) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment