Remove trans also from Building

parent 0803b675
Pipeline #21039 passed with stages
in 9 minutes and 20 seconds
...@@ -504,132 +504,128 @@ bool Building::resetGeometry(std::shared_ptr<TrainTimeTable> tab) ...@@ -504,132 +504,128 @@ bool Building::resetGeometry(std::shared_ptr<TrainTimeTable> tab)
{ {
// this function is composed of three copy/pasted blocks. // this function is composed of three copy/pasted blocks.
int room_id, subroom_id; int room_id, subroom_id;
SubRoom * subroom;
// std::cout << "enter resetGeometry with tab id: " << tab->id << "\n" ;
// std::cout << "temp Added Walls\n";
// for(auto id_wall: TempAddedWalls)
// {
// std::cout << "i " << id_wall.first << "\n";
// auto walls = id_wall.second;
// for(auto wall: walls )
// std::cout << wall.toString() << "\n";
// }
// std::cout << "temp Removed Walls\n";
// for(auto id_wall: TempRemovedWalls)
// {
// std::cout << "i " << id_wall.first << "\n";
// auto walls = id_wall.second;
// for(auto wall: walls )
// std::cout << wall.toString() << "\n";
// }
// std::cout << "temp Added Doors\n";
// for(auto id_wall: TempAddedDoors)
// {
// std::cout << "i " << id_wall.first << "\n";
// auto walls = id_wall.second;
// for(auto wall: walls )
// std::cout << wall.toString() << "\n";
// }
// remove temp added walls // remove temp added walls
for(auto id_wall: TempAddedWalls) auto tempWalls = TempAddedWalls[tab->id];
for(auto wall: tempWalls)
{ {
int i = id_wall.first; for (auto platform: _platforms)
if(i != tab->id) continue;
auto tempWalls = id_wall.second;
for(auto wall: tempWalls)
{ {
for (auto platform: _platforms) // auto tracks = platform.second->tracks;
room_id = platform.second->rid;
subroom_id = platform.second->sid;
// auto room = this->GetAllRooms().at(room_id);
SubRoom * subroom = this->GetAllRooms().at(room_id)->GetAllSubRooms().at(subroom_id).get();
for(auto subWall: subroom->GetAllWalls())
{ {
auto tracks = platform.second->tracks; if(subWall == wall)
room_id = platform.second->rid;
subroom_id = platform.second->sid;
for(auto r: GetAllRooms())
{ {
if(r.first != room_id) subroom->RemoveWall(wall);
continue; // std::cout << KGRN << "RESET REMOVE wall " << wall.toString() << "\n" << RESET;
subroom = r.second->GetSubRoom(subroom_id); auto it = std::find(tempWalls.begin(), tempWalls.end(), wall);
} if (it != tempWalls.end())
for (auto track : tracks)
{
auto walls = track.second;
for(auto trackWall : walls)
{ {
if (trackWall == wall) tempWalls.erase(it);
{
subroom->RemoveWall(wall);
auto it = std::find(tempWalls.begin(), tempWalls.end(), wall);
if (it != tempWalls.end())
{
// std::cout<< KGRN << "delete wall ..." << RESET <<std::endl;
// wallPiece.WriteToErrorLog();
tempWalls.erase(it);
}
}
} }
} }//if
} }//subroom
} }//platforms
} }
TempAddedWalls[tab->id] = tempWalls;
/* // add remove walls */ /* // add remove walls */
for(auto id_wall: TempRemovedWalls) auto tempRemovedWalls = TempRemovedWalls[tab->id];
for(auto wall: tempRemovedWalls)
{ {
int i = id_wall.first; for (auto platform: _platforms)
if(i != tab->id) continue;
auto tempWalls = id_wall.second;
for(auto wall: tempWalls)
{ {
for (auto platform: _platforms) auto tracks = platform.second->tracks;
room_id = platform.second->rid;
subroom_id = platform.second->sid;
SubRoom * subroom = this->GetAllRooms().at(room_id)->GetAllSubRooms().at(subroom_id).get();
for (auto track : tracks)
{ {
auto tracks = platform.second->tracks; auto walls = track.second;
room_id = platform.second->rid; for(auto trackWall : walls)
subroom_id = platform.second->sid;
for(auto r: GetAllRooms())
{
if(r.first != room_id)
continue;
subroom = r.second->GetSubRoom(subroom_id);
}
for (auto track : tracks)
{ {
auto walls = track.second; if (trackWall == wall)
for(auto trackWall : walls)
{ {
if (trackWall == wall) subroom->AddWall(wall);
// std::cout << KGRN << "ADD BACK wall " << wall.toString() << "\n" << RESET;
auto it = std::find(tempRemovedWalls.begin(), tempRemovedWalls.end(), wall);
if (it != tempRemovedWalls.end())
{ {
subroom->AddWall(wall); tempRemovedWalls.erase(it);
auto it = std::find(tempWalls.begin(), tempWalls.end(), wall);
if (it != tempWalls.end())
{
// std::cout<< KGRN << "delete wall ..." << RESET <<std::endl;
// wallPiece.WriteToErrorLog();
tempWalls.erase(it);
}
} }
} }
} }
} }
} }
} }
TempRemovedWalls[tab->id] = tempRemovedWalls;
/* // remove added doors */ /* // remove added doors */
for(auto id_wall: TempAddedDoors) auto tempDoors = TempAddedDoors[tab->id];
{
int i = id_wall.first;
if(i != tab->id) continue;
auto tempWalls = id_wall.second;
for(auto door: tempWalls) for(auto door: tempDoors)
{
for (auto platform: _platforms)
{ {
for (auto platform: _platforms) auto tracks = platform.second->tracks;
room_id = platform.second->rid;
subroom_id = platform.second->sid;
SubRoom * subroom = this->GetAllRooms().at(room_id)->GetAllSubRooms().at(subroom_id).get();
for(auto subTrans: subroom->GetAllTransitions())
{ {
auto tracks = platform.second->tracks; if (*subTrans == door)
room_id = platform.second->rid;
subroom_id = platform.second->sid;
for(auto r: GetAllRooms())
{ if(r.first != room_id)
continue;
subroom = r.second->GetSubRoom(subroom_id);
}
for (auto track : tracks)
{ {
auto walls = track.second; // Trnasitions are added to subrooms and building!!
for(auto trackWall : walls) subroom->RemoveTransition(subTrans);
this->RemoveTransition(subTrans);
// std::cout << KGRN << "RESET remove door " << door.toString() << "\n" << RESET;
auto it = std::find(tempDoors.begin(), tempDoors.end(), door);
if (it != tempDoors.end())
{ {
if (trackWall == door) tempDoors.erase(it);
{
subroom->RemoveTransition(&door);
auto it = std::find(tempWalls.begin(), tempWalls.end(), door);
if (it != tempWalls.end())
{
// std::cout<< KGRN << "delete wall ..." << RESET <<std::endl;
// wallPiece.WriteToErrorLog();
tempWalls.erase(it);
}
}
} }
} }
} }
} }
} }
TempAddedDoors[tab->id] = tempDoors;
// std::cout << "leave resetGeometry with tab id: " << tab->id << "\n" ;
// std::cout << "temp Added Walls: " << TempAddedWalls[tab->id].size() << "\n";
// std::cout << "temp Removed Walls: " << TempRemovedWalls[tab->id].size()<< "\n";
// std::cout << "temp Added Doors: " <<TempAddedDoors[tab->id].size() << "\n";
return true; return true;
} }
bool Building::InitPlatforms() bool Building::InitPlatforms()
...@@ -1159,10 +1155,20 @@ bool Building::AddCrossing(Crossing* line) ...@@ -1159,10 +1155,20 @@ bool Building::AddCrossing(Crossing* line)
_crossings[IDCrossing] = line; _crossings[IDCrossing] = line;
return true; return true;
} }
bool Building::RemoveTransition(Transition * line)
{
// std::cout << "enter Building Remove Transitions with " << _transitions.size() << "\n";
if (_transitions.count(line->GetID())!=0) {
_transitions.erase(line->GetID());
// std::cout << " enter Nuilding Remove Transitions with " << _transitions.size() << "\n";
return true;
}
// std::cout << "2 enter Nuilding Remove Transitions with " << _transitions.size() << "\n";
return false;
}
bool Building::AddTransition(Transition* line) bool Building::AddTransition(Transition* line)
{ {
std::cout << "building addtransition "<< line->GetID()<< "\n"; // std::cout << "building add transition "<< line->GetID()<< "\n";
if (_transitions.count(line->GetID())!=0) { if (_transitions.count(line->GetID())!=0) {
char tmp[CLENGTH]; char tmp[CLENGTH];
sprintf(tmp, sprintf(tmp,
......
...@@ -262,6 +262,8 @@ public: ...@@ -262,6 +262,8 @@ public:
// ------------------------------------ // ------------------------------------
bool AddCrossing(Crossing* line); bool AddCrossing(Crossing* line);
bool RemoveTransition(Transition * line);
bool AddTransition(Transition* line); bool AddTransition(Transition* line);
bool AddHline(Hline* line); bool AddHline(Hline* line);
......
...@@ -251,16 +251,19 @@ bool SubRoom::AddCrossing(Crossing* line) ...@@ -251,16 +251,19 @@ bool SubRoom::AddCrossing(Crossing* line)
bool SubRoom::RemoveTransition(Transition * t) bool SubRoom::RemoveTransition(Transition * t)
{ {
auto it = std::find(_transitions.begin(), _transitions.end(), t); auto it = std::find(_transitions.begin(), _transitions.end(), t);
// if (it != _transitions.end()) { if (it != _transitions.end()) {
// _transitions.erase(it); // std::cout << "subroom remove transition "<< t->GetID() << ", " << t->GetUniqueID()<< "\n";
_transitions.erase(it);
RemoveGoalID(t->GetUniqueID()); RemoveGoalID(t->GetUniqueID());
// return true; // std::cout << "enter Remove Transitions with " << _transitions.size() << "\n";
// } return true;
}
// std::cout << "2 enter Remove Transitions with " << _transitions.size() << "\n";
return false; return false;
} }
bool SubRoom::AddTransition(Transition* line) bool SubRoom::AddTransition(Transition* line)
{ {
std::cout << "subroom addtransition "<< line->GetID() << ", " << line->GetUniqueID()<< "\n"; // std::cout << "subroom addtransition "<< line->GetID() << ", " << line->GetUniqueID()<< "\n";
_transitions.push_back(line); _transitions.push_back(line);
_goalIDs.push_back(line->GetUniqueID()); _goalIDs.push_back(line->GetUniqueID());
return true; return true;
......
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