diff --git a/Simulation.cpp b/Simulation.cpp index 579cd8f7cea7745837ff613d957109dc49e40929..bf228b774a9263009b18ad061ab60596e4e974f0 100644 --- a/Simulation.cpp +++ b/Simulation.cpp @@ -352,7 +352,7 @@ void Simulation::UpdateRoutesAndLocations() //set the new room if needed if ((ped->GetFinalDestination() == FINAL_DEST_OUT) - && (room->GetCaption() == "outside")) { //TODO Hier aendern fuer inside goals? + && (room->GetCaption() == "outside")) { //TODO Hier aendern fuer inside goals? #pragma omp critical(Simulation_Update_pedsToRemove) pedsToRemove.insert(ped); } else if ((ped->GetFinalDestination() != FINAL_DEST_OUT) @@ -575,43 +575,37 @@ double Simulation::RunBody(double maxSimTime) //here we could place router-tasks (calc new maps) that can use multiple cores AND we have 't' //update quickestRouter - if (_routingEngine.get()->GetRouter(ROUTING_FF_QUICKEST)) { - if(geometryChanged) - { - FFRouter* ffrouter2 = dynamic_cast(_routingEngine.get()->GetRouter(ROUTING_FF_QUICKEST)); - ffrouter2->Init(_building.get()); - // debug - fs::path f("tmp_"+std::to_string(t)+"_"+_config->GetGeometryFile()); - std::string filename = f.string(); - std::cout << "\nUpdate geometry. New geometry --> " << filename.c_str() << "\n"; - - std::cout<< KGRN << "Enter correctGeometry: Building Has " << _building->GetAllTransitions().size() << " Transitions\n" << RESET; - _building->SaveGeometry(filename); - // - double _deltaH = _building->GetConfig()->get_deltaH(); - double _wallAvoidDistance = _building->GetConfig()->get_wall_avoid_distance(); - bool _useWallAvoidance = _building->GetConfig()->get_use_wall_avoidance(); - - if(auto dirlocff = dynamic_cast(_building->GetConfig()->get_dirStrategy())){ - Log->Write("INFO:\t Init DirectionLOCALFloorfield starting ..."); - dirlocff->Init(_building.get(), _deltaH, _wallAvoidDistance, _useWallAvoidance); - Log->Write("INFO:\t Init DirectionLOCALFloorfield done"); - } - - - std::cout << KBLU << " Init router in simulation\n" << RESET; - } - else{ - FFRouter* ffrouter = dynamic_cast(_routingEngine.get()->GetRouter(ROUTING_FF_QUICKEST)); - if (ffrouter->MustReInit()) { - ffrouter->ReInit(); - ffrouter->SetRecalc(t); - } + if(geometryChanged) + { + // debug + fs::path f("tmp_"+std::to_string(t)+"_"+_config->GetGeometryFile()); + std::string filename = f.string(); + std::cout << "\nUpdate geometry. New geometry --> " << filename.c_str() << "\n"; + + std::cout<< KGRN << "Enter correctGeometry: Building Has " << _building->GetAllTransitions().size() << " Transitions\n" << RESET; + _building->SaveGeometry(filename); + // + double _deltaH = _building->GetConfig()->get_deltaH(); + double _wallAvoidDistance = _building->GetConfig()->get_wall_avoid_distance(); + bool _useWallAvoidance = _building->GetConfig()->get_use_wall_avoidance(); + + if(auto dirlocff = dynamic_cast(_building->GetConfig()->get_dirStrategy())){ + Log->Write("INFO:\t Init DirectionLOCALFloorfield starting ..."); + dirlocff->Init(_building.get(), _deltaH, _wallAvoidDistance, _useWallAvoidance); + Log->Write("INFO:\t Init DirectionLOCALFloorfield done"); + } } + else{ // quickest needs update even if NeedsUpdate() is false + FFRouter* ffrouter = dynamic_cast(_routingEngine.get()->GetRouter(ROUTING_FF_QUICKEST)); + if (ffrouter->MustReInit()) { + ffrouter->ReInit(); + ffrouter->SetRecalc(t); + } } // here the used routers are update, when needed due to external changes if (_routingEngine->NeedsUpdate()){ + std::cout << KBLU << " Init router in simulation\n" << RESET; _routingEngine->UpdateRouter(); } diff --git a/routing/ff_router/ffRouter.cpp b/routing/ff_router/ffRouter.cpp index 3348c7e55b3e1555f2a3e79245708a18dfa27959..ec6dafb0089ece8a70d68268c2c970dfca765f65 100644 --- a/routing/ff_router/ffRouter.cpp +++ b/routing/ff_router/ffRouter.cpp @@ -322,6 +322,44 @@ bool FFRouter::ReInit() _distMatrix.clear(); _pathsMatrix.clear(); + // Geommetry may change dure to trains or whatever happens in the future + //get all door UIDs + _allDoorUIDs.clear(); + _TransByUID.clear(); + _ExitsByUID.clear(); + _CroTrByUID.clear(); + auto& allTrans = _building->GetAllTransitions(); + auto& allCross = _building->GetAllCrossings(); + std::vector> roomAndCroTrVector; + roomAndCroTrVector.clear(); + for (auto& pair:allTrans) { + //TODO if (pair.second->IsOpen()) { + if (!pair.second->IsClose()) { + _allDoorUIDs.emplace_back(pair.second->GetUniqueID()); + _CroTrByUID.insert(std::make_pair(pair.second->GetUniqueID(), pair.second)); + if (pair.second->IsExit()) { + _ExitsByUID.insert(std::make_pair(pair.second->GetUniqueID(), pair.second)); + } + Room* room1 = pair.second->GetRoom1(); + if (room1) roomAndCroTrVector.emplace_back(std::make_pair(room1->GetID(), pair.second->GetUniqueID())); + Room* room2 = pair.second->GetRoom2(); + if (room2) roomAndCroTrVector.emplace_back(std::make_pair(room2->GetID(), pair.second->GetUniqueID())); + } + } + for (auto& pair:allCross) { + //TODO if (pair.second->IsOpen()) { + if (!pair.second->IsClose()) { + _allDoorUIDs.emplace_back(pair.second->GetUniqueID()); + _CroTrByUID.insert(std::make_pair(pair.second->GetUniqueID(), pair.second)); + Room* room1 = pair.second->GetRoom1(); + if (room1) roomAndCroTrVector.emplace_back(std::make_pair(room1->GetID(), pair.second->GetUniqueID())); + } + } + //make unique + std::sort(_allDoorUIDs.begin(), _allDoorUIDs.end()); + _allDoorUIDs.erase( std::unique(_allDoorUIDs.begin(),_allDoorUIDs.end()), _allDoorUIDs.end()); + +// alldoorUIDs reinit //init, yet no distances, only create map entries for(auto& id1 : _allDoorUIDs) { for(auto& id2 : _allDoorUIDs){