mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 07:07:05 +01:00
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.
This commit is contained in:
@@ -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_problem> switch_drag_problem() const;
|
||||
std::optional<switch_problem> 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<std::string> 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<TTrack const *> const &Moving = {}) const;
|
||||
void flash_switch_problem(switch_problem Problem);
|
||||
void flash_switch_problem(std::string const &Text, std::vector<segment_data> Paths, std::vector<std::pair<glm::dvec3, std::string>> 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<curve_sample> 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<switch_curve::track_point> frame_points(std::vector<curve_sample> 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<switch_curve::track_point> 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<curve_sample> const &Frame, std::vector<TTrack *> 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<curve_sample> const &Frame, std::vector<TTrack *> const &Tracks, std::vector<segment_data> 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<segment_data> const &Paths, std::vector<curve_sample> 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<segment_data> const &Paths, std::vector<curve_sample> const &Frame, double const Station, int const Direction, std::vector<TTrack *> const *Tracks = nullptr) const;
|
||||
static double nearest_station(std::vector<curve_sample> const &Frame, glm::dvec3 const &Point);
|
||||
static std::vector<segment_data> curved_switch_paths(editor_track::switch_template const &Shape, std::vector<curve_sample> 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
|
||||
|
||||
@@ -159,6 +159,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
|
||||
// splitkind <kind>, nudgekind <kind> <dx> <dz> the first path over an element of the kind split in two, or moved
|
||||
// switchplace <template> <x> <z> <direction> <side> the catalogue template whose label starts so put into the straight
|
||||
// nearest the point, or into the curve (switchcurve); slipplace <template> <x> <z>
|
||||
// switchslide <name|selected> <metres|back|ahead> the switch moved along its straight or the curve it's bent into, as dragged
|
||||
// switchreplace <name|selected> <template> the switch given the catalogue template whose label starts so, as the inspector gives it
|
||||
// switchpieces <R> <n> [name] logs the diverging path made of pieces of each switch: length, the arc R of 1:n against the axis
|
||||
// switchbreak [name] the first piece of the diverging path moved off its neighbour, the switch committed
|
||||
// switches logs the switches kept in the scenery and the speed of each diverging track
|
||||
@@ -225,6 +227,8 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
|
||||
// expect height <track> <start|end> <m> <tolerance> the height of the end of the first path
|
||||
// expect lift <track> <start|end> <label> <m> <tolerance> how far the end of the first path is above the height marked
|
||||
// expect includes <track> <count> the includes whose parameters name the track: the model and the events of a turntable
|
||||
// expect status <text> the status of the switch tool, as its panel shows it, holds the text (the rest of the line)
|
||||
// expect steps <count> the steps of the history Ctrl+Z takes back, the ones made together counted once
|
||||
// each expect logs SELFTEST PASS or SELFTEST FAIL; a failed one, or a command no group takes,
|
||||
// makes the run end with editor_selftest::failed_exit_code
|
||||
// quit logs SELFTEST result: <failed> failed of <expectations>, the editor closes
|
||||
|
||||
@@ -312,6 +312,29 @@ void expect_includes(std::string const &What, std::istringstream &Words)
|
||||
expectation(count == wanted, What, std::to_string(count), std::to_string(wanted));
|
||||
}
|
||||
|
||||
// expect status <text>: the status the switch tool shows in its panel holds the text, the rest of the line
|
||||
void expect_status(std::string const &What, std::istringstream &Words, std::string const &Status)
|
||||
{
|
||||
std::string wanted;
|
||||
std::getline(Words >> std::ws, wanted);
|
||||
if (wanted.empty())
|
||||
{
|
||||
expectation(false, What, "malformed", "the text the status holds");
|
||||
return;
|
||||
}
|
||||
expectation(Status.find(wanted) != std::string::npos, What, "\"" + Status + "\"", "a status holding \"" + wanted + "\"");
|
||||
}
|
||||
|
||||
// expect steps <count>: the steps Ctrl+Z takes back, the ones made together counted once
|
||||
void expect_steps(std::string const &What, std::istringstream &Words, std::size_t const Steps)
|
||||
{
|
||||
std::size_t wanted{0};
|
||||
Words >> wanted;
|
||||
if (malformed(What, Words))
|
||||
return;
|
||||
expectation(Steps == wanted, What, std::to_string(Steps), std::to_string(wanted));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
editor_mode::selftest_result editor_mode::selftest_expect(std::string const &command, std::istringstream &words)
|
||||
@@ -354,7 +377,11 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
|
||||
expect_height(what, kind, words, m_selftest.marks);
|
||||
else if (kind == "includes")
|
||||
expect_includes(what, words);
|
||||
else if (kind == "status")
|
||||
expect_status(what, words, m_switch.status);
|
||||
else if (kind == "steps")
|
||||
expect_steps(what, words, static_cast<std::size_t>(std::ranges::count_if(m_history, [](EditorSnapshot const &Step) { return false == Step.joined; })));
|
||||
else
|
||||
expectation(false, what, "no expectation " + kind, "cant, joint, records, speed, gauge, track, route, norms, height, lift or includes");
|
||||
expectation(false, what, "no expectation " + kind, "cant, joint, records, speed, gauge, track, route, norms, height, lift, includes, status or steps");
|
||||
return selftest_result::handled;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ http:
|
||||
#include "editor/editorFormat.hpp"
|
||||
#include "editor/editorAlignmentStore.hpp"
|
||||
#include "editor/editorSwitchStore.hpp"
|
||||
#include "editor/editorSpeed.hpp"
|
||||
#include "editor/editorGeometry.hpp"
|
||||
#include "editor/editorIncludeInfo.hpp"
|
||||
|
||||
@@ -55,8 +56,67 @@ segment_data straight_path(glm::dvec3 const &Start, glm::dvec3 const &End)
|
||||
return path;
|
||||
}
|
||||
|
||||
// m past the ends of a switch its line is looked at for the ends of the cant ramps, which keep 6 m off it (9.6 pkt 16)
|
||||
double constexpr kRampReach{10.0};
|
||||
|
||||
// the radius the main track of a switch is bent to, signed as the store signs it, + where the headings grow; 0 straight. Of its sharpest
|
||||
// piece: one bent up to the frog keeps straight over it
|
||||
double bent_main_radius(segment_data const &Main)
|
||||
{
|
||||
std::vector<segment_data const *> parts;
|
||||
if (Main.pieces.empty())
|
||||
parts.push_back(&Main);
|
||||
for (auto const &piece : Main.pieces)
|
||||
parts.push_back(&piece);
|
||||
double radius{0.0};
|
||||
double sharpest{0.0};
|
||||
for (auto const *part : parts)
|
||||
{
|
||||
bezier const curve{*part};
|
||||
auto const begin{plan_of(curve.first(0.0))};
|
||||
auto const finish{plan_of(curve.first(1.0))};
|
||||
auto const length{curve.plan_length()};
|
||||
if (glm::length(begin) < 1e-9 || glm::length(finish) < 1e-9 || length < 0.5)
|
||||
continue;
|
||||
auto const turn{geometry::signed_angle(glm::normalize(begin), glm::normalize(finish))};
|
||||
if (std::abs(turn) / length > sharpest)
|
||||
{
|
||||
sharpest = std::abs(turn) / length;
|
||||
radius = length / turn;
|
||||
}
|
||||
}
|
||||
return std::abs(radius) > 20000.0 ? 0.0 : radius;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string editor_mode::switch_refusal(std::vector<std::string> const &Refusals, bool const Laid)
|
||||
{
|
||||
if (Refusals.empty())
|
||||
return {};
|
||||
return format(Laid ? STR_C("The switch isn't laid: %s") : STR_C("The switch stays as it is: %s"), lines_of(Refusals).c_str());
|
||||
}
|
||||
|
||||
std::string editor_mode::straight_switch_refusal(editor_track::straight const &Line, glm::dvec3 const &From, glm::dvec3 const &To, bool const Laid, std::vector<TTrack const *> const &Moving) const
|
||||
{
|
||||
// the line along the straight and on past it: no ramp within the switch nor nearer than 6 m (11.4 pkt 7, 9.6 pkt 16). A switch moved
|
||||
// along it is left out, the line taken on over the place it leaves
|
||||
auto chain{straight_chain(Line)};
|
||||
for (std::size_t i = chain.tracks.size(); i-- > 0;)
|
||||
if (std::find(Moving.begin(), Moving.end(), chain.tracks[i]) != Moving.end())
|
||||
{
|
||||
chain.tracks.erase(chain.tracks.begin() + i);
|
||||
chain.forward.erase(chain.forward.begin() + i);
|
||||
}
|
||||
if (chain.tracks.empty())
|
||||
return {};
|
||||
double offset{0.0};
|
||||
auto const points{line_points(chain, kRampReach, offset)};
|
||||
auto const &first{chain.tracks.front()->m_paths.front()};
|
||||
auto const origin{Line.along(first.points[chain.forward.front() ? segment_data::point::start : segment_data::point::end])};
|
||||
return switch_refusal(switch_curve::check_line(points, offset + Line.along(From) - origin, offset + Line.along(To) - origin).refusals, Laid);
|
||||
}
|
||||
|
||||
std::vector<double> editor_mode::switch_memo_key() const
|
||||
{
|
||||
auto const &tool{m_switch};
|
||||
@@ -524,6 +584,13 @@ void editor_mode::insert_free_switch()
|
||||
auto const paths{bent ? bend.paths : free_switch_paths()};
|
||||
if (paths.size() < 2)
|
||||
return;
|
||||
// bent so as to break a hard rule: none laid
|
||||
if (bent && false == bend.report.refusals.empty())
|
||||
{
|
||||
tool.status = refused(switch_refusal(bend.report.refusals, true));
|
||||
flash_switch_problem(tool.status, {paths.begin(), paths.begin() + 2}, {{tool.point, ""}});
|
||||
return;
|
||||
}
|
||||
auto const made{create_switch_set(tool.templates[tool.armed], paths, tool.free_end.track, switch_name_for_new())};
|
||||
if (made.empty())
|
||||
return;
|
||||
@@ -565,6 +632,15 @@ void editor_mode::switch_placed(std::vector<TTrack *> const &Created)
|
||||
m_track_point = {};
|
||||
m_node = *found;
|
||||
ui()->set_node(m_node);
|
||||
// the speed written on its diverging track, told after what the drive placed with it tells
|
||||
auto const told = [&]() {
|
||||
auto const known{switch_store::named(**found)};
|
||||
std::string speed;
|
||||
if (known.has_value() && known->radius > 0.0)
|
||||
branch_speed_of(**found, known->radius, known->ratio, &speed);
|
||||
if (false == speed.empty() && m_switch.status.find(speed) == std::string::npos)
|
||||
m_switch.status += (m_switch.status.empty() ? "" : "\n") + speed;
|
||||
};
|
||||
if (slip)
|
||||
{
|
||||
auto const known{switch_store::named(**found)};
|
||||
@@ -595,11 +671,13 @@ void editor_mode::switch_placed(std::vector<TTrack *> const &Created)
|
||||
m_switch.status = format(STR_C("Double switch %s + %s with drives: events %s+, %s- and %s+, %s- switch them, also in the map"), driven[0].c_str(), driven[1].c_str(), driven[0].c_str(), driven[0].c_str(), driven[1].c_str(), driven[1].c_str());
|
||||
ui()->set_status(m_switch.status, false);
|
||||
}
|
||||
told();
|
||||
advance_switch_name();
|
||||
return;
|
||||
}
|
||||
if (place_switch_drive(**found))
|
||||
join_last_steps();
|
||||
told();
|
||||
advance_switch_name();
|
||||
}
|
||||
|
||||
@@ -796,6 +874,14 @@ bool editor_mode::place_switch_on_straight(editor_track::straight const &Line, e
|
||||
auto const from{switch_from(Line, shape.length, Along, Direction, Snap)};
|
||||
auto const to{from + shape.length};
|
||||
auto const origin{Direction > 0 ? from : to};
|
||||
// no cant ramp within it nor near it: not laid, the tracks as they were
|
||||
auto const point = [&](double const Distance) { return Line.start + glm::dvec3{Line.direction.x, Line.grade, Line.direction.y} * Distance; };
|
||||
if (auto const refusal{straight_switch_refusal(Line, point(from), point(to), true)}; false == refusal.empty())
|
||||
{
|
||||
m_switch.status = refused(refusal);
|
||||
flash_switch_problem(refusal, {straight_path(point(from), point(to))}, {{point(origin), ""}});
|
||||
return false;
|
||||
}
|
||||
// from the track as it lies there, before it's cut: the switch in its plane between the heights of the two ends
|
||||
auto const height_from{straight_height(Line, from)};
|
||||
auto const height_to{straight_height(Line, to)};
|
||||
@@ -806,7 +892,6 @@ bool editor_mode::place_switch_on_straight(editor_track::straight const &Line, e
|
||||
if (std::string reason; tracks_editable(Line.tracks, reason))
|
||||
{
|
||||
m_switch.status = refused(STR_C("The switch would overlap another switch, move it onto plain track"));
|
||||
auto const point = [&](double const Distance) { return Line.start + glm::dvec3{Line.direction.x, Line.grade, Line.direction.y} * Distance; };
|
||||
flash_switch_problem(m_switch.status, {straight_path(point(from), point(to))});
|
||||
}
|
||||
return false;
|
||||
@@ -831,6 +916,9 @@ std::vector<TTrack *> editor_mode::create_switch_set(editor_track::switch_templa
|
||||
auto const switch_of = [&](editor_track::switch_template const &Template, std::vector<segment_data> const &Each, std::string const &Named) {
|
||||
return Style != nullptr ? editor_track::create_switch(Template, Each, *Style, Named) : editor_track::create_switch(Template, Each, m_lay.style, Named);
|
||||
};
|
||||
// the speed on the diverging track written as laid, none kept from the track or the switch copied: the own limit of the plain track it
|
||||
// goes into, or of the laying, stays for the main track where it's the lower
|
||||
auto const main{Style != nullptr ? (Style->eType == tt_Normal ? speed_check::path_velocity(*Style, 0) : -1.0) : m_lay.style.velocity > 0.0 ? m_lay.style.velocity : -1.0};
|
||||
if (Shape.twofold() && Paths.size() >= 5)
|
||||
{
|
||||
auto firstshape{Shape};
|
||||
@@ -845,9 +933,11 @@ std::vector<TTrack *> editor_mode::create_switch_set(editor_track::switch_templa
|
||||
m_switch.status = refused(STR_C("The switch couldn't be created from this template"));
|
||||
return {};
|
||||
}
|
||||
auto const speed{write_switch_speed(*one, Shape.radius, Shape.ratio, main)};
|
||||
write_switch_speed(*two, Shape.radius, Shape.ratio, main);
|
||||
editor_track::commit({one, two, link});
|
||||
record_double(*one, *two, Shape);
|
||||
m_switch.status = format(STR_C("Double switch %s with its second switch %s inserted"), one->name().c_str(), two->name().c_str());
|
||||
m_switch.status = format(STR_C("Double switch %s with its second switch %s inserted"), one->name().c_str(), two->name().c_str()) + (speed.empty() ? "" : "\n") + speed;
|
||||
return {one, two, link};
|
||||
}
|
||||
auto *track{switch_of(Shape, Paths, Name)};
|
||||
@@ -856,9 +946,10 @@ std::vector<TTrack *> editor_mode::create_switch_set(editor_track::switch_templa
|
||||
m_switch.status = refused(STR_C("The switch couldn't be created from this template"));
|
||||
return {};
|
||||
}
|
||||
auto const speed{write_switch_speed(*track, Shape.radius, Shape.ratio, main)};
|
||||
editor_track::commit({track});
|
||||
record_switch(*track, Shape);
|
||||
m_switch.status = format(STR_C("Switch %s inserted, Ctrl+Z takes it back"), track->name().c_str());
|
||||
m_switch.status = format(STR_C("Switch %s inserted, Ctrl+Z takes it back"), track->name().c_str()) + (speed.empty() ? "" : "\n") + speed;
|
||||
return {track};
|
||||
}
|
||||
|
||||
@@ -1279,6 +1370,11 @@ std::vector<TTrack *> editor_mode::build_double_slip(glm::dvec3 const &PointA, g
|
||||
if (false == single)
|
||||
parts.push_back(editor_track::create_path(Style, laid(arc(PointC, Second, -side, PointB, middle - split, middle + split))));
|
||||
parts.erase(std::remove(parts.begin(), parts.end(), nullptr), parts.end());
|
||||
// the speed on its slip curves written as laid, the own limit of the track it goes into kept where it's the lower
|
||||
auto const main{Style.eType == tt_Normal ? speed_check::path_velocity(Style, 0) : -1.0};
|
||||
for (auto *part : parts)
|
||||
if (part->eType == tt_Switch)
|
||||
write_switch_speed(*part, Curve.radius, Angle > 1e-6 ? 1.0 / std::tan(Angle) : 0.0, main);
|
||||
record_slip(parts, "slip", Type, Curve.radius, Angle, base, Curve.middle);
|
||||
return parts;
|
||||
}
|
||||
@@ -1534,6 +1630,15 @@ bool editor_mode::insert_double_slip(editor_track::straight const &Line, glm::dv
|
||||
auto const &pointC{plan.points[2]};
|
||||
auto const &pointD{plan.points[3]};
|
||||
|
||||
// no cant ramp under it nor near it, as under a switch: none laid, the tracks as they were
|
||||
auto const along = [&](double const Distance) { return Line.start + glm::dvec3{Line.direction.x, Line.grade, Line.direction.y} * Distance; };
|
||||
if (auto const refusal{straight_switch_refusal(Line, along(alongfirst - half), along(alongfirst + half), true)}; false == refusal.empty())
|
||||
{
|
||||
state.status = refused(refusal);
|
||||
m_switch.status = state.status;
|
||||
flash_switch_problem(refusal, {straight_path(along(alongfirst - half), along(alongfirst + half))}, {{Point, ""}});
|
||||
return false;
|
||||
}
|
||||
std::vector<std::pair<TTrack *, editor_track::state>> states;
|
||||
std::vector<TTrack *> created;
|
||||
std::vector<TTrack *> removed;
|
||||
@@ -1853,6 +1958,192 @@ std::vector<switch_curve::track_point> editor_mode::frame_points(std::vector<cur
|
||||
return points;
|
||||
}
|
||||
|
||||
std::vector<switch_curve::track_point> editor_mode::line_points(editor_track::chain const &Chain, double const Beyond, double &Offset) const
|
||||
{
|
||||
Offset = 0.0;
|
||||
struct run
|
||||
{
|
||||
TTrack const *track;
|
||||
bool forward;
|
||||
};
|
||||
std::vector<run> runs;
|
||||
for (std::size_t i = 0; i < std::min(Chain.tracks.size(), Chain.forward.size()); ++i)
|
||||
if (Chain.tracks[i] != nullptr && false == Chain.tracks[i]->m_paths.empty())
|
||||
runs.push_back({Chain.tracks[i], Chain.forward[i]});
|
||||
if (runs.empty())
|
||||
return {};
|
||||
auto const taken = [&](TTrack const *Track, std::vector<run> const &More) {
|
||||
auto const of = [&](run const &Run) { return Run.track == Track; };
|
||||
return std::any_of(runs.begin(), runs.end(), of) || std::any_of(More.begin(), More.end(), of);
|
||||
};
|
||||
// the plain tracks joined on past an end of the chain, each run the way the chain goes, as far as Beyond
|
||||
auto const onward = [&](bool const Atend) {
|
||||
std::vector<run> result;
|
||||
auto current{Atend ? runs.back() : runs.front()};
|
||||
for (double reached{0.0}; reached < Beyond;)
|
||||
{
|
||||
auto const &path{current.track->m_paths.front()};
|
||||
auto const &leaving{path.points[current.forward == Atend ? segment_data::point::end : segment_data::point::start]};
|
||||
std::optional<run> next;
|
||||
for (auto const &[other, point] : editor_track::connected_points(*current.track, leaving))
|
||||
if (other->eType == tt_Normal && false == other->m_editorremoved && other->m_paths.size() == 1 && false == taken(other, result))
|
||||
{
|
||||
next = run{other, (point.kind == editor_track::point_kind::start) == Atend};
|
||||
break;
|
||||
}
|
||||
if (false == next.has_value())
|
||||
break;
|
||||
result.push_back(*next);
|
||||
auto const &own{next->track->m_paths.front()};
|
||||
reached += plan_distance(own.points[segment_data::point::start], own.points[segment_data::point::end]);
|
||||
current = *next;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
auto all{onward(false)};
|
||||
std::reverse(all.begin(), all.end());
|
||||
auto const first{all.size()};
|
||||
all.insert(all.end(), runs.begin(), runs.end());
|
||||
auto const after{onward(true)};
|
||||
all.insert(all.end(), after.begin(), after.end());
|
||||
// a point every half metre, as frame_points has them: the cant leaning the track to where the headings grow above 0
|
||||
auto const gauge{m_route.design.norms.gauge};
|
||||
std::vector<switch_curve::track_point> points;
|
||||
glm::dvec2 last{0.0};
|
||||
for (std::size_t i = 0; i < all.size(); ++i)
|
||||
{
|
||||
auto const &[track, forward]{all[i]};
|
||||
auto const &path{track->m_paths.front()};
|
||||
std::vector<segment_data const *> parts;
|
||||
if (path.pieces.empty())
|
||||
parts.push_back(&path);
|
||||
for (auto const &piece : path.pieces)
|
||||
parts.push_back(&piece);
|
||||
if (false == forward)
|
||||
std::reverse(parts.begin(), parts.end());
|
||||
auto entered{false};
|
||||
for (auto const *part : parts)
|
||||
{
|
||||
bezier const curve{*part};
|
||||
auto const steps{std::max(4, static_cast<int>(std::ceil(curve.plan_length() / 0.5)))};
|
||||
for (int k = 0; k <= steps; ++k)
|
||||
{
|
||||
auto const t{forward ? static_cast<double>(k) / steps : 1.0 - static_cast<double>(k) / steps};
|
||||
auto const position{plan_of(curve.point(t))};
|
||||
auto const station{points.empty() ? 0.0 : points.back().station + glm::distance(position, last)};
|
||||
if (i == first && false == entered)
|
||||
{
|
||||
Offset = station;
|
||||
entered = true;
|
||||
}
|
||||
// the point a path ends with is the one the next starts with
|
||||
if (false == points.empty() && glm::distance(position, last) < 1e-4)
|
||||
continue;
|
||||
auto const tangent{plan_of(forward ? curve.first(t) : -curve.first(t))};
|
||||
switch_curve::track_point point;
|
||||
point.station = station;
|
||||
point.heading = std::atan2(tangent.y, tangent.x);
|
||||
if (false == points.empty())
|
||||
point.heading = points.back().heading + std::remainder(point.heading - points.back().heading, 2.0 * glm::pi<double>());
|
||||
auto const roll{part->rolls[0] + (part->rolls[1] - part->rolls[0]) * t};
|
||||
point.cant = gauge * std::sin(glm::radians(static_cast<double>(forward ? roll : -roll)));
|
||||
points.push_back(point);
|
||||
last = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
editor_track::chain editor_mode::frame_chain(std::vector<curve_sample> const &Frame, std::vector<TTrack *> const &Tracks)
|
||||
{
|
||||
editor_track::chain chain;
|
||||
for (auto *track : Tracks)
|
||||
{
|
||||
if (track == nullptr || track->m_paths.empty())
|
||||
continue;
|
||||
auto const &path{track->m_paths.front()};
|
||||
chain.tracks.push_back(track);
|
||||
chain.forward.push_back(nearest_station(Frame, path.points[segment_data::point::start]) <= nearest_station(Frame, path.points[segment_data::point::end]));
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
|
||||
editor_track::chain editor_mode::straight_chain(editor_track::straight const &Line)
|
||||
{
|
||||
std::vector<std::pair<double, std::size_t>> order;
|
||||
for (std::size_t i = 0; i < std::min(Line.tracks.size(), Line.paths.size()); ++i)
|
||||
if (Line.tracks[i] != nullptr && Line.paths[i] == 0 && false == Line.tracks[i]->m_paths.empty())
|
||||
{
|
||||
auto const &path{Line.tracks[i]->m_paths.front()};
|
||||
order.emplace_back(std::min(Line.along(path.points[segment_data::point::start]), Line.along(path.points[segment_data::point::end])), i);
|
||||
}
|
||||
std::sort(order.begin(), order.end());
|
||||
editor_track::chain chain;
|
||||
for (auto const &[along, i] : order)
|
||||
{
|
||||
auto const &path{Line.tracks[i]->m_paths.front()};
|
||||
chain.tracks.push_back(Line.tracks[i]);
|
||||
chain.forward.push_back(Line.along(path.points[segment_data::point::end]) >= Line.along(path.points[segment_data::point::start]));
|
||||
}
|
||||
return chain;
|
||||
}
|
||||
|
||||
double editor_mode::branch_speed_of(TTrack const &Switch, double const Radius, double const Ratio, std::string *Why) const
|
||||
{
|
||||
if (Why != nullptr)
|
||||
Why->clear();
|
||||
if (Switch.eType != tt_Switch || Switch.m_paths.size() < 2)
|
||||
return -1.0;
|
||||
auto const &main{Switch.m_paths[0]};
|
||||
auto const &diverging{Switch.m_paths[1]};
|
||||
auto const heading{plan_of(bezier{main}.first(0.0))};
|
||||
if (glm::length(heading) < 1e-9)
|
||||
return -1.0;
|
||||
// the side the diverging track leaves to, the one where the headings grow above 0, as the main radius of the store is signed
|
||||
auto const side{cross(heading, plan_of(diverging.points[segment_data::point::end] - main.points[segment_data::point::start])) >= 0.0 ? 1.0 : -1.0};
|
||||
// of the basic switch, else of the diverging track as it lies, bent already
|
||||
auto const basic{Radius > 0.5 ? Radius : editor_track::branch_radius(diverging)};
|
||||
if (basic <= 0.5)
|
||||
return -1.0;
|
||||
// bent with the main track, one-sided where it turns the way the diverging track does, table 11.8: signed the way the diverging track
|
||||
// turns off it, below 0 the other way
|
||||
auto radius{basic};
|
||||
if (auto const bend{bent_main_radius(main)}; Radius > 0.5 && bend != 0.0)
|
||||
radius = switch_curve::bent_radius((bend > 0.0) == (side > 0.0) ? std::abs(bend) : -std::abs(bend), Radius, Ratio);
|
||||
// the cant of the line under it with its sign: above 0 leaning into the turn of the diverging track, below 0 against it. A roll above
|
||||
// 0 leans the track to where the headings grow
|
||||
auto const roll{0.5 * (static_cast<double>(diverging.rolls[0]) + static_cast<double>(diverging.rolls[1]))};
|
||||
auto const cant{m_route.design.norms.gauge * std::sin(glm::radians(roll)) * (radius >= 0.0 ? side : -side)};
|
||||
auto const deficiency{switch_curve::switch_deficiency(Switch.SwitchExtension != nullptr && Switch.SwitchExtension->m_movablenose).normal};
|
||||
auto const formula{switch_curve::curve_speed(std::abs(radius), cant, deficiency)};
|
||||
// no more than the basic switch has: table 11.2, which the formula gives for a fixed frog, a movable nose kept to it as Id-4 keeps it
|
||||
auto const table{editor_track::diverging_speed(basic)};
|
||||
auto const rounded{std::isinf(formula) ? table : speed_check::suggested(formula)};
|
||||
auto const speed{std::min(table, rounded)};
|
||||
if (Why != nullptr)
|
||||
{
|
||||
*Why = format(STR_C("Speed on the diverging track %.0f km/h"), speed);
|
||||
if (std::abs(radius - basic) > 0.5 || std::abs(cant) > 0.5)
|
||||
*Why += format(STR_C(": R %.0f m, cant %+.0f mm into its turn, I up to %.0f mm (formula 9.9, table 9.7)"), std::abs(radius), cant, deficiency);
|
||||
if (rounded > table)
|
||||
*Why += format(STR_C(", no more than %.0f km/h of the basic switch (table 11.2)"), table);
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
std::string editor_mode::write_switch_speed(TTrack &Switch, double const Radius, double const Ratio, double const Main)
|
||||
{
|
||||
std::string why;
|
||||
auto const speed{branch_speed_of(Switch, Radius, Ratio, &why)};
|
||||
if (speed <= 0.0)
|
||||
return {};
|
||||
// one value for both tracks of a switch: the own limit of the main track where it's the lower, for both, else the one of the diverging
|
||||
// track for it alone, below 0
|
||||
editor_track::velocity(Switch, Main > 0.0 && Main <= speed ? Main : -std::max(2.0, speed));
|
||||
return why;
|
||||
}
|
||||
|
||||
void editor_mode::curved_switch_pose(int &Direction, int &Side) const
|
||||
{
|
||||
auto const &tool{m_switch};
|
||||
@@ -1872,7 +2163,18 @@ double editor_mode::curved_switch_start(int const Direction, std::string *What)
|
||||
return tool.pressed;
|
||||
auto const length{tool.templates[tool.armed].length};
|
||||
std::string what;
|
||||
auto start{switch_curve::snapped_start(switch_curve::ramp_ends(frame_points(tool.frame)), tool.pressed, length, Direction, 3.0, &what)};
|
||||
// the ends of the ramps past the ends of the curve too, along it
|
||||
double offset{0.0};
|
||||
auto line{line_points(frame_chain(tool.frame, tool.frame_tracks), kRampReach, offset)};
|
||||
if (line.size() < 2)
|
||||
{
|
||||
line = frame_points(tool.frame);
|
||||
offset = 0.0;
|
||||
}
|
||||
auto ramps{switch_curve::ramp_ends(line)};
|
||||
for (auto &end : ramps)
|
||||
end -= offset;
|
||||
auto start{switch_curve::snapped_start(ramps, tool.pressed, length, Direction, 3.0, &what)};
|
||||
// as on a straight, an end of the switch within half a metre of a joint of the tracks goes right onto it: no path of a few centimetres
|
||||
// left beside it, no gap at it
|
||||
constexpr double kJointPull{0.5};
|
||||
@@ -1997,14 +2299,41 @@ std::vector<switch_curve::track_point> plan_points(segment_data const &Path)
|
||||
|
||||
} // namespace
|
||||
|
||||
switch_curve::switch_report editor_mode::curved_switch_report(std::vector<segment_data> const &Paths, std::vector<curve_sample> const &Frame, double const Station, int const Direction) const
|
||||
switch_curve::switch_report editor_mode::curved_switch_report(std::vector<segment_data> const &Paths, std::vector<curve_sample> const &Frame, double const Station, int const Direction, std::vector<TTrack *> const *Tracks) const
|
||||
{
|
||||
auto const &tool{m_switch};
|
||||
if (Paths.size() < 2 || tool.armed < 0 || tool.armed >= static_cast<int>(tool.templates.size()))
|
||||
return {};
|
||||
auto const &shape{tool.templates[tool.armed]};
|
||||
auto const frog{frog_zone(shape)};
|
||||
return switch_curve::check(plan_points(Paths[0]), plan_points(Paths[1]), frame_points(Frame), Station, Station + Direction * shape.length, shape.radius, shape.ratio, frog.has_value() ? shape.length - *frog : 0.0);
|
||||
// the line on past the ends of the curve too, for the ends of the cant ramps there
|
||||
double offset{0.0};
|
||||
auto line{Tracks != nullptr ? line_points(frame_chain(Frame, *Tracks), kRampReach, offset) : std::vector<switch_curve::track_point>{}};
|
||||
if (line.size() < 2)
|
||||
{
|
||||
line = frame_points(Frame);
|
||||
offset = 0.0;
|
||||
}
|
||||
return switch_curve::check(plan_points(Paths[0]), plan_points(Paths[1]), line, offset + Station, offset + Station + Direction * shape.length, shape.radius, shape.ratio, frog.has_value() ? shape.length - *frog : 0.0,
|
||||
shape.twofold());
|
||||
}
|
||||
|
||||
switch_curve::switch_report editor_mode::bent_switch_report(TTrack const &Switch, std::vector<curve_sample> const &Frame, std::vector<TTrack *> const &Tracks, std::vector<segment_data> const &Paths) const
|
||||
{
|
||||
if (Paths.size() < 2 || Frame.size() < 2)
|
||||
return {};
|
||||
// of the type of its record, for the limits of table 11.9; the hard rules need none
|
||||
auto const known{switch_store::named(Switch)};
|
||||
double offset{0.0};
|
||||
auto line{line_points(frame_chain(Frame, Tracks), kRampReach, offset)};
|
||||
if (line.size() < 2)
|
||||
{
|
||||
line = frame_points(Frame);
|
||||
offset = 0.0;
|
||||
}
|
||||
auto const &main{Paths.front()};
|
||||
return switch_curve::check(plan_points(Paths[0]), plan_points(Paths[1]), line, offset + nearest_station(Frame, main.points[segment_data::point::start]), offset + nearest_station(Frame, main.points[segment_data::point::end]),
|
||||
known.has_value() ? known->radius : 0.0, known.has_value() ? known->ratio : 0.0);
|
||||
}
|
||||
|
||||
segment_data editor_mode::frame_path(segment_data const &Local, std::vector<curve_sample> const &Frame, double const Station, int const Direction, int const Side, std::optional<double> const &Bent)
|
||||
@@ -2113,6 +2442,15 @@ void editor_mode::insert_curved_switch(int const Direction, int const Side)
|
||||
auto const station{std::clamp(tool.along, Direction > 0 ? 0.0 : shape.length, Direction > 0 ? total - shape.length : total)};
|
||||
auto const from{Direction > 0 ? station : station - shape.length};
|
||||
auto const to{from + shape.length};
|
||||
// the switch as it'll lie, judged by the norms before a track is cut: one breaking a hard rule isn't laid, the tracks as they were
|
||||
auto const paths{curved_switch_paths(shape, tool.frame, station, Direction, Side)};
|
||||
auto const report{curved_switch_report(paths, tool.frame, station, Direction, &tool.frame_tracks)};
|
||||
if (false == report.refusals.empty())
|
||||
{
|
||||
tool.status = refused(switch_refusal(report.refusals, true));
|
||||
flash_switch_problem(tool.status, {paths.begin(), paths.begin() + std::min<std::size_t>(2, paths.size())}, {{sample_at(tool.frame, station).position, ""}});
|
||||
return;
|
||||
}
|
||||
editor_track::edit edit;
|
||||
// a track of the scenery changed: its state before kept once for Ctrl+Z, none for one made here
|
||||
auto const keep = [&](TTrack &Track) {
|
||||
@@ -2160,7 +2498,6 @@ void editor_mode::insert_curved_switch(int const Direction, int const Side)
|
||||
edit.removed.push_back(candidate);
|
||||
}
|
||||
}
|
||||
auto const paths{curved_switch_paths(shape, tool.frame, station, Direction, Side)};
|
||||
// a joint a few centimetres off an end of the switch, not cut there: the end of the track left beside it goes right onto the end of
|
||||
// the switch, so the two join and no gap is left; the end of one bent up to the frog is fitted to it further on
|
||||
std::vector<TTrack *> snapped;
|
||||
@@ -2186,7 +2523,6 @@ void editor_mode::insert_curved_switch(int const Direction, int const Side)
|
||||
}
|
||||
}
|
||||
editor_track::commit(snapped);
|
||||
auto const report{curved_switch_report(paths, tool.frame, station, Direction)};
|
||||
// a switch bent up to the frog leaves the curve straight, a little off it at its end: the track going on from there along the line
|
||||
// starts where the switch ends, heading as it does, and meets the line again at its other end
|
||||
std::string fitted;
|
||||
@@ -2533,6 +2869,13 @@ void editor_mode::insert_curved_slip(int const Direction, int const Side)
|
||||
return;
|
||||
}
|
||||
auto const report{curved_slip_report(plan, shape.type)};
|
||||
// bent into the curve: none laid, the tracks as they were (11.4 pkt 4b)
|
||||
if (false == report.refusals.empty())
|
||||
{
|
||||
tool.status = refused(switch_refusal(report.refusals, true));
|
||||
flash_switch_problem(tool.status, curved_slip_lines(plan, shape.type), {{sample_at(tool.frame, plan.middle).position, ""}});
|
||||
return;
|
||||
}
|
||||
std::vector<std::pair<TTrack *, editor_track::state>> states;
|
||||
std::vector<TTrack *> created;
|
||||
std::vector<TTrack *> removed;
|
||||
|
||||
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "editor/editorFormat.hpp"
|
||||
#include "editor/editorAlignmentStore.hpp"
|
||||
#include "editor/editorSwitchStore.hpp"
|
||||
#include "editor/editorSpeed.hpp"
|
||||
#include "editor/editorGeometry.hpp"
|
||||
|
||||
#include "world/Track.h"
|
||||
@@ -517,6 +518,13 @@ bool editor_mode::move_switch_paths(TTrack &Track, std::vector<segment_data> con
|
||||
Status = reason;
|
||||
return false;
|
||||
}
|
||||
// where it goes, the cant of the line under it and near it as at laying it: one breaking a hard rule stays as it is
|
||||
if (auto const refusal{straight_switch_refusal(editor_track::find_straight(Track, m_straights.tolerance), Paths.front().points[segment_data::point::start], Paths.front().points[segment_data::point::end], false, {&Track})};
|
||||
false == refusal.empty())
|
||||
{
|
||||
Status = refusal;
|
||||
return false;
|
||||
}
|
||||
auto const ends{switch_end_moves(Track, Paths.front(), online, {low, high}, m_straights.tolerance.offset, Status)};
|
||||
if (false == ends.has_value())
|
||||
return false;
|
||||
@@ -619,6 +627,14 @@ bool editor_mode::move_double_paths(double_switch const &Set, std::vector<segmen
|
||||
Status = reason;
|
||||
return false;
|
||||
}
|
||||
// where it goes, the cant of the line under both its switches and near them as at laying it: one breaking a hard rule stays as it is
|
||||
if (auto const refusal{straight_switch_refusal(editor_track::find_straight(*Set.first, m_straights.tolerance), Paths[0].points[segment_data::point::start], Paths[2].points[segment_data::point::end], false,
|
||||
{Set.first, Set.link, Set.second})};
|
||||
false == refusal.empty())
|
||||
{
|
||||
Status = refusal;
|
||||
return false;
|
||||
}
|
||||
struct outer_end
|
||||
{
|
||||
TTrack *track{nullptr};
|
||||
@@ -914,7 +930,11 @@ bool editor_mode::slide_bent_switch(TTrack &Track, double const Distance)
|
||||
switch_store::follow();
|
||||
records_to_history();
|
||||
straight_refresh();
|
||||
m_switch.status = format(STR_C("Switch %s moved %.2f m along the curve"), Track.name().c_str(), distance) + (notes.empty() ? "" : "\n") + notes;
|
||||
// bent where it lies now: the speed on its diverging track as there, of the type of its record
|
||||
std::string speed;
|
||||
if (auto const known{switch_store::named(Track)}; known.has_value() && known->radius > 0.0)
|
||||
speed = write_switch_speed(Track, known->radius, known->ratio, speed_check::path_velocity(Track, 0));
|
||||
m_switch.status = format(STR_C("Switch %s moved %.2f m along the curve"), Track.name().c_str(), distance) + (notes.empty() ? "" : "\n") + notes + (speed.empty() ? "" : "\n") + speed;
|
||||
ui()->set_status(m_switch.status, false == notes.empty());
|
||||
return true;
|
||||
}
|
||||
@@ -924,6 +944,13 @@ bool editor_mode::lay_bent_switch(TTrack &Track, std::vector<curve_sample> const
|
||||
Notes.clear();
|
||||
if (Paths.size() < 2 || Frame.size() < 2)
|
||||
return false;
|
||||
// where it goes, as at laying it into the curve: the curvatures of its tracks, the cant of the line under it and near it; one breaking a
|
||||
// hard rule stays as it is
|
||||
if (auto const report{bent_switch_report(Track, Frame, {Sides[0], &Track, Sides[1]}, Paths)}; false == report.refusals.empty())
|
||||
{
|
||||
Notes = switch_refusal(report.refusals, false);
|
||||
return false;
|
||||
}
|
||||
auto const &main{Paths.front()};
|
||||
// where the new ends of the switch fall along the curve, within the tracks next to it
|
||||
std::array<double, 2> const ends{nearest_station(Frame, main.points[segment_data::point::start]), nearest_station(Frame, main.points[segment_data::point::end])};
|
||||
|
||||
@@ -17,6 +17,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "editor/editorFormat.hpp"
|
||||
#include "editor/editorGeometry.hpp"
|
||||
#include "editor/editorSwitchStore.hpp"
|
||||
#include "editor/editorSpeed.hpp"
|
||||
#include "simulation/simulation.h"
|
||||
#include "utilities/translation.h"
|
||||
#include "world/Track.h"
|
||||
@@ -366,6 +367,8 @@ bool editor_mode::apply_switch_template(TTrack &Switch, editor_track::switch_tem
|
||||
return false;
|
||||
auto const &main{first.m_paths[0]};
|
||||
auto const &diverging{first.m_paths[1]};
|
||||
// the own limit of the main track, kept where it's lower than the speed of the diverging track of the new template
|
||||
auto const limit{speed_check::path_velocity(first, 0)};
|
||||
if (set.has_value() || false == has_controls(main))
|
||||
{
|
||||
// along the straight: the start and the direction of the switch kept
|
||||
@@ -435,6 +438,10 @@ bool editor_mode::apply_switch_template(TTrack &Switch, editor_track::switch_tem
|
||||
extension->m_bladethrow = Shape.bladethrow;
|
||||
editor_track::commit_parameters(*track);
|
||||
}
|
||||
// the speed on the diverging track of the new template, as it lies, none of the old one kept
|
||||
for (auto *track : {&first, set.has_value() ? set->second : nullptr})
|
||||
if (track != nullptr)
|
||||
write_switch_speed(*track, Shape.radius, Shape.ratio, limit);
|
||||
if (set.has_value())
|
||||
record_double(*set->first, *set->second, Shape);
|
||||
else
|
||||
|
||||
@@ -2883,6 +2883,9 @@ void editor_mode::draw_build_overlay() const
|
||||
if (projection.project(bend.target.position, screen))
|
||||
drawlist->AddCircle(screen, 14.0f, bend.problem.empty() ? IM_COL32(255, 60, 255, 255) : overlay_color::invalid, 20, 3.0f);
|
||||
}
|
||||
// what it breaks first: it isn't laid so
|
||||
for (auto const &refusal : bend.report.refusals)
|
||||
lines.emplace_back(refusal, overlay_color::invalid);
|
||||
for (auto const &warning : bend.report.warnings)
|
||||
lines.emplace_back(warning, overlay_color::invalid);
|
||||
}
|
||||
@@ -2923,12 +2926,14 @@ void editor_mode::draw_build_overlay() const
|
||||
for (auto const &line : slip_report_lines(report))
|
||||
lines.emplace_back(line, IM_COL32(255, 255, 255, 235));
|
||||
notes = report.notes;
|
||||
warnings = report.warnings;
|
||||
// what it breaks first: it isn't laid so
|
||||
warnings = report.refusals;
|
||||
warnings.insert(warnings.end(), report.warnings.begin(), report.warnings.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
station = curved_switch_start(forward, &snapped);
|
||||
auto const report{curved_switch_report(preview, m_switch.frame, station, forward)};
|
||||
auto const report{curved_switch_report(preview, m_switch.frame, station, forward, &m_switch.frame_tracks)};
|
||||
if (report.curved)
|
||||
{
|
||||
lines.emplace_back(format(STR_C("main track R %s at the start, %s at the end"), radius(report.main_start).c_str(), radius(report.main_end).c_str()), IM_COL32(255, 255, 255, 235));
|
||||
@@ -2936,7 +2941,8 @@ void editor_mode::draw_build_overlay() const
|
||||
}
|
||||
lines.emplace_back(format(STR_C("cant %.0f mm at the start, %.0f mm at the end"), report.cant_start, report.cant_end), IM_COL32(255, 255, 255, 235));
|
||||
notes = report.notes;
|
||||
warnings = report.warnings;
|
||||
warnings = report.refusals;
|
||||
warnings.insert(warnings.end(), report.warnings.begin(), report.warnings.end());
|
||||
}
|
||||
if (false == snapped.empty())
|
||||
lines.emplace(lines.begin(), snapped, IM_COL32(255, 170, 40, 255));
|
||||
|
||||
@@ -32,15 +32,14 @@ constexpr double kRampClear{6.0};
|
||||
constexpr double kSideRadius{180.0};
|
||||
|
||||
// the curved switches bent from the basic ones, table 11.9: the radius of the basic switch, the limiting curvature of the
|
||||
// diverging track and the least radius of the main track; the values in its brackets, allowed only by way of exception, are past
|
||||
// them as well
|
||||
struct bent_limit
|
||||
{
|
||||
double radius;
|
||||
double branch;
|
||||
double main;
|
||||
};
|
||||
constexpr bent_limit kBent[]{{300.0, 4.000e-3, 1505.522}, {500.0, 4.000e-3, 501.730}, {760.0, 3.333e-3, 497.250}, {1200.0, 2.169e-3, 750.001}, {2500.0, 1.063e-3, 1510.0}};
|
||||
// diverging track and the least radius of the main track, then the values in its brackets, allowed only by way of exception
|
||||
constexpr bent_limit kBent[]{{300.0, 4.000e-3, 1505.522, 4.673e-3, 749.722},
|
||||
{500.0, 4.000e-3, 501.730, 4.673e-3, 375.638},
|
||||
{760.0, 3.333e-3, 497.250, 3.333e-3, 497.250},
|
||||
{1200.0, 2.169e-3, 750.001, 2.169e-3, 750.001},
|
||||
{2500.0, 1.063e-3, 1510.0, 1.063e-3, 1510.0}};
|
||||
// formula 9.9: I = 11.8 V^2 / R - D, the standard gauge in it
|
||||
constexpr double kDeficiencyFactor{11.8};
|
||||
|
||||
double heading_at(std::vector<track_point> const &Track, double const Station)
|
||||
{
|
||||
@@ -67,23 +66,25 @@ double cant_at(std::vector<track_point> const &Track, double const Station)
|
||||
}
|
||||
|
||||
// the cant of the line over a switch From to To along it: the same all along it, a ramp off it by 6 m at least or ending at its ends
|
||||
// (11.4 pkt 7, 9.6 pkt 16-17), as much as table 9.6 lets a switch have, Curved or straight
|
||||
void check_cant(std::vector<track_point> const &Line, double const From, double const To, bool const Curved, double &Start, double &End, std::vector<std::string> &Notes, std::vector<std::string> &Warnings)
|
||||
// (11.4 pkt 7, 9.6 pkt 16-17), as much as table 9.6 lets a switch have, Curved or straight. A ramp under the switch or ending near it
|
||||
// isn't one the switch is laid or moved with, an end of one right at an end of the switch is
|
||||
void check_cant(std::vector<track_point> const &Line, double const From, double const To, bool const Curved, double &Start, double &End, std::vector<std::string> &Notes, std::vector<std::string> &Warnings,
|
||||
std::vector<std::string> &Refusals)
|
||||
{
|
||||
Start = std::abs(cant_at(Line, From));
|
||||
End = std::abs(cant_at(Line, To));
|
||||
if (std::abs(End - Start) > 1.0)
|
||||
Warnings.emplace_back(format(STR_C("The cant changes within the switch, %.0f to %.0f mm: it's to stay the same over it (11.4 pkt 7)"), Start, End));
|
||||
Refusals.emplace_back(format(STR_C("The cant changes within the switch, %.0f to %.0f mm: it's to stay the same over it (11.4 pkt 7)"), Start, End));
|
||||
auto const low{std::min(From, To)};
|
||||
auto const high{std::max(From, To)};
|
||||
for (auto const end : ramp_ends(Line))
|
||||
{
|
||||
if (end > low + kAtEnd && end < high - kAtEnd)
|
||||
Warnings.emplace_back(format(STR_C("A cant ramp starts or ends within the switch, %.1f m from its start: at the start or the end of the switch, or 6 m off it at least (9.6 pkt 16-17)"), std::abs(end - From)));
|
||||
Refusals.emplace_back(format(STR_C("A cant ramp starts or ends within the switch, %.1f m from its start: at the start or the end of the switch, or 6 m off it at least (9.6 pkt 16-17)"), std::abs(end - From)));
|
||||
else if (std::abs(end - low) <= kAtEnd || std::abs(end - high) <= kAtEnd)
|
||||
Notes.emplace_back(STR_C("A cant ramp starts or ends at an end of the switch"));
|
||||
else if (auto const off{end < low ? low - end : end - high}; off < kRampClear)
|
||||
Warnings.emplace_back(format(STR_C("A cant ramp ends %.1f m off the switch, 6 m at least (9.6 pkt 16)"), off));
|
||||
Refusals.emplace_back(format(STR_C("A cant ramp ends %.1f m off the switch, 6 m at least (9.6 pkt 16)"), off));
|
||||
}
|
||||
auto const cant{std::max(Start, End)};
|
||||
if (Curved && cant > 100.0 + 1e-6)
|
||||
@@ -133,7 +134,7 @@ std::vector<double> ramp_ends(std::vector<track_point> const &Track)
|
||||
}
|
||||
|
||||
switch_report check(std::vector<track_point> const &Main, std::vector<track_point> const &Branch, std::vector<track_point> const &Line, double const From, double const To, double const Radius,
|
||||
double const Ratio, double const Straight)
|
||||
double const Ratio, double const Straight, bool const Double)
|
||||
{
|
||||
switch_report report;
|
||||
if (Main.size() < 2 || Branch.size() < 2 || Line.size() < 2)
|
||||
@@ -178,9 +179,14 @@ switch_report check(std::vector<track_point> const &Main, std::vector<track_poin
|
||||
|
||||
// the curvature of each track of one sign all along it, the cases KZW I and KZW III of 9.7 pkt 12, not KZW II
|
||||
if (branch.low < -kStraight && branch.high > kStraight)
|
||||
report.warnings.emplace_back(STR_C("The curvature of the diverging track turns from one side to the other within the switch (KZW II), which isn't allowed (9.7 pkt 12)"));
|
||||
report.refusals.emplace_back(format(STR_C("The curvature of the diverging track turns from one side to the other within the switch (KZW II), R %.0f m one way and R %.0f m the other, which isn't allowed (9.7 pkt 12)"),
|
||||
1.0 / branch.high, -1.0 / branch.low));
|
||||
if (main.low < -kStraight && main.high > kStraight)
|
||||
report.warnings.emplace_back(STR_C("The curvature of the main track turns from one side to the other within the switch, which isn't allowed (9.7 pkt 12)"));
|
||||
report.refusals.emplace_back(format(STR_C("The curvature of the main track turns from one side to the other within the switch, R %.0f m one way and R %.0f m the other, which isn't allowed (9.7 pkt 12)"),
|
||||
1.0 / main.high, -1.0 / main.low));
|
||||
// the editor tells no main track from a side one: a double switch is bent nowhere
|
||||
if (report.curved && Double)
|
||||
report.refusals.emplace_back(format(STR_C("Bent into R %.0f m: no double switch, slip nor crossing is bent (11.4 pkt 4)"), 1.0 / main.sharpest));
|
||||
if (report.curved)
|
||||
{
|
||||
auto const limit{std::find_if(std::begin(kBent), std::end(kBent), [&](bent_limit const &Limit) { return std::abs(Limit.radius - Radius) < 2.0; })};
|
||||
@@ -194,19 +200,68 @@ switch_report check(std::vector<track_point> const &Main, std::vector<track_poin
|
||||
report.warnings.emplace_back(format(STR_C("The main track bent to R %.0f m, below the least %.0f m for the switch of R %.0f m (table 11.9)"), 1.0 / main.sharpest, limit->main, Radius));
|
||||
}
|
||||
// 1:9 itself is bent, as the Rz 300-1:9 of table 11.9; the ratio may come from the angle of the tracks, a bit off the catalogue,
|
||||
// 1:9.403 told from 1:9.51 by half of what keeps them apart
|
||||
// 1:9.403 told from 1:9.51 by half of what keeps them apart. A warning only: the rule holds in the running and the main tracks,
|
||||
// which the editor doesn't tell from the side ones
|
||||
if (Ratio > 0.0 && (Ratio < 8.95 || std::abs(Ratio - 9.403) < 0.05))
|
||||
report.warnings.emplace_back(format(STR_C("A switch of 1:%.3f isn't bent in the running and the main tracks: none of 1:9.403 nor steeper than 1:9 (11.4 pkt 4)"), Ratio));
|
||||
report.warnings.emplace_back(format(STR_C("A switch of 1:%.3f isn't bent in the running and the main tracks: none of 1:9.403 nor steeper than 1:9 (11.4 pkt 4). The editor doesn't tell a main track from a side one, so it only warns"), Ratio));
|
||||
// the basic switches of table 11.9 have the curve of the diverging track running through the frog; one with a straight frog is
|
||||
// bent up to the frog, the frog and both tracks over it straight, the curvature jumping there
|
||||
if (Straight > 0.5)
|
||||
report.warnings.emplace_back(format(STR_C("Bent up to the frog, as the DB bends the switches with a straight frog: both tracks keep straight over its last %.1f m, the curvature jumps there; table 11.9 lists no such bent switch"), Straight));
|
||||
}
|
||||
|
||||
check_cant(Line, From, To, report.curved, report.cant_start, report.cant_end, report.notes, report.warnings);
|
||||
check_cant(Line, From, To, report.curved, report.cant_start, report.cant_end, report.notes, report.warnings, report.refusals);
|
||||
return report;
|
||||
}
|
||||
|
||||
switch_report check_line(std::vector<track_point> const &Line, double const From, double const To)
|
||||
{
|
||||
switch_report report;
|
||||
if (Line.size() >= 2)
|
||||
check_cant(Line, From, To, false, report.cant_start, report.cant_end, report.notes, report.warnings, report.refusals);
|
||||
return report;
|
||||
}
|
||||
|
||||
std::optional<bent_limit> bent_limit_of(double const Radius)
|
||||
{
|
||||
auto const limit{std::find_if(std::begin(kBent), std::end(kBent), [&](bent_limit const &Limit) { return std::abs(Limit.radius - Radius) < 2.0; })};
|
||||
if (limit == std::end(kBent))
|
||||
return std::nullopt;
|
||||
return *limit;
|
||||
}
|
||||
|
||||
double bent_radius(double const Main, double const Radius, double const Ratio)
|
||||
{
|
||||
if (Radius <= 0.0)
|
||||
return 0.0;
|
||||
if (std::abs(Main) < 1e-6)
|
||||
return Radius;
|
||||
auto const tangent{Ratio > 0.0 ? Radius * std::tan(0.5 * std::atan(1.0 / Ratio)) : 0.0};
|
||||
auto const product{std::abs(Main) * Radius};
|
||||
auto const squared{tangent * tangent};
|
||||
// a) two-sided, the main track bent against the diverging one, and b) one-sided, the main track bent with it: r" = (R r -+ t^2) / (R +- r);
|
||||
// the main track sharper than the diverging curve takes the diverging track past straight, the one-sided switch of b) bent from its
|
||||
// diverging track: r" = (R r + t^2) / (r - R)
|
||||
if (Main > 0.0)
|
||||
return (product - squared) / (Main + Radius);
|
||||
auto const apart{-Main - Radius};
|
||||
if (std::abs(apart) < 1e-6)
|
||||
return 0.0;
|
||||
return (product + squared) / apart;
|
||||
}
|
||||
|
||||
deficiency switch_deficiency(bool const Movable)
|
||||
{
|
||||
return Movable ? deficiency{100.0, 130.0, 130.0} : deficiency{90.0, 110.0, 110.0};
|
||||
}
|
||||
|
||||
double curve_speed(double const Radius, double const Cant, double const Deficiency)
|
||||
{
|
||||
if (Radius <= 0.0)
|
||||
return std::numeric_limits<double>::infinity();
|
||||
return std::sqrt(std::max(0.0, Deficiency + Cant) * Radius / kDeficiencyFactor);
|
||||
}
|
||||
|
||||
slip_report check_slip(std::vector<std::vector<track_point>> const &Tracks, std::vector<std::vector<track_point>> const &Curves, std::vector<track_point> const &Line, double const From, double const To)
|
||||
{
|
||||
slip_report report;
|
||||
@@ -239,26 +294,29 @@ slip_report check_slip(std::vector<std::vector<track_point>> const &Tracks, std:
|
||||
// the curvature of each track through it of one sign all along it, as in the main track of a switch (9.7 pkt 12); the slip curves
|
||||
// begin with the leads along the stock rails, which bend with the line even where the curve turns against it
|
||||
auto turning{false};
|
||||
double sharpest{0.0};
|
||||
for (auto const &track : Tracks)
|
||||
{
|
||||
auto const curvatures{along(track)};
|
||||
report.curved = report.curved || curvatures.sharpest > kStraight;
|
||||
sharpest = std::max(sharpest, curvatures.sharpest);
|
||||
turning = turning || (curvatures.low < -kStraight && curvatures.high > kStraight);
|
||||
}
|
||||
if (turning)
|
||||
report.warnings.emplace_back(STR_C("The curvature of a track through the slip turns from one side to the other within it, which isn't allowed (9.7 pkt 12)"));
|
||||
report.refusals.emplace_back(STR_C("The curvature of a track through the slip turns from one side to the other within it, which isn't allowed (9.7 pkt 12)"));
|
||||
for (auto const &curve : Curves)
|
||||
if (curve.size() >= 2)
|
||||
report.curves.push_back(along(curve).sharpest);
|
||||
if (report.curved)
|
||||
{
|
||||
report.warnings.emplace_back(STR_C("A slip isn't bent in the running nor in the main tracks, a bent one goes into a side track only (11.4 pkt 4b)"));
|
||||
// the editor tells no main track from a side one: a slip is bent nowhere
|
||||
report.refusals.emplace_back(format(STR_C("Bent into R %.0f m: no double switch, slip nor crossing is bent (11.4 pkt 4)"), 1.0 / sharpest));
|
||||
// bent the way the curve of the slip turns it gets sharper: no sharper than the side tracks take
|
||||
for (auto const curvature : report.curves)
|
||||
if (curvature > 1.0 / kSideRadius + 1e-9)
|
||||
report.warnings.emplace_back(format(STR_C("A slip curve bent to R %.0f m, below the least %.0f m of a side track (table 9.2)"), 1.0 / curvature, kSideRadius));
|
||||
}
|
||||
check_cant(Line, From, To, report.curved, report.cant_start, report.cant_end, report.notes, report.warnings);
|
||||
check_cant(Line, From, To, report.curved, report.cant_start, report.cant_end, report.notes, report.warnings, report.refusals);
|
||||
if (report.curved && std::max(report.cant_start, report.cant_end) > 1.0)
|
||||
report.notes.emplace_back(STR_C("In a side track the layouts needing no cant are recommended (9.3 pkt 5)"));
|
||||
return report;
|
||||
|
||||
@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -47,18 +48,57 @@ struct switch_report
|
||||
bool transition{false}; // its curvature changing along the switch
|
||||
std::vector<std::string> notes;
|
||||
std::vector<std::string> warnings;
|
||||
// the hard rules broken (11.4 pkt 4 and 7, 9.6 pkt 16, 9.7 pkt 12): the switch isn't laid nor moved so
|
||||
std::vector<std::string> refusals;
|
||||
};
|
||||
|
||||
// Main, Branch: the tracks of the switch from its start, the stations from 0 there; Line: the track it's laid into, From and To the
|
||||
// stations of the start and the end of the switch along it, From after To where it goes back along the line. Radius and Ratio:
|
||||
// of the diverging track of the basic switch it's bent from; Straight: how far both tracks keep straight at the end of the switch, over
|
||||
// a straight frog, the switch bent up to it as the DB bends such switches
|
||||
// a straight frog, the switch bent up to it as the DB bends such switches; Double: a double switch, which isn't bent (11.4 pkt 4a)
|
||||
switch_report check(std::vector<track_point> const &Main, std::vector<track_point> const &Branch, std::vector<track_point> const &Line, double const From, double const To, double const Radius,
|
||||
double const Ratio, double const Straight = 0.0);
|
||||
double const Ratio, double const Straight = 0.0, bool const Double = false);
|
||||
// a switch laid into a straight: the cant of the line over it alone, as check() judges it
|
||||
switch_report check_line(std::vector<track_point> const &Line, double const From, double const To);
|
||||
|
||||
// a slip switch bent into a curve, as ST-T1-A6 sees it: in a side track only (11.4 pkt 4b), the curvature of each track through it of
|
||||
// one sign all along it (9.7 pkt 12), its slip curves no sharper than a side track may be (table 9.2), the cant as over a switch bent,
|
||||
// none recommended in a side track (9.3 pkt 5)
|
||||
// the switches bent one-sided from the basic ones, table 11.9: the radius of the basic switch, the limiting curvature of the diverging
|
||||
// track (1/m) and the least radius of the main track (m); the values in its brackets are allowed only by way of exception, after the
|
||||
// agreement of the Zaklad Linii Kolejowych, the same as the others where it has none
|
||||
struct bent_limit
|
||||
{
|
||||
double radius;
|
||||
double branch;
|
||||
double main;
|
||||
double branch_exception;
|
||||
double main_exception;
|
||||
};
|
||||
std::optional<bent_limit> bent_limit_of(double const Radius);
|
||||
|
||||
// the radius of the diverging track of a switch bent from the basic one of Radius and 1:Ratio, its main track bent to Main, table 11.8:
|
||||
// Main above 0 bent the way the diverging track turns off it (one-sided), below 0 the other way (two-sided), 0 not bent. The tangent of
|
||||
// the diverging curve of the basic switch, t = r tan(a/2), corrects the plain sum of the curvatures. Above 0 the diverging track turns
|
||||
// off the way it does in the basic switch, below 0 the other way (bent past straight by a main track sharper than its own curve), 0 for
|
||||
// a straight one
|
||||
double bent_radius(double const Main, double const Radius, double const Ratio);
|
||||
|
||||
// the cant deficiency over a switch, table 9.7, mm: recommended (P0), normal (P1) and the limit (P2); of a fixed frog up to 160 km/h,
|
||||
// of a movable nose up to 230 km/h, which take in any diverging track of the catalogue
|
||||
struct deficiency
|
||||
{
|
||||
double recommended;
|
||||
double normal;
|
||||
double limit;
|
||||
};
|
||||
deficiency switch_deficiency(bool const Movable);
|
||||
|
||||
// the speed with the cant deficiency I up to Deficiency (mm) on a track of Radius (m) under the Cant (mm, above 0 leaning into its
|
||||
// turn, below 0 against it), formula 9.9 the other way round: V = sqrt((I + D) R / 11.8), km/h. Infinite for a straight, 0 where the
|
||||
// cant against the turn takes up all the deficiency already
|
||||
double curve_speed(double const Radius, double const Cant, double const Deficiency);
|
||||
|
||||
// a slip switch bent into a curve, as ST-T1-A6 sees it: none is bent (11.4 pkt 4b, the editor telling no main track from a side
|
||||
// one), the curvature of each track through it of one sign all along it (9.7 pkt 12), its slip curves no sharper than a side track may
|
||||
// be (table 9.2), the cant as over a switch bent, none recommended in a side track (9.3 pkt 5)
|
||||
struct slip_report
|
||||
{
|
||||
// of the two tracks through the slip in its middle, 1/m, positive turning the way the line does
|
||||
@@ -72,6 +112,8 @@ struct slip_report
|
||||
bool curved{false}; // the tracks through it bent
|
||||
std::vector<std::string> notes;
|
||||
std::vector<std::string> warnings;
|
||||
// as of a switch: a slip isn't bent (11.4 pkt 4b)
|
||||
std::vector<std::string> refusals;
|
||||
};
|
||||
|
||||
// Tracks: the two tracks through the slip, Curves: its slip curves, each from its start, the stations from 0 there; Line as for a switch,
|
||||
|
||||
+13
-2
@@ -55,8 +55,9 @@ with 1 when it couldn't start or an error ended it, and with the system's code o
|
||||
The fixture holds plain tracks only, no terrain: lines of straights (`a`, `s`, `d`, the pair `p` and `q` 4.5 m apart), a track
|
||||
of 1000 mm gauge (`g1`) beside one of the standard gauge (`g2`), a turntable of 16 m with `velocity 10` (`tt1`, with the
|
||||
include of its model and events), two curves of 600 and 604.5 m side by side with a cant of 60 mm (`i0`..`i9`, `o0`..`o9`,
|
||||
the straights at their ends taking the cant on and off), and a track apart with a vehicle (`v1`), without which the editor
|
||||
would put one of its own onto a track of the cases on saving. It uses only what every install of the game has.
|
||||
the straights at their ends taking the cant on and off), a straight taking a cant of 60 mm on along its middle track (`r1`..`r3`),
|
||||
a curve without cant of 60 m of R 2000 m and 60 m of R 400 m turning the same way between straights (`k0`..`k3`), and a track
|
||||
apart with a vehicle (`v1`), without which the editor would put one of its own onto a track of the cases on saving. It uses only what every install of the game has.
|
||||
|
||||
## Writing a case
|
||||
|
||||
@@ -79,6 +80,8 @@ The expectations (`expect <what> ...`), each logged as `SELFTEST PASS <what>` or
|
||||
| `expect height <track> <start\|end> <m> <tolerance>` | the height of the end of the first path |
|
||||
| `expect lift <track> <start\|end> <label> <m> <tolerance>` | how far the end is above the height `mark <label> <track> <start\|end>` kept |
|
||||
| `expect includes <track> <count>` | the includes whose parameters name the track: the model and the events of a turntable |
|
||||
| `expect status <text>` | the status of the switch tool, as its panel shows it, holds the text (the rest of the line) |
|
||||
| `expect steps <count>` | the steps of the history Ctrl+Z takes back, the ones made together counted once: none made by a change refused |
|
||||
|
||||
A line `#> reopen` ends a run of the editor there (the part before it saves and ends with `quit`) and starts the editor again
|
||||
on the scenery as it was saved, for what has to be checked after a save and a load. The editor's own `openscenery` starts a
|
||||
@@ -98,3 +101,11 @@ The cases check the fixes of PR #450 (the numbers are those of its test plan):
|
||||
| `6b_set_delete_whole` | a double switch, a slip and a crossover in a set go whole, with their records |
|
||||
| `7_crossover_delete` | deleting a switch of a crossover on a curve takes the crossover out whole: the outer track comes down, the record goes |
|
||||
| `7b_bent_switch_delete` | a switch bent out of the shape of its record still takes the record along when deleted |
|
||||
|
||||
and the quick fixes of the switches (Q2 of the plan of the track editing):
|
||||
|
||||
| case | fix |
|
||||
| --- | --- |
|
||||
| `q2_1_switch_speed` | a switch laid, or given another template, gets the speed of its diverging track written: of its type, bent into a curve with the cant taken with its sign and the cant deficiency of its frog |
|
||||
| `q2_2_switch_refusals` | a switch with the cant changing within it or a ramp ending nearer than 6 m, a double switch or a slip bent, or the curvature of its diverging track turning from one side to the other isn't laid; 1:9.403 bent is only warned of |
|
||||
| `q2_3_switch_move` | a switch moved along its curve or its straight is judged as when it's laid: moved too near a cant ramp, or onto one, it stays |
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Q2: a switch laid gets the speed of its diverging track written, of its type (table 11.2) and of its bend into a curve, the cant
|
||||
# taken with its sign and the cant deficiency of its frog (formula 9.9, table 9.7); a template changed writes it anew. Before, a switch
|
||||
# was laid without one, or with the one of the track or the switch it was copied from.
|
||||
# s1..s3, a1..a3, d1..d3: straights; i1..i8: a curve of R 600 m turning to +x, canted 60 mm
|
||||
wait 5
|
||||
# Rz 60E1-300-1:9 on a straight: 50 km/h, on the diverging track alone (below 0)
|
||||
switchplace Rz_60E1-300-1:9 40 150 1 1
|
||||
expect speed z1 -50
|
||||
expect status Speed on the diverging track 50 km/h
|
||||
# given the template of 1:12: 60 km/h
|
||||
switchreplace z1 Rz_60E1-500-1:12
|
||||
expect speed z1 -60
|
||||
# the movable nose of the 2500-1:26,5 would take 166 km/h, table 11.2 keeps it to 130
|
||||
switchplace Rz_60E1-2500-1:26,5 0 100 1 1
|
||||
expect speed z2 -130
|
||||
expect status no more than 130 km/h of the basic switch (table 11.2)
|
||||
# a double slip on a straight: its slip curves of R 190 m, 40 km/h
|
||||
slipplace Rkpd_60E1-190-1:9 80 150 1 1
|
||||
expect speed editor_dks1_a -40
|
||||
expect speed editor_dks1_d -40
|
||||
# Rz 60E1-190-1:9 bent into the curve, its diverging track out of it: two-sided, R 278 m, the cant of 60 mm against its turn,
|
||||
# 34 km/h, 30 km/h written (the cant taken without its sign would give 63)
|
||||
switchcurve Rz_60E1-190-1:9 308.32 99.54 1 1
|
||||
expect speed z3 -30
|
||||
expect status R 278 m, cant -60 mm into its turn, I up to 110 mm (formula 9.9, table 9.7)
|
||||
# the same into the curve: one-sided, R 144 m, the cant into its turn, 46 km/h, no more than the 40 km/h of the basic switch
|
||||
switchcurve Rz_60E1-190-1:9 321.21 158.11 1 -1
|
||||
expect speed z4 -40
|
||||
expect status R 144 m, cant +60 mm into its turn
|
||||
quit
|
||||
@@ -0,0 +1,42 @@
|
||||
# Q2: a switch breaking a hard rule of ST-T1-A6 isn't laid, the scenery left as it was, the switch tool telling why: the cant
|
||||
# changing within it (11.4 pkt 7), the end of a cant ramp nearer than 6 m (9.6 pkt 16), a double switch or a slip bent (11.4 pkt 4),
|
||||
# the curvature of the diverging track turning from one side to the other (9.7 pkt 12). A switch of 1:9.403 bent is only warned of:
|
||||
# the rule holds in the main tracks, which the editor doesn't tell. Before, all of them were laid with warnings, or none.
|
||||
# i0: a straight taking the cant of 60 mm on along all of it into i1..i8, a curve of R 600 m turning to +x; k1, k2: 60 m of R 2000 m
|
||||
# and 60 m of R 400 m turning the same way, without cant
|
||||
wait 5
|
||||
# on the straight i0: the cant changing within the switch
|
||||
switchplace Rz_60E1-300-1:9 300 -40 1 1
|
||||
expect track z1 removed
|
||||
expect steps 0
|
||||
expect status 11.4 pkt 7
|
||||
expect track i0 present
|
||||
# into the curve 3 m past the end of the ramp on i0
|
||||
switchcurve Rz_60E1-300-1:9 300.0075 3 1 -1
|
||||
expect track z1 removed
|
||||
expect steps 0
|
||||
expect status 3.0 m
|
||||
expect status (9.6 pkt 16)
|
||||
# a double switch into the curve
|
||||
switchcurve Rpd_49E1-190-1:9/1:9 308.32 99.54 1 -1
|
||||
expect track z1 removed
|
||||
expect track z1b removed
|
||||
expect steps 0
|
||||
expect status no double switch, slip nor crossing is bent (11.4 pkt 4)
|
||||
# a double slip into the curve
|
||||
switchcurve Rkpd_60E1-190-1:9 308.32 99.54 1 -1
|
||||
expect track editor_dks1_a removed
|
||||
expect steps 0
|
||||
expect status (11.4 pkt 4)
|
||||
# Rz 60E1-1200-1:18,5 over the change from R 2000 m to R 400 m, its diverging track out of the curve: R 3000 m one way, R 600 m the other
|
||||
switchcurve Rz_60E1-1200-1:18,5 600.225 80 1 1
|
||||
expect track z1 removed
|
||||
expect steps 0
|
||||
expect status (KZW II)
|
||||
expect status (9.7 pkt 12)
|
||||
# Rz 49E1-300-1:9,403 into the curve: laid, with the warning
|
||||
switchcurve Rz_49E1-300-1:9,403 308.32 99.54 1 -1
|
||||
expect track z1 present
|
||||
expect steps 1
|
||||
expect status none of 1:9.403 nor steeper than 1:9 (11.4 pkt 4)
|
||||
quit
|
||||
@@ -0,0 +1,34 @@
|
||||
# Q2: a switch moved along its line is judged as when it's laid there: moved into a place breaking a hard rule it stays as it is,
|
||||
# the switch tool telling why. Before, a switch moved anywhere along its line with no check.
|
||||
# i0: a straight taking the cant of 60 mm on along all of it into i1..i8, a curve of R 600 m turning to +x;
|
||||
# r1..r3: a straight taking the cant of 60 mm on along r2, from 100 m to 160 m of it
|
||||
wait 5
|
||||
# bent into the curve 20 m past the end of the ramp on i0
|
||||
switchcurve Rz_60E1-300-1:9 300.3333 19.9963 1 -1
|
||||
expect track z1 present
|
||||
expect steps 1
|
||||
# 17 m back along the curve: 3 m off the end of the ramp
|
||||
switchslide z1 -17
|
||||
expect steps 1
|
||||
expect status 3.0 m
|
||||
expect status (9.6 pkt 16)
|
||||
# 20 m back: it starts where the ramp ends
|
||||
switchslide z1 -20
|
||||
expect steps 2
|
||||
# on the straight r 20 m from its start
|
||||
switchplace Rz_60E1-300-1:9 440 20 1 1
|
||||
expect track z2 present
|
||||
expect steps 3
|
||||
# 45 m on: its end 1.8 m off the start of the ramp
|
||||
switchslide z2 45
|
||||
expect steps 3
|
||||
expect status 1.8 m
|
||||
expect status (9.6 pkt 16)
|
||||
# 70 m on: onto the ramp, the cant changing within it
|
||||
switchslide z2 70
|
||||
expect steps 3
|
||||
expect status (11.4 pkt 7)
|
||||
# 30 m on: 16.8 m off the ramp
|
||||
switchslide z2 30
|
||||
expect steps 4
|
||||
quit
|
||||
@@ -358,6 +358,72 @@ node -1 0 o9 track normal 60 1.435 0.15 25.0 20 0 flat vis
|
||||
0
|
||||
endtrack
|
||||
|
||||
// line r: a straight taking a cant of 60 mm on along r2 (moving a switch towards a cant ramp)
|
||||
node -1 0 r1 track normal 100 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
440 0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
440 0 100 0
|
||||
0
|
||||
endtrack
|
||||
|
||||
node -1 0 r2 track normal 60 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
440 0 100 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
440 0 160 -2.292443
|
||||
0
|
||||
endtrack
|
||||
|
||||
node -1 0 r3 track normal 100 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
440 0 160 -2.292443
|
||||
0 0 0
|
||||
0 0 0
|
||||
440 0 260 -2.292443
|
||||
0
|
||||
endtrack
|
||||
|
||||
// curve k without cant: a straight, 60 m of R 2000 m and 60 m of R 400 m turning the same way, a straight (the curvature of the
|
||||
// diverging track of a switch over the change turning from one side to the other)
|
||||
node -1 0 k0 track normal 50 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
600 0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
600 0 50 0
|
||||
0
|
||||
endtrack
|
||||
|
||||
node -1 0 k1 track normal 60 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
600 0 50 0
|
||||
0 0 20.000375
|
||||
-0.599921 0 -19.991376
|
||||
600.899933 0 109.991 0
|
||||
2000
|
||||
endtrack
|
||||
|
||||
node -1 0 k2 track normal 60 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
600.899933 0 109.991 0
|
||||
0.600191 0 20.000377
|
||||
-3.582271 0 -19.686103
|
||||
607.182469 0 169.60463 0
|
||||
400
|
||||
endtrack
|
||||
|
||||
node -1 0 k3 track normal 50 1.435 0.15 25.0 20 0 flat vis
|
||||
rail_screw_used1 6 1435mm/tpbps-new2 0.2 0.5 1.1
|
||||
607.182469 0 169.60463 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
616.133948 0 218.796814 0
|
||||
0
|
||||
endtrack
|
||||
|
||||
// a track apart with a vehicle of the scenery: the editor saving a scenery without one puts a vehicle of its own onto the
|
||||
// first track long enough, a track of the cases
|
||||
node -1 0 v1 track normal 50 1.435 0.15 25.0 20 0 flat vis
|
||||
|
||||
@@ -55,11 +55,12 @@ TEST_CASE("switch on a curve: the curvatures of its tracks on a transition curve
|
||||
// turning off to the outside of the curve: against it all along, the case KZW I
|
||||
CHECK(report.branch_start < 0.0);
|
||||
CHECK(report.branch_end < 0.0);
|
||||
CHECK(false == says(report.warnings, "KZW II"));
|
||||
// laid on the ramp, the cant changing under it
|
||||
CHECK(false == says(report.refusals, "KZW II"));
|
||||
// laid on the ramp, the cant changing under it: not laid so (11.4 pkt 7)
|
||||
CHECK(report.cant_start == doctest::Approx(25.0).epsilon(0.02));
|
||||
CHECK(report.cant_end == doctest::Approx(40.0).epsilon(0.02));
|
||||
CHECK(says(report.warnings, "The cant changes within the switch"));
|
||||
CHECK(says(report.refusals, "The cant changes within the switch"));
|
||||
CHECK(false == says(report.warnings, "The cant changes within the switch"));
|
||||
}
|
||||
|
||||
TEST_CASE("switch on a curve: the diverging track turning from one side to the other is the case KZW II") {
|
||||
@@ -69,7 +70,12 @@ TEST_CASE("switch on a curve: the diverging track turning from one side to the o
|
||||
auto const report{switch_curve::check(main, branch, track, 125.0, 155.0, 500.0, 12.0)};
|
||||
CHECK(report.branch_start < 0.0);
|
||||
CHECK(report.branch_end > 0.0);
|
||||
CHECK(says(report.warnings, "KZW II"));
|
||||
// refused, with the radii it turns with either way
|
||||
CHECK(says(report.refusals, "KZW II"));
|
||||
CHECK(says(report.refusals, "(9.7 pkt 12)"));
|
||||
CHECK(false == says(report.warnings, "KZW II"));
|
||||
// the main track, on the transition curve alone, turns one way all along
|
||||
CHECK(false == says(report.refusals, "main track"));
|
||||
}
|
||||
|
||||
TEST_CASE("switch on a curve: the ends of a cant ramp at the ends of the switch or 6 m off it") {
|
||||
@@ -83,10 +89,13 @@ TEST_CASE("switch on a curve: the ends of a cant ramp at the ends of the switch
|
||||
auto const [main, branch] {laid(track, From, 30.0, 500.0, 1)};
|
||||
return switch_curve::check(main, branch, track, From, From + 30.0, 500.0, 12.0);
|
||||
};
|
||||
CHECK(says(at(210.0).warnings, "within the switch"));
|
||||
CHECK(says(at(222.0).warnings, "6 m at least"));
|
||||
CHECK(false == says(at(220.0).warnings, "within the switch"));
|
||||
// within it or nearer than 6 m: not laid so
|
||||
CHECK(says(at(210.0).refusals, "within the switch"));
|
||||
CHECK(says(at(222.0).refusals, "6 m at least"));
|
||||
CHECK(says(at(222.0).refusals, "2.0 m off the switch"));
|
||||
CHECK(false == says(at(220.0).refusals, "within the switch"));
|
||||
CHECK(says(at(220.0).notes, "at an end of the switch"));
|
||||
CHECK(at(230.0).refusals.empty());
|
||||
CHECK(false == says(at(230.0).warnings, "cant ramp"));
|
||||
|
||||
// the start pressed near those places drawn to them
|
||||
@@ -119,7 +128,7 @@ TEST_CASE("switch on a curve: one with a straight frog bent up to the frog, both
|
||||
CHECK(report.curved);
|
||||
// the curvature of the bent part only: no transition curve under it, the diverging track turning one way all along
|
||||
CHECK_FALSE(report.transition);
|
||||
CHECK(false == says(report.warnings, "KZW II"));
|
||||
CHECK(false == says(report.refusals, "KZW II"));
|
||||
CHECK(says(report.warnings, "Bent up to the frog"));
|
||||
}
|
||||
}
|
||||
@@ -131,7 +140,9 @@ TEST_CASE("switch on a curve: none of 1:9.403 nor steeper than 1:9 bent in the r
|
||||
CAPTURE(Ratio);
|
||||
auto const report{switch_curve::check(main, branch, track, 150.0, 183.0, 300.0, Ratio)};
|
||||
REQUIRE(report.curved);
|
||||
return says(report.warnings, "(11.4 pkt 4)");
|
||||
// the editor tells no main track from a side one: a warning, which says so, not a refusal
|
||||
CHECK(report.refusals.empty());
|
||||
return says(report.warnings, "(11.4 pkt 4)") && says(report.warnings, "only warns");
|
||||
};
|
||||
// 1:9 of the catalogue and as read off the angle of the tracks
|
||||
CHECK_FALSE(banned(9.0));
|
||||
@@ -172,7 +183,8 @@ switch_curve::slip_report bent_slip(std::vector<switch_curve::track_point> const
|
||||
TEST_CASE("slip bent into a curve: in a side track only, its slip curve bent the way of the curve no sharper than a side track takes") {
|
||||
auto const sharp{bent_slip(line(0.0, 0.0, 400.0, 800.0, 0.0), 150.0, 1.0 / 800.0)};
|
||||
CHECK(sharp.curved);
|
||||
CHECK(says(sharp.warnings, "11.4 pkt 4b"));
|
||||
// none bent, the editor telling no main track from a side one
|
||||
CHECK(says(sharp.refusals, "R 800 m: no double switch, slip nor crossing is bent (11.4 pkt 4)"));
|
||||
CHECK(sharp.first == doctest::Approx(1.0 / 800.0).epsilon(0.02));
|
||||
CHECK(sharp.second == doctest::Approx(std::cos(std::atan(1.0 / 9.0)) / 800.0).epsilon(0.02));
|
||||
REQUIRE(sharp.curves.size() == 2);
|
||||
@@ -186,7 +198,7 @@ TEST_CASE("slip bent into a curve: in a side track only, its slip curve bent the
|
||||
// R 4000 m: the slip curve of 1/190 + 1/4000, R 181.4 m, still within the side tracks
|
||||
auto const gentle{bent_slip(line(0.0, 0.0, 400.0, 4000.0, 0.0), 150.0, 1.0 / 4000.0)};
|
||||
CHECK(gentle.curved);
|
||||
CHECK(says(gentle.warnings, "11.4 pkt 4b"));
|
||||
CHECK(says(gentle.refusals, "(11.4 pkt 4)"));
|
||||
CHECK(false == says(gentle.warnings, "table 9.2"));
|
||||
CHECK(gentle.notes.empty());
|
||||
|
||||
@@ -194,6 +206,7 @@ TEST_CASE("slip bent into a curve: in a side track only, its slip curve bent the
|
||||
auto const straight{bent_slip(line(400.0, 0.0, 0.0, 1000.0, 0.0), 150.0, 0.0)};
|
||||
CHECK_FALSE(straight.curved);
|
||||
CHECK(straight.warnings.empty());
|
||||
CHECK(straight.refusals.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("slip bent into a curve: the cant of the side track, a track through it turning from one side to the other") {
|
||||
@@ -201,7 +214,7 @@ TEST_CASE("slip bent into a curve: the cant of the side track, a track through i
|
||||
auto const canted{bent_slip(line(0.0, 0.0, 400.0, 1000.0, 30.0), 150.0, 1.0 / 1000.0)};
|
||||
CHECK(canted.cant_start == doctest::Approx(30.0));
|
||||
CHECK(canted.cant_end == doctest::Approx(30.0));
|
||||
CHECK(false == says(canted.warnings, "The cant changes"));
|
||||
CHECK(false == says(canted.refusals, "The cant changes"));
|
||||
CHECK(says(canted.notes, "9.3 pkt 5"));
|
||||
|
||||
// a reverse curve under it
|
||||
@@ -212,7 +225,7 @@ TEST_CASE("slip bent into a curve: the cant of the side track, a track through i
|
||||
point.heading = 16.6 / 1000.0 - (point.station - 16.6) / 1000.0;
|
||||
auto const angle{std::atan(1.0 / 9.0)};
|
||||
auto const report{switch_curve::check_slip({first, arc(33.2, angle, 1.0 / 1000.0)}, {arc(21.0, 0.0, 1.0 / 190.0)}, curve, 150.0, 183.2)};
|
||||
CHECK(says(report.warnings, "9.7 pkt 12"));
|
||||
CHECK(says(report.refusals, "9.7 pkt 12"));
|
||||
}
|
||||
|
||||
TEST_CASE("switch exit: a curve right behind a straight frog, its sudden changes of the cant deficiency apart or together") {
|
||||
@@ -244,3 +257,141 @@ TEST_CASE("switch exit: a curve right behind a straight frog, its sudden changes
|
||||
CHECK(on.apart < 0.0);
|
||||
CHECK(on.warnings.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("switch on a curve: a double switch isn't bent, nor is a slip or a crossing (11.4 pkt 4)") {
|
||||
auto const track{line(0.0, 1.0, 400.0, 1500.0, 0.0)};
|
||||
auto const [main, branch] {laid(track, 150.0, 30.0, 190.0, 1)};
|
||||
auto const bent{switch_curve::check(main, branch, track, 150.0, 180.0, 190.0, 9.0, 0.0, true)};
|
||||
REQUIRE(bent.curved);
|
||||
CHECK(says(bent.refusals, "Bent into R 1500 m: no double switch, slip nor crossing is bent (11.4 pkt 4)"));
|
||||
// a single one of the same shape is
|
||||
CHECK(switch_curve::check(main, branch, track, 150.0, 180.0, 190.0, 9.0).refusals.empty());
|
||||
// and a double one on a straight
|
||||
auto const straight{line(400.0, 0.0, 0.0, 1000.0, 0.0)};
|
||||
auto const [smain, sbranch] {laid(straight, 150.0, 30.0, 190.0, 1)};
|
||||
auto const on_straight{switch_curve::check(smain, sbranch, straight, 150.0, 180.0, 190.0, 9.0, 0.0, true)};
|
||||
CHECK_FALSE(on_straight.curved);
|
||||
CHECK(on_straight.refusals.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("switch on a straight: the cant of the line over it, no ramp within it nor nearer than 6 m (11.4 pkt 7, 9.6 pkt 16)") {
|
||||
// a straight of 100 m, a ramp of 60 m up to 60 mm, then 100 m of 60 mm
|
||||
std::vector<switch_curve::track_point> straight;
|
||||
for (int k = 0; k * 0.5 <= 260.0 + 1e-9; ++k) {
|
||||
auto const s{k * 0.5};
|
||||
straight.push_back({s, 0.0, s <= 100.0 ? 0.0 : s <= 160.0 ? (s - 100.0) : 60.0});
|
||||
}
|
||||
auto const at = [&](double const From) { return switch_curve::check_line(straight, From, From + 33.2); };
|
||||
CHECK(at(20.0).refusals.empty());
|
||||
CHECK(at(60.0).refusals.empty());
|
||||
// 1.8 m off the start of the ramp
|
||||
CHECK(says(at(65.0).refusals, "1.8 m off the switch, 6 m at least (9.6 pkt 16)"));
|
||||
// on it: the cant changing under it, the start of the ramp within it
|
||||
auto const on{at(90.0)};
|
||||
CHECK(says(on.refusals, "The cant changes within the switch, 0 to 23 mm: it's to stay the same over it (11.4 pkt 7)"));
|
||||
CHECK(says(on.refusals, "10.0 m from its start"));
|
||||
// ending right where the ramp starts, and of the cant all along
|
||||
CHECK(at(100.0 - 33.2).refusals.empty());
|
||||
CHECK(says(at(100.0 - 33.2).notes, "at an end of the switch"));
|
||||
CHECK(at(180.0).refusals.empty());
|
||||
CHECK(at(180.0).cant_start == doctest::Approx(60.0));
|
||||
}
|
||||
|
||||
TEST_CASE("table 11.8: the diverging track of a switch bent one-sided and two-sided, the tangent t correcting the sum of the curvatures") {
|
||||
// Rz 60E1-500-1:12: t = 500 tan(atan(1/12) / 2) = 20.797 m, as a of the catalogue
|
||||
// a) two-sided, the main track bent to R 1200 against the diverging one: r" = (R r + t^2) / (R - r)
|
||||
CHECK(switch_curve::bent_radius(-1200.0, 500.0, 12.0) == doctest::Approx((1200.0 * 500.0 + 20.797 * 20.797) / 700.0).epsilon(1e-5));
|
||||
CHECK(switch_curve::bent_radius(-1200.0, 500.0, 12.0) == doctest::Approx(857.76).epsilon(1e-5));
|
||||
// b) one-sided, the main track bent to R 1200 with it: r" = (R r - t^2) / (R + r)
|
||||
CHECK(switch_curve::bent_radius(1200.0, 500.0, 12.0) == doctest::Approx(352.69).epsilon(1e-5));
|
||||
// near the plain sums of the curvatures, 1 / (1/500 -+ 1/1200)
|
||||
CHECK(switch_curve::bent_radius(-1200.0, 500.0, 12.0) == doctest::Approx(857.14).epsilon(1e-3));
|
||||
CHECK(switch_curve::bent_radius(1200.0, 500.0, 12.0) == doctest::Approx(352.94).epsilon(1e-3));
|
||||
// b) bent from the diverging track: the main track sharper than it takes it past straight, r" = (R r + t^2) / (r - R), the other way
|
||||
CHECK(switch_curve::bent_radius(-400.0, 500.0, 12.0) == doctest::Approx(-2004.33).epsilon(1e-5));
|
||||
// the main track as sharp as the diverging curve against it: the diverging track straight; not bent: the basic switch
|
||||
CHECK(switch_curve::bent_radius(-500.0, 500.0, 12.0) == 0.0);
|
||||
CHECK(switch_curve::bent_radius(0.0, 500.0, 12.0) == 500.0);
|
||||
}
|
||||
|
||||
TEST_CASE("table 11.9: the least radii of the switches bent one-sided, the diverging track of the least main radius by table 11.8") {
|
||||
struct row {
|
||||
double radius;
|
||||
double ratio;
|
||||
double branch; // the limiting curvature, 1/km
|
||||
double least_branch; // m
|
||||
double least_main; // m
|
||||
double branch_exception;
|
||||
double least_branch_exception;
|
||||
double least_main_exception;
|
||||
};
|
||||
// the values in the brackets for 300 and 500, allowed by way of exception
|
||||
row const rows[]{{300.0, 9.0, 4.000, 250.0, 1505.522, 4.673, 214.0, 749.722},
|
||||
{500.0, 12.0, 4.000, 250.0, 501.730, 4.673, 214.0, 375.638},
|
||||
{760.0, 14.0, 3.333, 300.0, 497.250, 3.333, 300.0, 497.250},
|
||||
{1200.0, 18.5, 2.169, 461.0, 750.001, 2.169, 461.0, 750.001},
|
||||
{2500.0, 26.5, 1.063, 941.0, 1510.0, 1.063, 941.0, 1510.0}};
|
||||
for (auto const &entry : rows) {
|
||||
CAPTURE(entry.radius);
|
||||
auto const limit{switch_curve::bent_limit_of(entry.radius)};
|
||||
REQUIRE(limit.has_value());
|
||||
CHECK(limit->branch * 1000.0 == doctest::Approx(entry.branch));
|
||||
CHECK(limit->main == doctest::Approx(entry.least_main));
|
||||
CHECK(limit->branch_exception * 1000.0 == doctest::Approx(entry.branch_exception));
|
||||
CHECK(limit->main_exception == doctest::Approx(entry.least_main_exception));
|
||||
// the least main radius bends the diverging track one-sided to the least radius the table gives it
|
||||
CHECK(switch_curve::bent_radius(entry.least_main, entry.radius, entry.ratio) == doctest::Approx(entry.least_branch).epsilon(0.001));
|
||||
CHECK(switch_curve::bent_radius(entry.least_main_exception, entry.radius, entry.ratio) == doctest::Approx(entry.least_branch_exception).epsilon(0.001));
|
||||
}
|
||||
CHECK_FALSE(switch_curve::bent_limit_of(190.0).has_value());
|
||||
}
|
||||
|
||||
TEST_CASE("table 9.7: the cant deficiency over a switch, fixed frog and movable nose") {
|
||||
auto const fixed{switch_curve::switch_deficiency(false)};
|
||||
CHECK(fixed.recommended == 90.0);
|
||||
CHECK(fixed.normal == 110.0);
|
||||
CHECK(fixed.limit == 110.0);
|
||||
auto const movable{switch_curve::switch_deficiency(true)};
|
||||
CHECK(movable.recommended == 100.0);
|
||||
CHECK(movable.normal == 130.0);
|
||||
CHECK(movable.limit == 130.0);
|
||||
}
|
||||
|
||||
TEST_CASE("formula 9.9 and table 9.7: the speeds of table 11.2 on the diverging tracks of the basic switches with a fixed frog") {
|
||||
// V = sqrt(I R / 11.8) at the normal 110 mm, rounded down to 10 km/h: 190 40, 300 (1:9 and 1:9.403) 50, 500 60, 760 80, 1200 100
|
||||
auto const table = [](double const Radius) { return std::floor(switch_curve::curve_speed(Radius, 0.0, switch_curve::switch_deficiency(false).normal) / 10.0) * 10.0; };
|
||||
CHECK(table(190.0) == 40.0);
|
||||
CHECK(table(300.0) == 50.0);
|
||||
CHECK(table(500.0) == 60.0);
|
||||
CHECK(table(760.0) == 80.0);
|
||||
CHECK(table(1200.0) == 100.0);
|
||||
// the 2500-1:26.5 with a movable nose would take 166 km/h; table 11.2 and Id-4 give it 130, which the editor keeps
|
||||
CHECK(switch_curve::curve_speed(2500.0, 0.0, switch_curve::switch_deficiency(true).normal) == doctest::Approx(166.0).epsilon(0.001));
|
||||
// a straight track takes any speed, a cant against the turn as large as the deficiency none
|
||||
CHECK(std::isinf(switch_curve::curve_speed(0.0, 0.0, 110.0)));
|
||||
CHECK(switch_curve::curve_speed(500.0, -110.0, 110.0) == 0.0);
|
||||
CHECK(switch_curve::curve_speed(500.0, -150.0, 110.0) == 0.0);
|
||||
}
|
||||
|
||||
TEST_CASE("formula 9.9: the speed on the diverging track of a bent switch, the cant with its sign, the frog by table 9.7") {
|
||||
// the example of the review: Rz 60E1-500-1:12 bent outward into R 1200 m with 60 mm of cant, two-sided, r" = 857.8 m. The cant
|
||||
// leans against the diverging track: with I up to 100 mm, the 0.65 m/s2 the editor took for the switch branches, about 54 km/h,
|
||||
// where the cant taken without its sign gave 107
|
||||
auto const radius{switch_curve::bent_radius(-1200.0, 500.0, 12.0)};
|
||||
CHECK(switch_curve::curve_speed(radius, -60.0, 100.0) == doctest::Approx(53.9).epsilon(0.002));
|
||||
CHECK(switch_curve::curve_speed(radius, 60.0, 100.0) == doctest::Approx(107.8).epsilon(0.002));
|
||||
// by its frog, table 9.7: fixed, 90 recommended and 110 normal; movable nose, 100 and 130
|
||||
auto const fixed{switch_curve::switch_deficiency(false)};
|
||||
auto const movable{switch_curve::switch_deficiency(true)};
|
||||
CHECK(switch_curve::curve_speed(radius, -60.0, fixed.recommended) == doctest::Approx(46.7).epsilon(0.002));
|
||||
CHECK(switch_curve::curve_speed(radius, -60.0, fixed.normal) == doctest::Approx(60.3).epsilon(0.002));
|
||||
CHECK(switch_curve::curve_speed(radius, -60.0, movable.recommended) == doctest::Approx(53.9).epsilon(0.002));
|
||||
CHECK(switch_curve::curve_speed(radius, -60.0, movable.normal) == doctest::Approx(71.3).epsilon(0.002));
|
||||
// bent inward, one-sided into R 1200: r" = 352.7 m, the cant leaning into its turn, 71 km/h at 110 mm
|
||||
CHECK(switch_curve::curve_speed(switch_curve::bent_radius(1200.0, 500.0, 12.0), 60.0, fixed.normal) == doctest::Approx(71.3).epsilon(0.002));
|
||||
// Rz 60E1-190-1:9 in the curve R 600 m with 60 mm of the self-test scenery: outward 278.3 m and 34.3 km/h, inward 144.2 m and 45.6 km/h
|
||||
CHECK(switch_curve::bent_radius(-600.0, 190.0, 9.0) == doctest::Approx(278.3).epsilon(0.001));
|
||||
CHECK(switch_curve::curve_speed(switch_curve::bent_radius(-600.0, 190.0, 9.0), -60.0, fixed.normal) == doctest::Approx(34.3).epsilon(0.002));
|
||||
CHECK(switch_curve::bent_radius(600.0, 190.0, 9.0) == doctest::Approx(144.2).epsilon(0.001));
|
||||
CHECK(switch_curve::curve_speed(switch_curve::bent_radius(600.0, 190.0, 9.0), 60.0, fixed.normal) == doctest::Approx(45.6).epsilon(0.002));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user