mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-30 22:30:28 +01:00
feat(editor,track): a cant ramp of its own, off the transition curve: each end of a curve may have its ramp moved and of a length of its own (ST-T1-A6 9.6 pkt 5 and 11), on the straight before the curve or on the arc, the transition keeping the full cant all along, as a switch laid on it wants it; set in the plan under "Cant ramps", stored with the vertex as "ramps", reversed with the curve, marked across the track in the view. The cant of a line is a profile along it now, the paths cut where a ramp of its own starts and ends, their rolls following it, warnings where a ramp is shorter than its cant asks for or reaches into the curve before, past the line or over the other ramp. A switch on a cant ramp is drawn following it: its rails, blades, frogs and bed made at the mean of its rolls, as before, are turned along each path to the roll of the path there, so it no longer steps at its ends against the tracks either side. The checks of a switch laid into a curve warn of the values of table 11.9 in brackets as of the others, with no word of a consent. Unit test of a ramp moved onto the straight
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
#include "doctest.h"
|
||||
#include "editor/editorAlignment.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -391,3 +393,48 @@ TEST_CASE("alignment: bends clicked close along a curve make one compound curve,
|
||||
}
|
||||
CHECK(design.vertices.size() < 12);
|
||||
}
|
||||
|
||||
TEST_CASE("alignment: a cant ramp moved off the transition curve onto the straight before it") {
|
||||
auto design{straights({300.0, 300.0}, {30.0 * pi / 180.0}, 80.0)};
|
||||
auto &vertex{design.vertices.front()};
|
||||
vertex.radius = 800.0;
|
||||
vertex.transition_in = vertex.transition_out = 60.0;
|
||||
vertex.cant = 60.0;
|
||||
auto const along{alignment::compute(design)};
|
||||
REQUIRE(along.valid);
|
||||
REQUIRE(along.ramps.size() == 2);
|
||||
auto const start{along.ramps.front().from};
|
||||
CHECK(along.ramps.front().to - start == doctest::Approx(60.0));
|
||||
CHECK(alignment::evaluate(along, start + 30.0).cant == doctest::Approx(30.0));
|
||||
|
||||
// the whole ramp on the straight, the transition with the full cant all along it, as a switch laid on it wants it
|
||||
vertex.ramp_in_offset = -40.0;
|
||||
vertex.ramp_in_length = 40.0;
|
||||
auto const moved{alignment::compute(design)};
|
||||
REQUIRE(moved.valid);
|
||||
REQUIRE(moved.ramps.size() == 2);
|
||||
CHECK(moved.ramps.front().own);
|
||||
CHECK(moved.ramps.front().from == doctest::Approx(start - 40.0));
|
||||
CHECK(moved.ramps.front().to == doctest::Approx(start));
|
||||
CHECK(alignment::evaluate(moved, start - 50.0).cant == doctest::Approx(0.0));
|
||||
CHECK(alignment::evaluate(moved, start - 20.0).cant == doctest::Approx(30.0));
|
||||
CHECK(alignment::evaluate(moved, start + 10.0).cant == doctest::Approx(60.0));
|
||||
CHECK(alignment::evaluate(moved, start + 50.0).cant == doctest::Approx(60.0));
|
||||
// on the straight the cant leans the way the curve turns
|
||||
CHECK(alignment::evaluate(moved, start - 20.0).turn == alignment::evaluate(moved, start + 100.0).turn);
|
||||
// 40 m are too short to raise 60 mm at 80 km/h
|
||||
CHECK(std::any_of(moved.warnings.begin(), moved.warnings.end(), [](std::string const &Warning) { return Warning.find("cant ramp of") != std::string::npos; }));
|
||||
|
||||
// the paths end where the ramp starts and ends, their rolls going along it
|
||||
auto const paths{alignment::pieces(moved, design, alignment::minimum_pieces(moved, design))};
|
||||
auto const meets = [&](double const Chainage) {
|
||||
auto const point{alignment::evaluate(moved, Chainage).position};
|
||||
return std::any_of(paths.begin(), paths.end(), [&](segment_data const &Path) { return glm::distance(Path.points[segment_data::point::start], point) < 0.05; });
|
||||
};
|
||||
CHECK(meets(start - 40.0));
|
||||
CHECK(meets(start));
|
||||
for (std::size_t i = 1; i < paths.size(); ++i)
|
||||
CHECK(paths[i].rolls[0] == doctest::Approx(paths[i - 1].rolls[1]).epsilon(1e-4));
|
||||
auto const turned{std::max_element(paths.begin(), paths.end(), [](segment_data const &A, segment_data const &B) { return std::abs(A.rolls[1]) < std::abs(B.rolls[1]); })};
|
||||
CHECK(std::abs(turned->rolls[1]) == doctest::Approx(glm::degrees(std::asin(60.0 / design.norms.gauge))).epsilon(1e-3));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ TEST_CASE("switch on a curve: the curvatures of its tracks on a transition curve
|
||||
CHECK(report.branch_start < 0.0);
|
||||
CHECK(report.branch_end < 0.0);
|
||||
CHECK(false == says(report.warnings, "KZW II"));
|
||||
CHECK(says(report.notes, "transition curve"));
|
||||
// laid on the ramp, the cant changing under it
|
||||
CHECK(report.cant_start == doctest::Approx(25.0).epsilon(0.02));
|
||||
CHECK(report.cant_end == doctest::Approx(40.0).epsilon(0.02));
|
||||
|
||||
Reference in New Issue
Block a user