Commit fd7c8519 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Save commputation when there is only one alternative

parent 3cd4941f
...@@ -828,25 +828,33 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) ...@@ -828,25 +828,33 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped)
//double normFactor=0.0; //double normFactor=0.0;
//map <int, double> doorProb; //map <int, double> doorProb;
// get the opened exits
SubRoom* sub = _building->GetRoom(ped->GetRoomID())->GetSubRoom(
ped->GetSubRoomID());
// get the relevant opened exits // get the relevant opened exits
vector <AccessPoint*> relevantAPs; vector <AccessPoint*> relevantAPs;
GetRelevantRoutesTofinalDestination(ped,relevantAPs); GetRelevantRoutesTofinalDestination(ped,relevantAPs);
//cout<<"relevant APs size:" <<relevantAPs.size()<<endl; //cout<<"relevant APs size:" <<relevantAPs.size()<<endl;
//in the case there is only one alternative
//save some computation
if(relevantAPs.size()==1)
{
auto&& ap=relevantAPs[0];
ped->SetExitIndex(ap->GetID());
ped->SetExitLine(ap->GetNavLine());
return ap->GetID();
}
int bestAPsID = -1; int bestAPsID = -1;
double minDistGlobal = FLT_MAX; double minDistGlobal = FLT_MAX;
double minDistLocal = FLT_MAX; double minDistLocal = FLT_MAX;
// get the opened exits
SubRoom* sub = _building->GetRoom(ped->GetRoomID())->GetSubRoom(
ped->GetSubRoomID());
//for (unsigned int i = 0; i < accessPointsInSubRoom.size(); i++) { //for (unsigned int i = 0; i < accessPointsInSubRoom.size(); i++) {
// int apID = accessPointsInSubRoom[i]; // int apID = accessPointsInSubRoom[i];
for(unsigned int g=0; g<relevantAPs.size(); g++) { for(unsigned int g=0; g<relevantAPs.size(); g++)
{
AccessPoint* ap=relevantAPs[g]; AccessPoint* ap=relevantAPs[g];
//int exitid=ap->GetID();
//AccessPoint* ap = _accessPoints[apID];
if (ap->isInRange(sub->GetUID()) == false) if (ap->isInRange(sub->GetUID()) == false)
continue; continue;
...@@ -863,7 +871,6 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped) ...@@ -863,7 +871,6 @@ int GlobalRouter::GetBestDefaultRandomExit(Pedestrian* ped)
//check if visible //check if visible
if (sub->IsVisible(posA, posC, true) == false) { if (sub->IsVisible(posA, posC, true) == false) {
ped->RerouteIn(10); ped->RerouteIn(10);
//ped->Dump(ped->GetID());
continue; continue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment