Transform coordinates of doors relatively to track

parent a3fee79d
...@@ -822,6 +822,7 @@ bool GeoFileParser::LoadTrainInfo(Building* building) ...@@ -822,6 +822,7 @@ bool GeoFileParser::LoadTrainInfo(Building* building)
resTTT = LoadTrainTimetable(building, xRootNode); resTTT = LoadTrainTimetable(building, xRootNode);
resType = LoadTrainType(building, xRootNode); resType = LoadTrainType(building, xRootNode);
} }
return (resTTT && resType); return (resTTT && resType);
} }
bool GeoFileParser::LoadTrainTimetable(Building* building, TiXmlElement * xRootNode) bool GeoFileParser::LoadTrainTimetable(Building* building, TiXmlElement * xRootNode)
...@@ -858,7 +859,7 @@ bool GeoFileParser::LoadTrainTimetable(Building* building, TiXmlElement * xRootN ...@@ -858,7 +859,7 @@ bool GeoFileParser::LoadTrainTimetable(Building* building, TiXmlElement * xRootN
e = e->NextSiblingElement("train")) { e = e->NextSiblingElement("train")) {
std::shared_ptr<TrainTimeTable> TTT = parseTrainTimeTableNode(e); std::shared_ptr<TrainTimeTable> TTT = parseTrainTimeTableNode(e);
if (TTT) { // todo: maybe get pointer to train if (TTT) {
building->AddTrainTimeTable(TTT); building->AddTrainTimeTable(TTT);
} }
} }
......
...@@ -690,8 +690,8 @@ double Simulation::RunBody(double maxSimTime) ...@@ -690,8 +690,8 @@ double Simulation::RunBody(double maxSimTime)
trainOutflow[id] += Trans->GetDoorUsage(); trainOutflow[id] += Trans->GetDoorUsage();
if(trainOutflow[id] >= TrainTypes[type]->nmax) if(trainOutflow[id] >= TrainTypes[type]->nmax)
{ {
std::cout << "INFO:\tclosing train door "<< transType.c_str() << " at "<< Pedestrian::GetGlobalTime() << "\n"; std::cout << "INFO:\tclosing train door "<< transType.c_str() << " at "<< Pedestrian::GetGlobalTime() << " capacity " << TrainTypes[type]->nmax<< "\n";
Log->Write("INFO:\tclosing train door %s at t=%.2f. Flow = %.2f (Train Capacity %.2f)", transType.c_str(), Pedestrian::GetGlobalTime(), trainOutflow[id], TrainTypes[type]->nmax); Log->Write("INFO:\tclosing train door %s at t=%.2f. Flow = %.2f (Train Capacity %d)", transType.c_str(), Pedestrian::GetGlobalTime(), trainOutflow[id], TrainTypes[type]->nmax);
Trans->Close(); Trans->Close();
} }
} }
...@@ -754,12 +754,18 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared ...@@ -754,12 +754,18 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared
int trainId = tab->id; int trainId = tab->id;
std::string trainType = tab->type; std::string trainType = tab->type;
Point TrackStart = tab->pstart; Point TrackStart = tab->pstart;
Point TrainStart = tab->tstart;
Point TrackEnd = tab->pend; Point TrackEnd = tab->pend;
SubRoom * subroom; SubRoom * subroom;
int room_id, subroom_id; int room_id, subroom_id;
auto mytrack = building->GetTrackWalls(TrackStart, TrackEnd, room_id, subroom_id); auto mytrack = building->GetTrackWalls(TrackStart, TrackEnd, room_id, subroom_id);
Room* room = building->GetRoom(room_id); Room* room = building->GetRoom(room_id);
subroom = room->GetSubRoom(subroom_id);//todo safety check subroom = room->GetSubRoom(subroom_id);
if(subroom == nullptr)
{
Log->Write("ERROR:\t Simulation::correctGeometry got wrong room_id|subroom_id (%d|%d). TrainId %d", room_id, subroom_id, trainId);
exit(EXIT_FAILURE);
}
int transition_id = 10000; // randomly high number int transition_id = 10000; // randomly high number
std::cout << "enter with train " << trainType.c_str() << "\n"; std::cout << "enter with train " << trainType.c_str() << "\n";
...@@ -773,14 +779,26 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared ...@@ -773,14 +779,26 @@ bool Simulation::correctGeometry(std::shared_ptr<Building> building, std::shared
auto train = building->GetTrainTypes().at(trainType); auto train = building->GetTrainTypes().at(trainType);
auto doors = train->doors; auto doors = train->doors;
for(auto && d: doors)
{
auto newX = d.GetPoint1()._x + TrainStart._x + TrackStart._x;
auto newY = d.GetPoint1()._y + TrainStart._y + TrackStart._y;
d.SetPoint1(Point(newX, newY));
newX = d.GetPoint2()._x + TrainStart._x + TrackStart._x;
newY = d.GetPoint2()._y + TrainStart._y + TrackStart._y;
d.SetPoint2(Point(newX, newY));
}
for(auto d: doors)
{
Log->Write("Train %s %d. Transformed coordinates of doors: %s -- %s", trainType.c_str(), trainId, d.GetPoint1().toString().c_str(), d.GetPoint2().toString().c_str());
}
// std::vector<std::pair<PointWall, pointWall > > // std::vector<std::pair<PointWall, pointWall > >
auto pws = building->GetIntersectionPoints(doors, mytrack); auto pws = building->GetIntersectionPoints(doors, mytrack);
if(pws.empty()) if(pws.empty())
std::cout << "simulation::correctGeometry: pws are empty\n"; std::cout << KRED << "simulation::correctGeometry: pws are empty. Something went south with train doors\n" << RESET;
subroom->GetUID();
auto walls = subroom->GetAllWalls(); auto walls = subroom->GetAllWalls();
//--- //---
for(auto pw: pws) for(auto pw: pws)
{ {
......
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