mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-31 07:40:54 +01:00
feat(editor): the SRK tool shows the block of each line out of the station and places the SHP resonators: the automatic or the semi-automatic block chosen in a table of the lines, by hand or by the block signals standing along it, a double-track line taking the automatic one, a single-track one the other, kept in the record of the station; the block signals placed only on the lines of the automatic block, the warning discs only on those of the semi-automatic one. The heads checked for their resonators 200 m before an entry signal, a block signal and a warning disc and at an exit signal telling of the next one, 5 m either way, those of the old sceneries found by any event ending with _shp within 100 m; the ones missing placed as rezonator.inc with their events on the tracks the trains run into, at a joint within 5 m, else the track cut, in one step of undo. A signal stands by the track of its read event only when it lies near it, else by the nearest track, so a read event put on a track before the signal no longer shifts its routes
This commit is contained in:
@@ -2229,4 +2229,65 @@ std::vector<std::vector<route>> routes(std::vector<post> const &Posts, std::vect
|
||||
return all;
|
||||
}
|
||||
|
||||
std::vector<approach_point> approach(TTrack &Track, glm::dvec3 const &Point, int const Facing, double const Distance)
|
||||
{
|
||||
std::vector<approach_point> result;
|
||||
if (false == rail(Track))
|
||||
return result;
|
||||
auto *track{&Track};
|
||||
int path{0};
|
||||
long at{0};
|
||||
std::vector<glm::dvec3> points;
|
||||
auto nearest{std::numeric_limits<double>::max()};
|
||||
for (int candidate = 0; candidate < static_cast<int>(Track.m_paths.size()); ++candidate)
|
||||
{
|
||||
double length{0.0};
|
||||
auto dense{dense_points(Track, candidate, length)};
|
||||
for (std::size_t k = 0; k < dense.size(); ++k)
|
||||
if (auto const gap{plan_distance(dense[k], Point)}; gap < nearest - 1e-6)
|
||||
{
|
||||
nearest = gap;
|
||||
path = candidate;
|
||||
at = static_cast<long>(k);
|
||||
}
|
||||
if (path == candidate)
|
||||
points = std::move(dense);
|
||||
}
|
||||
auto facing{Facing > 0 ? 1 : -1};
|
||||
auto last{points[at]};
|
||||
double distance{0.0};
|
||||
std::unordered_set<TTrack const *> seen{track};
|
||||
while (true)
|
||||
{
|
||||
auto const count{static_cast<long>(points.size())};
|
||||
auto const step{facing > 0 ? -1L : 1L};
|
||||
for (auto k{at}; k >= 0 && k < count; k += step)
|
||||
{
|
||||
distance += plan_distance(last, points[k]);
|
||||
last = points[k];
|
||||
auto const ahead{points[std::clamp(k + 1, 0L, count - 1)] - points[std::clamp(k - 1, 0L, count - 1)]};
|
||||
glm::dvec3 way{ahead.x * facing, 0.0, ahead.z * facing};
|
||||
way = glm::length(way) > 1e-9 ? glm::normalize(way) : glm::dvec3{0.0, 0.0, 1.0};
|
||||
result.push_back({track, path, facing, points[k], way, distance});
|
||||
if (distance >= Distance)
|
||||
return result;
|
||||
}
|
||||
auto const atend{facing < 0};
|
||||
auto const end{end_of(*track, path, atend)};
|
||||
auto *before{neighbour(*track, path, atend)};
|
||||
int entered{0};
|
||||
bool from_end{false};
|
||||
if (before == nullptr || false == rail(*before) || false == seen.insert(before).second || false == end_at(*before, end, entered, from_end))
|
||||
return result;
|
||||
if (before->eType == tt_Switch && false == from_end)
|
||||
entered = straighter(*before);
|
||||
track = before;
|
||||
path = entered;
|
||||
double length{0.0};
|
||||
points = dense_points(*track, path, length);
|
||||
facing = from_end ? 1 : -1;
|
||||
at = from_end ? static_cast<long>(points.size()) - 2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace station
|
||||
|
||||
@@ -249,4 +249,18 @@ double path_speed(TTrack const &Track, int const Path);
|
||||
// the routes of the trains from each of the posts given on through the switches, none longer than the limit
|
||||
std::vector<std::vector<route>> routes(std::vector<post> const &Posts, std::vector<std::size_t> const &From, double const Limit);
|
||||
|
||||
// a point of the way of the trains up to a signal
|
||||
struct approach_point
|
||||
{
|
||||
TTrack *track{nullptr};
|
||||
int path{0};
|
||||
int facing{1}; // the trains run 1: towards the end of the path, -1: towards its start
|
||||
glm::dvec3 point{0.0};
|
||||
glm::dvec3 way{0.0, 0.0, 1.0}; // the trains run, in the plan
|
||||
double distance{0.0}; // m, before the signal
|
||||
};
|
||||
// the way of the trains running past the point of the track the way given, back along the tracks they come by up to the distance
|
||||
// before it or the end of the tracks, a metre or so apart: into a switch from its start along its straighter path
|
||||
std::vector<approach_point> approach(TTrack &Track, glm::dvec3 const &Point, int const Facing, double const Distance);
|
||||
|
||||
} // namespace station
|
||||
|
||||
Reference in New Issue
Block a user