mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 11:47:06 +01:00
4a3b36c204
E2b (editor-tracks-domain.md §2, §4 "Rozjazd", §7, §8): a turnout is an aggregate of the domain model, laid from the catalogue the editor lays its switches from, its rules invariants which refuse. - layoutTurnout: the type of the catalogue (switch_design::catalogue(), Id-4) as the model lays it: R, 1:n, a, b, the main length, the lead and the parts of the diverging track, the movable nose, the blades; the ordinary switches whose diverging track leaves tangentially, the double, symmetric and secant ones refused with the reason (E5). The diverging track laid off the start along the turnout: on a straight the curve of the type; bent with the main track the curve of the basic switch of the radius of table 11.8 (switch_curve::bent_radius), over the length which keeps its turn off the main track, so the angle of the frog stays 1:n, the lead and the straight through the frog bent along with the main track; the cant of the main track all along it, the grade of its start. The speeds: the diverging one by switch_curve::branch_speed (the rule the editor writes), the main one the line's, bent no faster than the deficiency of the frog lets it; the velocity written by the same rule as the editor's. - The turnout: its type, hand, direction along the line, its start, the ends of its two tracks (nodes), its main and diverging track (lines it owns), derived: the kilometrage of its start, the bending, the cant, the speeds. The network keeps the turnouts with the lines and the nodes, in the snapshots of undo and in the transactions; settle() has a turnout whose main track or start changed lay its diverging track again, move the node at its end and lay again the lines going on from there. - The nodes: three ends at the start of a turnout, its two tracks on one side of it; the start of a diverging track tells its node nothing (the node keeps the curvature of the main track) and runs on into no line, the end of one sets its node. - check(): the turnouts whose tracks or legs are touched, their invariants (the legs, the tracks, the main track as long as the type) and the rules of Q2 and 11.4 through switch_curve::check (the curvature of each track of one sign, KZW II refused; the cant the same over it; the ends of the ramps at its ends or 6 m off it), a switch of 1:9.403 or steeper than 1:9 bent in a main track refused (the model knows a main track from a side one, where the editor only warns), table 11.9 and a transition under it as warnings. The norms of the E1 module with the switch context: the elements of a turnout track are a connection of tracks of their frog (fixed or movable nose: the deficiency of tab. 9.7), bent or not (the cant of tab. 9.6), at its speeds; the chain of the line runs through the main track, the element cut by a turnout open. BLOCK findings are kept apart from the broken invariants (verdict::blocks). - The commands: insert a turnout at a chainage of a line (cut at its legs, the part between them its main track), move it along its line (the lines on both sides and its main track one line again, cut anew, the ids kept, a line going on from the end of its diverging track carried with it), change its type or hand, remove it (the line one again where it can be: the merge laid and kept only where it's the same track within a micrometre). The tracks of a turnout aren't split, deleted or edited as lines; a line is joined to the free side of a turnout's start, or to the end of its diverging track from a straight (the curvature stepping there). Tests: U: the types laid and refused; the legs on a straight against the catalogue for four types both hands both ways (the main track a + b, the tangent of the diverging end meeting the main track at R tan(a/2), Id-4's a within half a millimetre, the angle 1:n, the speeds of table 11.2); Rz 60E1-500-1:12 bent outward and inward into R 1200 m with 60 mm (r" 857.8 m and 352.7 m, 60 km/h, the angle of the frog kept, the cant over it); refusals: KZW II, a ramp under it and 3 m off it, a 1:7.5 bent in a main track (laid in a side track), no type, no hand, no room; moved, changed, turned, taken out with the line laid again within a micrometre, each a step to undo; a line from the diverging end carried along. P: 250 random edits with turnouts each, seeds 20261124, 31 and 977 (laid, moved, changed, taken out, with vertices moved and set, splits, joins, deletions, undo, redo): the invariants after each (the legs and the nodes whole, three ends only at a start, the velocity by the rule), no BLOCK, a refusal changing nothing, an undo exact.
87 lines
4.4 KiB
C++
87 lines
4.4 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 "editor/editorSwitchDesign.hpp"
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <glm/glm.hpp>
|
|
|
|
// The turnouts of the track geometry (editor-tracks-domain.md §4 "Rozjazd", §7): the type of the catalogue the editor lays its switches
|
|
// from (editorSwitchDesign, Id-4), the diverging track laid off the start of the main track and bent as the line under it is (table 11.8,
|
|
// the curve of the basic switch bent to keep the angle of the frog, the rest of it along with the main track), the speeds by the rule the
|
|
// editor writes (switch_curve::branch_speed), and the rules of Q2 and §11.4 as invariants: the hard ones refuse, the others warn.
|
|
namespace layout
|
|
{
|
|
|
|
// a type of the catalogue as the model lays it: an ordinary switch (Rz) whose diverging track leaves the main one tangentially
|
|
struct turnout_type
|
|
{
|
|
std::string name;
|
|
std::string rail;
|
|
double radius{0.0}; // m, of the diverging curve of the basic switch
|
|
double ratio{0.0}; // 1:n at the end of the diverging track
|
|
double a{0.0}; // m, from the start to the centre of the switch
|
|
double b{0.0}; // m, from the centre to the end of the main track
|
|
double length{0.0}; // m, of the main track
|
|
double lead{0.0}; // m, the straight of the diverging track along the main one before its curve
|
|
std::vector<switch_design::part> parts; // of the diverging track after the lead, turning to the side it leaves to
|
|
bool movable{false}; // the frog with a movable nose
|
|
double heel{0.0}; // where the moving blades end, 0: as the simulator makes them
|
|
double bladethrow{0.0};
|
|
|
|
double diverging_length() const;
|
|
};
|
|
|
|
// the type of the catalogue by its name; none, and the reason in Why, where there's no such type or the model doesn't lay it yet: double
|
|
// switches, slips and symmetric switches, the blades meeting the stock rails at an angle (stage E5)
|
|
std::optional<turnout_type> turnout_type_of(std::string const &Name, std::string *Why = nullptr);
|
|
// the names of the types the model lays, in the order of the catalogue
|
|
std::vector<std::string> turnout_types();
|
|
|
|
// the turnout on its line, as its start node and its main track tell it: the place, the heading along the turnout, the side of the start
|
|
// node it lies on, the curvature of the main track (its mean, 0 on a straight), the cant and the grade, all along the turnout
|
|
struct turnout_frame
|
|
{
|
|
glm::dvec3 position{0.0};
|
|
glm::dvec2 heading{0.0, 1.0};
|
|
int side{1};
|
|
int along{1}; // 1: the main track runs from the start of the turnout, -1 to it
|
|
double curvature{0.0}; // 1/m, above 0 turning left
|
|
double cant{0.0}; // mm, above 0 leaning left
|
|
double grade{0.0};
|
|
bool valid{false};
|
|
};
|
|
turnout_frame frame_of(network const &Network, turnout const &Turnout);
|
|
|
|
// the main track of the bending, signed as table 11.8 takes it: above 0 bent the way the diverging track leaves to, below 0 the other way,
|
|
// 0 a straight
|
|
double bending_of(double const Curvature, int const Hand);
|
|
|
|
// the diverging track laid from the frame, to the hand: the lead and the straights through the frog along the main track, the curve of the
|
|
// basic switch bent by table 11.8 over the length which keeps the angle of the frog, transitions by the sum of the curvatures; the cant
|
|
// of the main track all along it, the grade of its start. Errors where it can't be laid so
|
|
solved_line lay_diverging(turnout_frame const &Frame, turnout_type const &Type, int const Hand);
|
|
|
|
// what the turnout takes from the line under it: the kilometrage of its start, the bending, the cant, the speeds of both tracks (the
|
|
// diverging one by switch_curve::branch_speed, the main one by formula 9.9 with the deficiency of the frog where it's bent, no faster than
|
|
// the line), the velocity written
|
|
void derive_turnout(network const &Network, turnout &Turnout);
|
|
|
|
// the invariants of the turnout (its type, its legs and its tracks, the length of its main track) into the reasons; the rules of Q2 and
|
|
// §11.4 (switch_curve::check: the curvature of each track of one sign, the cant the same over it, the ramps off it by 6 m; no switch of
|
|
// 1:9.403 nor steeper than 1:9 bent in a main track) into the blocks, and its warnings (table 11.9, a transition under it) into the notices
|
|
void check_turnout(network const &Network, turnout const &Turnout, verdict &Result);
|
|
|
|
} // namespace layout
|