18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 17:37:09 +01:00
Files
maszyna/editor/layout/layoutGenerator.hpp
T
maj00r b0f7744434 feat(editor): the switch tracks of the simulator made of the turnouts of the track geometry, the legs at their nodes to the bit
The generator (editor-tracks-domain.md §5, "Rozjazdy") makes a turnout one switch track entry TTrack::Load reads: the paths of its main
and its diverging track, each from the start of the turnout.

- Each path the pieces of its line as the generator cuts any line (within 0.5 mm of the elements, the rolls and the heights from the
  line), turned round where the main track runs against the turnout, written as pieces1/pieces2; the path itself the curve between
  their ends and headings for the versions which know only the path, or the one piece where one makes it. The ends of both paths are
  the numbers of the nodes of the legs, so the tracks on the other side of them meet them to the bit.
- velocity as the speed rule gives it (the main limit for both where it's the lower, else the diverging one below 0), frogs, the
  movable nose and the blades of the type where it has them; the name <turnout_prefix><turnout>, t by default.
- A track of a turnout isn't made as a line of its own; generate_all() makes the lines, then the turnouts.

Tests (G): turnouts on a straight with a grade (a 1:12 to the left along the line, a 1:9 to the right against it, a 1:26.5 with a
movable nose) and one bent outward into R 1200 m with 60 mm, written and read back: both paths from the start node, the main one to
the end of the main track, the diverging one to its end, to the bit; the pieces as written, joined to the bit, each within 0.5 mm of
its line both ways (the farthest 6e-6 mm: short arcs of one Bezier curve each); the radius of the bent diverging curve; the velocity,
the movable nose and the frogs read back; the tracks of the lines on the other side of the legs ending there with the same numbers and
rolls (of the other sign where they meet head on). The diverging track of Rz 60E1-2500-1:26,5 as the simulator draws it within the chord
offsets of Id-4 (30 m chords, 41 to 49 mm in the middle): 45.0 mm all along, 130 km/h on it.

Left for E5: the catalogue as a data file (now switch_design::catalogue() in code), the double, symmetric and secant switches, the bending
exact everywhere (now table 11.8 for the curve of the basic switch, the rest of the diverging track bent with the main one, a main track
on a transition taken at its mean curvature), the connection solver (crossovers, the spacing measured along).
2026-11-23 12:41:49 +01:00

108 lines
4.9 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "editor/layout/layoutNetwork.hpp"
#include "world/Segment.h"
#include <array>
#include <map>
#include <string>
#include <vector>
// The generator of the tracks of the simulator (editor-tracks-domain.md §3 and §5): the layer between the domain and the simulator,
// which knows nothing of the domain. A line is cut into cubic Bezier pieces, each one a track entry of the text TTrack::Load reads:
// within the tolerance of the element it follows (half a millimetre by default, the curve measured as the simulator draws it, a straight
// of zero control vectors where it takes the curve for one), the rolls and the heights from the functions of the line, the radius from
// the element. A piece ends at a node with the numbers of the node, the same on both sides of it; the names of the tracks come from the
// identifiers of the line and of its vertices, so they don't change with a change of the shape which keeps its elements. A turnout is one
// switch track of two paths, its main and its diverging track, each made of the pieces of its line (pieces1, pieces2), the ends of its legs
// the numbers of its nodes, its velocity as the speed rule gives it, its frog and its blades as its type has them.
namespace layout
{
// a joint of an old track the pieces are to end at, the name of the old track kept for the piece before it (stage E6)
struct hard_split
{
double chainage{0.0};
std::string name;
};
struct generator_options
{
std::string prefix{"l"}; // of the names of the tracks: <prefix><line>_<element><piece>
std::string turnout_prefix{"t"}; // of the names of the switch tracks: <turnout_prefix><turnout>
double tolerance{0.0005}; // m, the farthest a piece may lie from its line, in the plan and in the height
double cant_tolerance{2.0}; // mm the cant may differ from the line between the ends of a piece, where the simulator turns it evenly
// what an entry has between the type and the path: the width, the friction, the sound distance, the quality, the damage, the
// environment and the visibility with the materials
std::string surface{"1.435 0.15 25 20 0 flat vis rail_screw_used1 4 tpbps-new2 0.2 0.5 1.1"};
// the joints of the old tracks as hard points of the pieces, by line: stage E6 (§10, "stare złącza jako twarde punkty podziału").
// Not yet: a line given any is refused, so nothing is made which would lose the names and the events of the old tracks
std::map<line_id, std::vector<hard_split>> hard_splits;
};
struct generated_piece
{
std::string name;
double from{0.0}; // chainage along the line
double to{0.0};
segment_data path; // its control vectors relative to its ends, zero for a straight, as the entry has them
double deviation{0.0}; // m, the farthest the curve as the simulator draws it lies from the line, measured when cut
std::string text; // the entry
};
struct generated_line
{
line_id line{line_id::none};
std::vector<generated_piece> pieces;
std::vector<std::string> errors;
std::string text() const;
};
// the pieces of a line of its own; a track of a turnout is made with its turnout
generated_line generate(network const &Network, line_id const Line, generator_options const &Options = {});
struct generated_turnout
{
turnout_id turnout{turnout_id::none};
std::string name;
// the main and the diverging track from the start of the turnout, each the pieces of its line, as the paths of the switch have them:
// the path the pieces make, whole, with them (none where one piece makes it)
std::array<std::vector<generated_piece>, 2> pieces;
std::array<segment_data, 2> paths;
double velocity{0.0};
std::vector<std::string> errors;
std::string text; // the entry
};
generated_turnout generate(network const &Network, turnout_id const Turnout, generator_options const &Options = {});
// all the lines of the network in the order of their identifiers, then all the turnouts; the errors of the ones which couldn't be made in
// Errors
std::string generate_all(network const &Network, generator_options const &Options, std::vector<std::string> &Errors);
// the curve the simulator draws of the path: a straight where its control vectors are zero, or so close to the third of the chord that
// TTrack takes it for one (its check of 2 cm, TTrack::straightened)
struct drawn_curve
{
glm::dvec3 p0;
glm::dvec3 p1;
glm::dvec3 p2;
glm::dvec3 p3;
glm::dvec3 point(double const T) const;
};
drawn_curve drawn(segment_data const &Path);
bool straightened(segment_data const &Path);
// the farthest the curve drawn lies from the line between the chainages: each point of it set square onto the line, the distance in the
// plan and in the height together
double deviation(solved_line const &Line, drawn_curve const &Curve, double const From, double const To);
} // namespace layout