From c7afa3ca10edd47ebbc72aa72f763b65235c4ff1 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:09:01 +0100 Subject: [PATCH] fix(editor): a switch laid gets the speed of its diverging track, one breaking a hard rule of ST-T1-A6 isn't laid - Every switch laid writes the speed of its diverging track (`velocity`): the switch tool on a straight, into a curve, from a free end and linked, a double switch, the switches of a slip, a switch given another template of the catalogue, and a switch moved along the curve it's bent into. A switch of the catalogue had no limit before, one copied from a switch of the scenery kept that one's, one laid without a track had the laying speed on both its tracks. The limit is for the diverging track alone (`velocity -V`); the own limit of the track it goes into stays for both where it's the lower. The switch tool says the speed and what gives it. - The speed is formula 9.9 of PKP PLK ST-T1-A6 the other way round, V = sqrt((I + D) r / 11.8), with the normal cant deficiency of the frog of table 9.7 (110 mm a fixed frog, 130 mm a movable nose), rounded down to the steps of the speed limits and no more than table 11.2 gives the basic switch. For the fixed frogs the formula gives table 11.2 itself (190 40, 300 50, 500 60, 760 80, 1200 100 km/h); the 2500-1:26.5 with a movable nose stays 130. A switch bent into a curve takes the radius of its diverging track from table 11.8 (one-sided r" = (Rr - t^2)/(R + r), two-sided (Rr + t^2)/(R - r)) and the cant of the line with its sign: leaning against the diverging track it takes speed away, where the speed check counted it as helping. Rz 60E1-190-1:9 bent out of the curve R 600 m with 60 mm: 30 km/h, not 40; the 60E1-500-1:12 of the review, out of R 1200 m with 60 mm: 60 km/h at its fixed frog (54 at I = 100 mm, the 0.65 m/s2 the editor took), not 107. - A switch breaking a hard rule isn't laid, the tracks left as they were, and the switch tool says why, with the value, the limit and the paragraph: the cant changing within it (11.4 pkt 7), a cant ramp ending within it or nearer than 6 m (9.6 pkt 16-17; one ending right at an end of the switch is let be, as the snapping of the start offers it), a double switch, a slip or a crossing bent (11.4 pkt 4), the curvature of its diverging or its main track turning from one side to the other (9.7 pkt 12, KZW II). They were warnings shown after the switch was laid, and on a straight the cant wasn't looked at at all. The line is looked at 10 m past the ends of the curve or the straight too, so the ramp on the straight before a curve counts. The previews show the refusals. - A switch moved along its straight or the curve it's bent into, a double switch moved along its straight, and a switch given another template go through the same checks; one breaking a rule stays as it is. - Warnings still: 1:9.403 and steeper than 1:9 bent (11.4 pkt 4c-d), a rule of the running and the main tracks, which the editor doesn't tell from the side ones, as the warning now says; the limits of table 11.9 and a cant over 100 mm in a bent switch (table 9.6), as before. Tests: unit tests of tables 11.8 and 11.9 (the least main radius bends the diverging track to the least radius the table gives), table 9.7, the speeds of table 11.2 by formula 9.9, the speed of a bent switch with the cant with its sign (the example of the review), the cant over a switch on a straight and a double switch bent. Editor cases `q2_1_switch_speed`, `q2_2_switch_refusals` and `q2_3_switch_move`, with `expect status` (the status of the switch tool) and `expect steps` (the undo steps), the fixture with a straight taking a cant on and a compound curve without cant. All pass; with the changes of the editor reverted all three fail. --- application/editormode.h | 26 +- application/editormodeselftest.cpp | 4 + application/editormodeselftestexpect.cpp | 29 +- application/editormodeswitchplace.cpp | 359 +++++++++++++++++++- application/editormodeswitchslide.cpp | 29 +- application/editormodeswitchtemplate.cpp | 7 + application/editormodetrack.cpp | 12 +- editor/editorSwitchCurve.cpp | 104 ++++-- editor/editorSwitchCurve.hpp | 52 ++- tests/editor/README.md | 15 +- tests/editor/cases/q2_1_switch_speed.txt | 30 ++ tests/editor/cases/q2_2_switch_refusals.txt | 42 +++ tests/editor/cases/q2_3_switch_move.txt | 34 ++ tests/editor/scenery/autotest_editor.scn | 66 ++++ tests/unit/test_switch_curve.cpp | 177 +++++++++- 15 files changed, 928 insertions(+), 58 deletions(-) create mode 100644 tests/editor/cases/q2_1_switch_speed.txt create mode 100644 tests/editor/cases/q2_2_switch_refusals.txt create mode 100644 tests/editor/cases/q2_3_switch_move.txt diff --git a/application/editormode.h b/application/editormode.h index de6bdb7d8..16d85a4ae 100644 --- a/application/editormode.h +++ b/application/editormode.h @@ -1972,6 +1972,11 @@ class editor_mode : public application_mode, private editor_track::observer, pri std::string straight_end_note(editor_track::straight const &Line, bool const Far) const; std::optional switch_drag_problem() const; std::optional straight_switch_problem(editor_track::straight const &Line, double const Length, double const Along, int const Direction) const; + // the hard rules of ST-T1-A6 the switch breaks, for the status: not Laid, or kept as it is when moved or given another template + static std::string switch_refusal(std::vector const &Refusals, bool const Laid); + // the switch lying along the straight From to To, the cant of the line under it and near it (11.4 pkt 7, 9.6 pkt 16): what it breaks, + // empty for nothing. Moving: the tracks of the switch moved along the straight, which the line is taken without + std::string straight_switch_refusal(editor_track::straight const &Line, glm::dvec3 const &From, glm::dvec3 const &To, bool const Laid, std::vector const &Moving = {}) const; void flash_switch_problem(switch_problem Problem); void flash_switch_problem(std::string const &Text, std::vector Paths, std::vector> Marks = {}); void draw_switch_problem(switch_problem const &Problem) const; @@ -2002,13 +2007,30 @@ class editor_mode : public application_mode, private editor_track::observer, pri static curve_sample sample_at(std::vector const &Frame, double const Station); // the curve a switch goes into as the norms look at it: its headings and its cant along it std::vector frame_points(std::vector const &Frame) const; + // the line of the chain as the norms look at it, the first path of each track the way the chain runs, and on over the plain tracks + // joined past its ends as far as Beyond: the ends of the cant ramps near a switch; Offset: the station the chain starts at + std::vector line_points(editor_track::chain const &Chain, double const Beyond, double &Offset) const; + // the tracks of the frame as a chain, each run the way the frame goes + static editor_track::chain frame_chain(std::vector const &Frame, std::vector const &Tracks); + // the tracks of the straight along their first paths as a chain, from its start on + static editor_track::chain straight_chain(editor_track::straight const &Line); + // the speed on the diverging track of the switch as it lies, km/h: the basic switch of Radius and 1:Ratio bent as its main track is + // (table 11.8), the cant of its line with its sign, the cant deficiency its frog takes (formula 9.9, table 9.7), no more than the + // basic switch has (table 11.2); Why receives how, for the status + double branch_speed_of(TTrack const &Switch, double const Radius, double const Ratio, std::string *Why = nullptr) const; + // that speed written into the switch for its diverging track, a lower limit of the main track kept for both; returns how, for the + // status + std::string write_switch_speed(TTrack &Switch, double const Radius, double const Ratio, double const Main); + // a switch of the scenery bent into the curve of the Frame along its Tracks, its Paths where it's moved to, as ST-T1-A6 sees it + switch_curve::switch_report bent_switch_report(TTrack const &Switch, std::vector const &Frame, std::vector const &Tracks, std::vector const &Paths) const; // the way the switch being placed into a curve goes along it and the side its diverging track leaves to, from the drag void curved_switch_pose(int &Direction, int &Side) const; // the start of the switch being placed into a curve: where it was pressed, drawn to where the switch meets an end of a cant ramp or // keeps 6 m off it; What receives which double curved_switch_start(int const Direction, std::string *What = nullptr) const; - // the switch made of the paths, laid into the curve at the station, as ST-T1-A6 sees it - switch_curve::switch_report curved_switch_report(std::vector const &Paths, std::vector const &Frame, double const Station, int const Direction) const; + // the switch made of the paths, laid into the curve at the station, as ST-T1-A6 sees it; with the Tracks of the frame its cant is + // looked at on past the ends of the curve too + switch_curve::switch_report curved_switch_report(std::vector const &Paths, std::vector const &Frame, double const Station, int const Direction, std::vector const *Tracks = nullptr) const; static double nearest_station(std::vector const &Frame, glm::dvec3 const &Point); static std::vector curved_switch_paths(editor_track::switch_template const &Shape, std::vector const &Frame, double const Station, int const Direction, int const Side); // the path of a switch template laid into the curve: x of the template across the main track to the Side, z along it from the diff --git a/application/editormodeselftest.cpp b/application/editormodeselftest.cpp index 8bc62f626..240fea8fb 100644 --- a/application/editormodeselftest.cpp +++ b/application/editormodeselftest.cpp @@ -159,6 +159,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c // splitkind , nudgekind the first path over an element of the kind split in two, or moved // switchplace