Changed to ReInit router

geometries may change during simulation
parent 268285f1
......@@ -575,11 +575,8 @@ 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<FFRouter*>(_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();
......@@ -597,21 +594,18 @@ double Simulation::RunBody(double maxSimTime)
dirlocff->Init(_building.get(), _deltaH, _wallAvoidDistance, _useWallAvoidance);
Log->Write("INFO:\t Init DirectionLOCALFloorfield done");
}
std::cout << KBLU << " Init router in simulation\n" << RESET;
}
else{
else{ // quickest needs update even if NeedsUpdate() is false
FFRouter* ffrouter = dynamic_cast<FFRouter*>(_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();
}
......
......@@ -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<std::pair<int, int>> 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){
......
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