mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 19:57:06 +01:00
Merge lang/editor-track-pl into ui/editor-first-steps
# Conflicts: # application/editormodeselftestexpect.cpp
This commit is contained in:
@@ -212,8 +212,24 @@ void norms_tool::forget(scene::basic_node const *Node)
|
||||
state.selected = -1;
|
||||
for (auto &line : state.lines)
|
||||
std::erase_if(line.entries, [Node](norms_report::entry const &Entry) { return Entry.track == Node; });
|
||||
for (auto &line : state.queue)
|
||||
std::erase_if(line.spans, [Node](norms_report::span const &Span) { return Span.track == Node; });
|
||||
// the span whose findings alone are kept moves down by the spans taken out before it; a line whose own span went has nothing left
|
||||
// to report
|
||||
auto const gone = [Node](norms_report::span const &Span) { return Span.track == Node; };
|
||||
auto line{state.queue.begin()};
|
||||
while (line != state.queue.end())
|
||||
{
|
||||
if (line->own >= 0 && line->own < static_cast<int>(line->spans.size()))
|
||||
{
|
||||
if (gone(line->spans[line->own]))
|
||||
{
|
||||
line = state.queue.erase(line);
|
||||
continue;
|
||||
}
|
||||
line->own -= static_cast<int>(std::count_if(line->spans.begin(), line->spans.begin() + line->own, gone));
|
||||
}
|
||||
std::erase_if(line->spans, gone);
|
||||
++line;
|
||||
}
|
||||
}
|
||||
|
||||
void norms_tool::render_class()
|
||||
|
||||
@@ -225,6 +225,7 @@ editor_mode::selftest_result editor_mode::selftest_dispatch(std::string const &c
|
||||
// expect joint <track> <start|end> <gap m> <angle deg> <cant step mm> the end of the first path against the end of another track
|
||||
// nearest to it within 1 m: the gap, the kink and the step of the cant between them, each at most
|
||||
// expect records <name> <count> [kind] the records of the switch store of the name, with the connections having the switch among theirs
|
||||
// expect shaped <switch> <yes|no> the switch keeps the shape its record says, or was bent out of it
|
||||
// expect speed <track> <km/h> [tolerance], expect gauge <track> <m> [tolerance] as editor_track::velocity gives it / the gauge
|
||||
// expect track <name> <present|removed>
|
||||
// expect route <track> <in|out> the track is a part of the line open in the route tool, or not
|
||||
@@ -256,8 +257,13 @@ void editor_mode::selftest_step()
|
||||
std::ifstream stream(file);
|
||||
std::string line;
|
||||
while (std::getline(stream, line))
|
||||
if (false == line.empty() && line.front() != '#')
|
||||
test.lines.push_back(line);
|
||||
{
|
||||
// an indented comment or a line of blanks is no command either
|
||||
auto const first{line.find_first_not_of(" \t\r")};
|
||||
if (first == std::string::npos || line[first] == '#')
|
||||
continue;
|
||||
test.lines.push_back(line.substr(first));
|
||||
}
|
||||
WriteLog("SELFTEST: " + std::to_string(test.lines.size()) + " steps from " + file);
|
||||
}
|
||||
++editor_selftest::frames();
|
||||
|
||||
@@ -51,6 +51,13 @@ inline std::size_t &failures()
|
||||
return count;
|
||||
}
|
||||
|
||||
// a command whose subject isn't there, a track name mistyped, fails the run as an expectation does
|
||||
inline void fail()
|
||||
{
|
||||
++expectations();
|
||||
++failures();
|
||||
}
|
||||
|
||||
// apart from the 1 of a start which failed or of an error which ended the editor
|
||||
inline constexpr int failed_exit_code{2};
|
||||
|
||||
|
||||
@@ -188,6 +188,24 @@ void expect_records(std::string const &What, std::istringstream &Words)
|
||||
expectation(count == wanted, What, std::to_string(count), std::to_string(wanted));
|
||||
}
|
||||
|
||||
// expect shaped <switch> <yes|no>: the switch keeps the shape its record says, or was bent out of it
|
||||
void expect_shaped(std::string const &What, std::istringstream &Words)
|
||||
{
|
||||
std::string name;
|
||||
std::string wanted;
|
||||
Words >> name >> wanted;
|
||||
if (malformed(What, Words))
|
||||
return;
|
||||
auto const *track{simulation::Paths.find(name)};
|
||||
if (track == nullptr || track->m_editorremoved)
|
||||
{
|
||||
expectation(false, What, "no track " + name, "a switch");
|
||||
return;
|
||||
}
|
||||
auto const shaped{switch_store::of(*track).has_value()};
|
||||
expectation(shaped == (wanted == "yes"), What, shaped ? "yes" : "no", wanted);
|
||||
}
|
||||
|
||||
// expect speed <track> <km/h> [tolerance], expect gauge <track> <m> [tolerance]
|
||||
void expect_track_value(std::string const &What, std::string const &Kind, std::istringstream &Words)
|
||||
{
|
||||
@@ -476,6 +494,8 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
|
||||
expect_joint(what, words, &editor_mode::cant_of_roll);
|
||||
else if (kind == "records")
|
||||
expect_records(what, words);
|
||||
else if (kind == "shaped")
|
||||
expect_shaped(what, words);
|
||||
else if (kind == "speed" || kind == "gauge")
|
||||
expect_track_value(what, kind, words);
|
||||
else if (kind == "track")
|
||||
@@ -498,6 +518,6 @@ editor_mode::selftest_result editor_mode::selftest_expect(std::string const &com
|
||||
{m_switch.status, ui()->refusal_shown(), ui()->status_line(), m_lay.mouse,
|
||||
{{"grow", m_nmt_state.grow}, {"area", EditorSettings.terrain_model().area}, {"prompt", m_nmt_state.prompt}}}))
|
||||
expectation(false, what, "no expectation " + kind,
|
||||
"cant, joint, records, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain or steps");
|
||||
"cant, joint, records, shaped, speed, gauge, track, route, norms, findings, height, lift, includes, status, statuslacks, refusal, statusline, laycursor, terrain or steps");
|
||||
return selftest_result::handled;
|
||||
}
|
||||
|
||||
@@ -404,8 +404,15 @@ editor_mode::selftest_result editor_mode::selftest_track(std::string const &comm
|
||||
double gauge{1500.0};
|
||||
std::string name;
|
||||
words >> gauge >> name;
|
||||
auto *track{name.empty() ? nullptr : simulation::Paths.find(name)};
|
||||
if (false == name.empty() && (track == nullptr || track->m_editorremoved))
|
||||
{
|
||||
editor_selftest::fail();
|
||||
WriteLog("SELFTEST FAIL routegauge: no track " + name);
|
||||
return selftest_result::handled;
|
||||
}
|
||||
// the line of the track opened in the route tool, as a click on it with the tool does, unless it's in the line open already
|
||||
if (auto *track{simulation::Paths.find(name)}; track != nullptr && false == track->m_editorremoved && std::ranges::find(m_route.chain.tracks, track) == m_route.chain.tracks.end())
|
||||
if (track != nullptr && std::ranges::find(m_route.chain.tracks, track) == m_route.chain.tracks.end())
|
||||
{
|
||||
m_track_tab = track_tab::route;
|
||||
m_route.single = false;
|
||||
@@ -426,7 +433,8 @@ editor_mode::selftest_result editor_mode::selftest_track(std::string const &comm
|
||||
std::string reason;
|
||||
if (track == nullptr || track->m_editorremoved || index < 0 || index >= static_cast<int>(track->m_paths.size()) || false == editor_track::can_edit_geometry(*track, reason))
|
||||
{
|
||||
WriteLog("SELFTEST trackcant: no path " + name + " " + std::to_string(index) + " to edit " + reason);
|
||||
editor_selftest::fail();
|
||||
WriteLog("SELFTEST FAIL trackcant: no path " + name + " " + std::to_string(index) + " to edit " + reason);
|
||||
return selftest_result::handled;
|
||||
}
|
||||
// as the field of the inspector takes it: the rolls of the path set, then the edit committed with the track as it was before
|
||||
|
||||
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "application/editormode.h"
|
||||
#include "application/editoruilayer.h"
|
||||
#include "application/editormodeselftest.h"
|
||||
#include "application/editormodeshared.h"
|
||||
#include "editor/editorFormat.hpp"
|
||||
#include "editor/editorGeometry.hpp"
|
||||
@@ -2099,8 +2100,15 @@ editor_mode::selftest_result editor_mode::selftest_props(std::string const &Comm
|
||||
// the set made of the tracks, also of one, and the last of them selected, as the set stays the selection only with it
|
||||
m_track_set.clear();
|
||||
for (std::string name; Words >> name;)
|
||||
{
|
||||
if (auto *track{simulation::Paths.find(name)}; track != nullptr && false == track->m_editorremoved)
|
||||
{
|
||||
m_track_set.push_back(track);
|
||||
continue;
|
||||
}
|
||||
editor_selftest::fail();
|
||||
WriteLog("SELFTEST FAIL tracksetdelete: no track " + name);
|
||||
}
|
||||
m_node = m_track_set.empty() ? nullptr : m_track_set.back();
|
||||
m_track_point = {};
|
||||
ui()->set_node(m_node);
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace
|
||||
{
|
||||
|
||||
double constexpr kParallel{1e-9}; // rad: tangents within this run alike
|
||||
double constexpr kTouching{1e-6}; // m: a cut this close to the end of an element is at the end
|
||||
double constexpr kShortest{0.1}; // m: no part of a line split shorter; the simulation takes a path under 5 cm for one of no length
|
||||
|
||||
using reasons = std::vector<std::string>;
|
||||
@@ -185,13 +186,18 @@ reasons propose(transaction &Change, outcome &Result, split_line const &Command)
|
||||
auto const next{k + 1 == count ? geometry::plan_of(Change.view().find(original.end)->position) : vertices[k + 1].point};
|
||||
auto const in{glm::normalize(curve.point - previous)};
|
||||
auto const out{glm::normalize(next - curve.point)};
|
||||
if (std::abs(geometry::signed_angle(in, cut.heading)) <= kParallel && std::abs(cut.curvature) < 1e-12)
|
||||
// at the start or the end of the curve: where its transition leaves the straight, or at the tangent point of an arc with none,
|
||||
// whose curvature there is already the arc's
|
||||
auto const straight_there{std::abs(cut.curvature) < 1e-12};
|
||||
auto const arc_starts{e.role == element_role::arc && u < kTouching};
|
||||
auto const arc_ends{e.role == element_role::arc && u > e.length - kTouching};
|
||||
if (std::abs(geometry::signed_angle(in, cut.heading)) <= kParallel && (straight_there || arc_starts))
|
||||
{
|
||||
// right at the start of the curve
|
||||
take(0, k, before);
|
||||
take(k, count, after);
|
||||
}
|
||||
else if (std::abs(geometry::signed_angle(cut.heading, out)) <= kParallel && std::abs(cut.curvature) < 1e-12)
|
||||
else if (std::abs(geometry::signed_angle(cut.heading, out)) <= kParallel && (straight_there || arc_ends))
|
||||
{
|
||||
take(0, k + 1, before);
|
||||
take(k + 1, count, after);
|
||||
@@ -376,7 +382,8 @@ reasons propose(transaction &Change, outcome &Result, join_ends const &Command)
|
||||
return {"a line can't join a node to itself"};
|
||||
auto const from{free_end_at(view, Command.from, true, why)};
|
||||
auto const to{free_end_at(view, Command.to, false, why)};
|
||||
if (false == why.empty())
|
||||
// an end not found says why in Why
|
||||
if (false == from.has_value() || false == to.has_value())
|
||||
return why;
|
||||
auto const &neighbour{*view.find(from->held.line)};
|
||||
auto const category{neighbour.category};
|
||||
|
||||
@@ -463,6 +463,7 @@ norms::line described(solved_line const &Line, norms::line_class const &Class, s
|
||||
element.length = e.length;
|
||||
element.curvature_start = e.curvature(0.0);
|
||||
element.curvature_end = e.curvature(e.length);
|
||||
element.bloss = e.kind == element_kind::bloss;
|
||||
element.speed = Class.vmax;
|
||||
auto const from{e.position(0.0)};
|
||||
auto const to{e.position(e.length)};
|
||||
|
||||
@@ -97,7 +97,8 @@ norms::element reversed(norms::element Element, double const Length)
|
||||
// the elements run on alike: the same kind, the curvature going on as it did
|
||||
bool runs_on(norms::element const &A, norms::element const &B)
|
||||
{
|
||||
if (A.kind != B.kind || std::abs(A.curvature_end - B.curvature_start) > kCurvature || A.speed != B.speed || A.features != B.features)
|
||||
// two halves of Bloss curves make no Bloss curve
|
||||
if (A.kind != B.kind || A.bloss || B.bloss || std::abs(A.curvature_end - B.curvature_start) > kCurvature || A.speed != B.speed || A.features != B.features)
|
||||
return false;
|
||||
if (A.kind != norms::element_kind::transition)
|
||||
return std::abs(A.curvature_start - B.curvature_end) <= kCurvature;
|
||||
@@ -341,6 +342,8 @@ std::vector<chain_part> chain_of(network const &Network, line_id const Line)
|
||||
{
|
||||
auto const &last{result.back()};
|
||||
auto const *owner{Network.find(last.line)};
|
||||
if (owner == nullptr)
|
||||
break;
|
||||
auto const beyond{last.forward ? line_end::end : line_end::start};
|
||||
auto const *other{across(owner->node_at(beyond), last.line, beyond)};
|
||||
if (other == nullptr || contains(other->line) || Network.find(other->line) == nullptr)
|
||||
@@ -352,6 +355,8 @@ std::vector<chain_part> chain_of(network const &Network, line_id const Line)
|
||||
{
|
||||
auto const &head{result.front()};
|
||||
auto const *owner{Network.find(head.line)};
|
||||
if (owner == nullptr)
|
||||
break;
|
||||
auto const behind{head.forward ? line_end::start : line_end::end};
|
||||
auto const *other{across(owner->node_at(behind), head.line, behind)};
|
||||
if (other == nullptr || contains(other->line) || Network.find(other->line) == nullptr)
|
||||
@@ -367,10 +372,14 @@ described_chain describe_chain(network const &Network, std::vector<chain_part> c
|
||||
double offset{0.0};
|
||||
for (auto const &part : Chain)
|
||||
{
|
||||
auto const &owner{*Network.find(part.line)};
|
||||
// the chain is made of the lines of the network: one gone is a chain out of date, of which the rest is described
|
||||
auto const *found{Network.find(part.line)};
|
||||
result.starts.push_back(offset);
|
||||
if (found == nullptr)
|
||||
continue;
|
||||
auto const &owner{*found};
|
||||
auto own{described(owner.solved, owner.category)};
|
||||
auto const length{owner.solved.length};
|
||||
result.starts.push_back(offset);
|
||||
if (false == part.forward)
|
||||
{
|
||||
for (auto &element : own.elements)
|
||||
@@ -497,12 +506,13 @@ void check_norms(network const &Network, std::set<line_id> const &Lines, verdict
|
||||
for (auto const &part : chain)
|
||||
{
|
||||
done.insert(part.line);
|
||||
laid = laid && Network.find(part.line)->solved.valid();
|
||||
auto const *line{Network.find(part.line)};
|
||||
laid = laid && line != nullptr && line->solved.valid();
|
||||
}
|
||||
if (false == laid)
|
||||
continue;
|
||||
auto const described{describe_chain(Network, chain)};
|
||||
auto const &first{*Network.find(chain.front().line)};
|
||||
auto const &first{*Network.find(chain.front().line)}; // NOSONAR: every line of the chain was found just above
|
||||
for (auto const &finding : norms::evaluate(described.line, first.category, Network.areas))
|
||||
{
|
||||
if (finding.level == norms::tier::none)
|
||||
@@ -510,7 +520,7 @@ void check_norms(network const &Network, std::set<line_id> const &Lines, verdict
|
||||
// the line it's on, by the chainage along the chain
|
||||
auto part{static_cast<std::size_t>(std::upper_bound(described.starts.begin(), described.starts.end(), finding.chainage + 1e-9) - described.starts.begin())};
|
||||
part = part > 0 ? part - 1 : 0;
|
||||
auto const &owner{*Network.find(chain[part].line)};
|
||||
auto const &owner{*Network.find(chain[part].line)}; // NOSONAR: every line of the chain was found just above
|
||||
auto const along{finding.chainage - described.starts[part]};
|
||||
auto const chainage{chain[part].forward ? along : owner.solved.length - along};
|
||||
auto const text{finding_text(finding)};
|
||||
|
||||
@@ -204,7 +204,8 @@ enum class element_kind
|
||||
arc
|
||||
};
|
||||
|
||||
// an element of the line in the plan: the curvature changes evenly along it from its start to its end, signed, positive turning left
|
||||
// an element of the line in the plan: the curvature changes evenly along it from its start to its end (or as a Bloss curve does),
|
||||
// signed, positive turning left
|
||||
struct element
|
||||
{
|
||||
element_kind kind{element_kind::straight};
|
||||
@@ -212,6 +213,9 @@ struct element
|
||||
double length{0.0};
|
||||
double curvature_start{0.0}; // 1/m
|
||||
double curvature_end{0.0};
|
||||
// a transition whose curvature follows the Bloss curve, 3t^2 - 2t^3 of the change: gentle at its ends, 1.5 times as fast as an
|
||||
// even one in its middle, the arc moved in by L^2 / 40R instead of L^2 / 24R
|
||||
bool bloss{false};
|
||||
double speed{0.0}; // km/h, the highest on it; 0: the one of the line class
|
||||
unsigned features{0}; // switch_track, movable_frog, curved_switch, crossing, expansion, diverging, platform, station
|
||||
// the element is cut by the end of the line or by a switch: its length isn't its own
|
||||
|
||||
@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "editor/norms/norms.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <tuple>
|
||||
|
||||
@@ -27,6 +28,7 @@ namespace
|
||||
|
||||
double constexpr kC{11.8};
|
||||
double constexpr kSame{1e-6}; // m: points closer along the line are one
|
||||
int constexpr kBlossPieces{8}; // a Bloss transition seen as this many pieces, as the cant ramps of the same shape are
|
||||
double constexpr kCurve{1.0 / 50000.0}; // 1/m: a curve, not a straight
|
||||
double constexpr kJumpCurvature{1e-6}; // 1/m
|
||||
double constexpr kStep{0.5}; // mm: a smaller step of the cant isn't one
|
||||
@@ -85,7 +87,8 @@ double curvature_at(element const &Element, double const Chainage)
|
||||
{
|
||||
if (Element.length <= kSame)
|
||||
return Element.curvature_end;
|
||||
return std::lerp(Element.curvature_start, Element.curvature_end, std::clamp((Chainage - Element.start) / Element.length, 0.0, 1.0));
|
||||
auto const t{std::clamp((Chainage - Element.start) / Element.length, 0.0, 1.0)};
|
||||
return std::lerp(Element.curvature_start, Element.curvature_end, Element.bloss ? t * t * (3.0 - 2.0 * t) : t);
|
||||
}
|
||||
|
||||
// a point inside an element where the curvature and the cant are known from inside it
|
||||
@@ -191,6 +194,16 @@ class checker
|
||||
continue;
|
||||
result.push_back({point.chainage, curvature_at(Element, point.chainage), point.cant});
|
||||
}
|
||||
// the curvature of a Bloss curve doesn't change evenly: eight pieces of it, for its steeper middle to be seen
|
||||
if (Element.bloss)
|
||||
{
|
||||
for (int i = 1; i < kBlossPieces; ++i)
|
||||
{
|
||||
auto const chainage{Element.start + Element.length * i / kBlossPieces};
|
||||
result.push_back({chainage, curvature_at(Element, chainage), cant_at(m_line.cant, chainage, true)});
|
||||
}
|
||||
std::ranges::sort(result, {}, &station::chainage);
|
||||
}
|
||||
result.push_back({end, Element.curvature_end, cant_at(m_line.cant, end, false)});
|
||||
return result;
|
||||
}
|
||||
@@ -290,8 +303,9 @@ class checker
|
||||
if (element.kind == element_kind::transition)
|
||||
{
|
||||
check(parameter::transition_length, element.length, Index, Here, element.start, element.length);
|
||||
// the arc moved in by a cubic parabola or a clothoid: L^2 / 24 times the change of the curvature (ST-T1-A6 tab. 9.11)
|
||||
auto const shift{element.length * element.length * std::abs(element.curvature_end - element.curvature_start) / 24.0};
|
||||
// the arc moved in by a cubic parabola or a clothoid: L^2 / 24 times the change of the curvature (ST-T1-A6 tab. 9.11), by a
|
||||
// Bloss curve L^2 / 40
|
||||
auto const shift{element.length * element.length * std::abs(element.curvature_end - element.curvature_start) / (element.bloss ? 40.0 : 24.0)};
|
||||
check(parameter::transition_shift, shift, Index, Here, element.start, element.length);
|
||||
return;
|
||||
}
|
||||
@@ -374,15 +388,22 @@ class checker
|
||||
return result;
|
||||
}
|
||||
|
||||
// the shortest element between two jumps for them to be taken apart: the longest the profiles of the element between them ask for
|
||||
// the shortest element between two jumps for them to be taken apart: the longest the profiles of the element between them ask for.
|
||||
// TSI INF and EN 13803 limit the jump but say nothing of jumps close together, so with only them there the longest any profile
|
||||
// asks for is taken: otherwise two jumps a metre apart would each pass a limit their sum breaks
|
||||
double intermediate(std::size_t const Index, double const Speed) const
|
||||
{
|
||||
auto const &element{m_line.elements[Index]};
|
||||
double result{0.0};
|
||||
for (auto const profile : profiles(element))
|
||||
if (auto const bound{limits(profile, parameter::intermediate_length, where(element, Speed, 0.0)).block})
|
||||
result = std::max(result, bound->value);
|
||||
return result;
|
||||
auto const longest = [this, &element, Speed](auto const &Profiles) {
|
||||
double result{0.0};
|
||||
for (auto const profile : Profiles)
|
||||
if (auto const bound{limits(profile, parameter::intermediate_length, where(element, Speed, 0.0)).block})
|
||||
result = std::max(result, bound->value);
|
||||
return result;
|
||||
};
|
||||
if (auto const own{longest(profiles(element))}; own > 0.0)
|
||||
return own;
|
||||
return longest(std::array{profile_id::plk, profile_id::tsi, profile_id::en13803, profile_id::ch});
|
||||
}
|
||||
|
||||
// ST-T1-A6 9.11 pkt 8 - 13: the jumps closer than the intermediate length, changing the cant deficiency the same way, are taken
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
wait 5
|
||||
switchplace Rz_60E1-300-1:9 40 150 1 1
|
||||
expect records z1 1 switch
|
||||
expect shaped z1 yes
|
||||
# the end of the diverging path of z1 moved aside with the gizmo: z1 no longer has the shape its record says
|
||||
select z1
|
||||
gizmo begin translate 1 end
|
||||
gizmo offset 0.5 0 0
|
||||
gizmo end
|
||||
# the drag went through: without it the case would only delete a switch which kept its shape
|
||||
expect shaped z1 no
|
||||
expect records z1 1 switch
|
||||
deletetrack z1
|
||||
expect track z1 removed
|
||||
|
||||
@@ -34,17 +34,17 @@ Line n01: 988.0 m, 11 elements, 19 findings
|
||||
828.0 note cant change rate 42 mm/s, PLK recommends at most 35 mm/s (tab. 9.13) [n13]
|
||||
|
||||
Norms: TSI INF, line 100 km/h, slow trains 60 km/h, mixed traffic, main track, 5 Tg a year, the speed of the tracks where they have one
|
||||
Line n01: 988.0 m, 11 elements, 3 findings
|
||||
Line n01: 988.0 m, 11 elements, 4 findings
|
||||
478.0 hard limit abrupt change of the cant deficiency 191 mm, TSI INF allows at most 130 mm (4.2.4.4(1)) [n07]
|
||||
598.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 900 m (4.2.3.5(1)) [n10]
|
||||
648.0 hard limit cant ramp 3.00 mm/m, EN 13803-1 allows at most 2.50 mm/m (5.2.5) [n11]
|
||||
648.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 500 m (4.2.3.5(1)) [n11]
|
||||
|
||||
Norms: EN 13803, line 100 km/h, slow trains 60 km/h, mixed traffic, main track, 5 Tg a year, the speed of the tracks where they have one
|
||||
Line n01: 988.0 m, 11 elements, 10 findings
|
||||
Line n01: 988.0 m, 11 elements, 9 findings
|
||||
210.0 warning cant deficiency 137 mm, EN 13803 allows at most 130 mm (5.2.3, tab. 1) [n03]
|
||||
398.0 warning abrupt change of the cant deficiency 106 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n06]
|
||||
478.0 warning abrupt change of the cant deficiency 106 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n07]
|
||||
488.0 warning abrupt change of the cant deficiency 85 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n08]
|
||||
478.0 hard limit abrupt change of the cant deficiency 191 mm, TSI INF allows at most 130 mm (4.2.4.4(1)) [n07]
|
||||
548.0 warning abrupt change of the cant deficiency 85 mm, EN 13803 allows at most 50 mm (EN 13803-2 7.1.3), the limit not confirmed [n09]
|
||||
598.0 hard limit break of the grade with no vertical curve, TSI INF asks for a radius of at least 900 m (4.2.3.5(1)) [n10]
|
||||
648.0 hard limit cant ramp 3.00 mm/m, EN 13803 allows at most 2.50 mm/m (5.2.5) [n11]
|
||||
|
||||
@@ -1180,7 +1180,8 @@ TEST_CASE("alignment: the cant ramp the norms ask for, which a track laid on fro
|
||||
CHECK(alignment::cant_ramp_length(100.0, 120.0, gentle) == doctest::Approx(100.0));
|
||||
// the ramp is never shorter at a higher speed
|
||||
double previous{0.0};
|
||||
for (double speed = 20.0; speed <= 200.0; speed += 10.0) {
|
||||
for (int step{0}; step <= 18; ++step) {
|
||||
auto const speed{20.0 + 10.0 * step};
|
||||
auto const length{alignment::cant_ramp_length(speed, 80.0, norms)};
|
||||
CHECK(length >= previous);
|
||||
previous = length;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// the cant of the tracks the editor lays and joins: from mm to the roll of the paths and back, signed with the turn, and matched
|
||||
// across the joints of the tracks
|
||||
//
|
||||
// the inspector of the editor shows and takes the cant on a base of 1500 mm in lambdas of its own (application/editormodetrack.cpp);
|
||||
// named, as editor_mode::cant_of_roll() and roll_of_cant(), they come with the quick fixes of the track editing, and their tests with them
|
||||
// the inspector of the editor shows and takes the cant on a base of 1500 mm through editor_mode::cant_of_roll() and roll_of_cant()
|
||||
// (application/editormodetrack.cpp). They live in the editor, which the unit tests don't link, so the self-test cases check them
|
||||
// through the inspector: tests/editor/cases/1_inspector_cant.txt
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "doctest.h"
|
||||
|
||||
@@ -34,7 +34,8 @@ track_points along(layout::network const &Network, std::vector<line_id> const &L
|
||||
track_points result;
|
||||
for (auto const id : Lines) {
|
||||
auto const &solved{Network.find(id)->solved};
|
||||
for (double s = 0.0; s < solved.length; s += Step) {
|
||||
for (int i{0}; i * Step < solved.length; ++i) {
|
||||
auto const s{i * Step};
|
||||
result.points.push_back(solved.point(s));
|
||||
result.cants.push_back(solved.cant_at(s));
|
||||
}
|
||||
@@ -58,7 +59,8 @@ void check_same_track(layout::network const &Before, line_id const Whole, layout
|
||||
auto const &first{After.find(First)->solved};
|
||||
auto const &second{After.find(Second)->solved};
|
||||
CHECK(first.length + second.length == doctest::Approx(whole.length).epsilon(1e-9));
|
||||
for (double s = 0.0; s <= whole.length; s += 7.3) {
|
||||
for (int i{0}; i * 7.3 <= whole.length; ++i) {
|
||||
auto const s{i * 7.3};
|
||||
CAPTURE(s);
|
||||
auto const &part{s < first.length ? first : second};
|
||||
auto const local{s < first.length ? s : s - first.length};
|
||||
@@ -200,6 +202,34 @@ TEST_CASE("layout commands: a line split on a straight, in an arc and in a cloth
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("layout commands: a line split right at the tangent points of an arc with no transitions keeps the track") {
|
||||
// one gentle curve with neither transitions nor cant, so its curvature jumps at the tangent points
|
||||
for (auto const share : {0.0, 1.0}) {
|
||||
CAPTURE(share);
|
||||
layout::model model;
|
||||
layout::create_line gentle;
|
||||
gentle.start = {0.0, 100.0, 0.0};
|
||||
gentle.end = {1200.0, 100.0, 50.0};
|
||||
layout::vertex bend;
|
||||
bend.point = {600.0, 0.0};
|
||||
bend.radius = 4000.0;
|
||||
gentle.vertices = {bend};
|
||||
gentle.category = line_class();
|
||||
auto const made{model.execute(gentle)};
|
||||
CAPTURE(reasons_of(made));
|
||||
REQUIRE(made.done);
|
||||
auto const before{model.state()};
|
||||
auto const &line{only_line(model)};
|
||||
auto const id{line.id};
|
||||
auto const chainage{inside(line, layout::element_role::arc, layout::number(line.shape.vertices[0].id), share)};
|
||||
auto const split{model.execute(layout::split_line{id, chainage})};
|
||||
CAPTURE(reasons_of(split));
|
||||
REQUIRE(split.done);
|
||||
check_invariants(model.state());
|
||||
check_same_track(before, id, model.state(), id, split.lines.front());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("layout commands: a split inside a vertical curve or a Bloss transition is refused; outside them it's kept") {
|
||||
layout::model model;
|
||||
REQUIRE(model.execute(three_curves(layout::transition_shape::bloss)).done);
|
||||
@@ -281,7 +311,7 @@ namespace {
|
||||
|
||||
// random edits of the network: moved vertices, new radii, transitions and cants, splits, joins, deletions, undoing and redoing
|
||||
void random_edits(unsigned const Seed, int const Count) {
|
||||
std::mt19937 random{Seed};
|
||||
std::mt19937 random{Seed}; // NOSONAR: seeded for repeatable tests, nothing secret is drawn
|
||||
auto const uniform = [&](double const Low, double const High) { return std::uniform_real_distribution<double>{Low, High}(random); };
|
||||
auto const pick = [&](std::size_t const Size) { return std::uniform_int_distribution<std::size_t>{0, Size - 1}(random); };
|
||||
layout::model model;
|
||||
|
||||
@@ -116,7 +116,8 @@ TEST_CASE("layout elements: an arc keeps its radius and its centre, points offse
|
||||
auto const e{layout::make_arc({5.0, 7.0}, {0.0, 1.0}, -1.0 / R, 200.0)};
|
||||
// turning right from heading +z: the centre to the right, at +x
|
||||
glm::dvec2 const centre{5.0 + R, 7.0};
|
||||
for (double s = 0.0; s <= 200.0; s += 25.0) {
|
||||
for (int step{0}; step <= 8; ++step) {
|
||||
auto const s{25.0 * step};
|
||||
CAPTURE(s);
|
||||
CHECK(glm::distance(e.position(s), centre) == doctest::Approx(R).epsilon(1e-12));
|
||||
CHECK(e.curvature(s) == -1.0 / R);
|
||||
|
||||
@@ -36,6 +36,11 @@ public:
|
||||
m_line.elements.back().features = Features;
|
||||
return *this;
|
||||
}
|
||||
// the last transition a Bloss curve
|
||||
line_builder &bloss() {
|
||||
m_line.elements.back().bloss = true;
|
||||
return *this;
|
||||
}
|
||||
norms::line done() {
|
||||
if (m_line.grades.empty()) {
|
||||
m_line.grades.push_back({0.0, m_end, 0.0, 0.0});
|
||||
@@ -237,6 +242,21 @@ TEST_CASE("norms engine: the abrupt changes over a straight shorter than tab. 9.
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("norms engine: TSI and EN, which say nothing of jumps close together, take them together over the intermediate length of the other profiles") {
|
||||
// the reverse curves of the test above, 10 m apart: each jump of 106.2 mm passes the TSI, their 212.4 mm don't
|
||||
auto const each{11.8 * 60 * 60 / 400.0};
|
||||
for (auto const profile : {profile_id::tsi, profile_id::en13803}) {
|
||||
CAPTURE(static_cast<int>(profile));
|
||||
line_builder builder;
|
||||
builder.straight(100, 60).arc(400, 80, 60).straight(10.0, 60).arc(-400, 80, 60).straight(100, 60);
|
||||
auto const found{of(evaluate(builder.done(), mixed_main(60), profile), parameter::deficiency_jump)};
|
||||
auto const summed{std::ranges::find_if(found, [](norms::finding const &Finding) { return std::abs(Finding.chainage - 180.0) < 1e-6; })};
|
||||
REQUIRE(summed != found.end());
|
||||
CHECK(summed->value == doctest::Approx(2.0 * each));
|
||||
CHECK(summed->length == doctest::Approx(10.0));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("norms engine: the gradient and the rate of change of the cant along a ramp, the rate of change of the deficiency along a transition") {
|
||||
// 100 mm over 50 m at 120 km/h: 2 mm/m, 66.7 mm/s
|
||||
line_builder ramp;
|
||||
@@ -270,6 +290,39 @@ TEST_CASE("norms engine: the gradient and the rate of change of the cant along a
|
||||
CHECK(change.front().level == tier::block);
|
||||
}
|
||||
|
||||
TEST_CASE("norms engine: a Bloss transition changes the cant deficiency fastest in its middle, and moves the arc in by L^2 / 40R") {
|
||||
// 60 m into R 600 m at 100 km/h, the cant evenly up to 60 mm: 136.7 mm of deficiency, 63.3 mm/s along an even transition, and
|
||||
// 1.5 * 196.7 - 60 = 235 mm per its length in the middle of a Bloss curve, 108.8 mm/s, past the 80 mm/s of the hard limit
|
||||
auto const findings = [](bool const Bloss) {
|
||||
line_builder curve;
|
||||
curve.straight(100, 100).transition(0, 600, 60, 100);
|
||||
if (Bloss)
|
||||
curve.bloss();
|
||||
curve.arc(600, 100, 100).transition(600, 0, 60, 100);
|
||||
if (Bloss)
|
||||
curve.bloss();
|
||||
curve.straight(100, 100);
|
||||
curve.cant(0, 0).cant(100, 0).cant(160, 60).cant(260, 60).cant(320, 0);
|
||||
return evaluate(curve.done(), mixed_main(100));
|
||||
};
|
||||
auto const fastest = [](std::vector<norms::finding> const &Found) {
|
||||
double result{0.0};
|
||||
for (auto const &finding : of(Found, parameter::deficiency_rate))
|
||||
result = std::max(result, finding.value);
|
||||
return result;
|
||||
};
|
||||
auto const even{findings(false)};
|
||||
auto const bloss{findings(true)};
|
||||
CHECK(fastest(even) == doctest::Approx((11.8 * 100 * 100 / 600.0 - 60.0) * 100 / (3.6 * 60.0)).epsilon(0.01));
|
||||
// seen as eight pieces, a little below the peak of the curve
|
||||
CHECK(fastest(bloss) > 100.0);
|
||||
CHECK(fastest(bloss) < 109.0);
|
||||
auto const blocked{of(bloss, parameter::deficiency_rate)};
|
||||
CHECK(std::ranges::any_of(blocked, [](norms::finding const &Finding) { return Finding.level == tier::block; }));
|
||||
for (auto const &finding : of(bloss, parameter::transition_shift))
|
||||
CHECK(finding.value == doctest::Approx(60.0 * 60.0 / (600.0 * 40.0)));
|
||||
}
|
||||
|
||||
TEST_CASE("norms engine: the lengths of the elements, the transition curves and the radius") {
|
||||
line_builder builder;
|
||||
builder.straight(100, 100).arc(400, 20, 100).straight(28, 100).transition(0, 400, 20, 100).arc(400, 100, 100).transition(400, 0, 60, 100).straight(100, 100);
|
||||
|
||||
@@ -149,16 +149,15 @@ TEST_CASE("norms report: the cant of a curve laid by the editor leans into it, b
|
||||
}
|
||||
}
|
||||
CHECK(curved > 50);
|
||||
// so at 80 km/h the arc falls short by 11.8 V^2 / R - 80 mm, not by more
|
||||
// so at 90 km/h the arc falls short by 11.8 V^2 / R - 80 mm, not by more: 159 mm, past the 110 mm of a finding (at 80 km/h
|
||||
// the 108.8 mm would make none, and the check would never run)
|
||||
norms_report::options options;
|
||||
options.line.vmax = 80.0;
|
||||
options.line.vmax = 90.0;
|
||||
options.track_speeds = false;
|
||||
auto const checked{norms_report::check(spans, options)};
|
||||
for (auto const &found : checked.entries) {
|
||||
if (found.finding.what == norms::parameter::cant_deficiency && found.kind == norms::element_kind::arc) {
|
||||
CHECK(found.finding.value == doctest::Approx(11.8 * 80 * 80 / 400.0 - 80.0).epsilon(0.02));
|
||||
}
|
||||
}
|
||||
auto const deficient{std::ranges::find_if(checked.entries, [](auto const &Found) { return Found.finding.what == norms::parameter::cant_deficiency && Found.kind == norms::element_kind::arc; })};
|
||||
REQUIRE(deficient != checked.entries.end());
|
||||
CHECK(deficient->finding.value == doctest::Approx(11.8 * 90 * 90 / 400.0 - 80.0).epsilon(0.02));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,6 +182,22 @@ TEST_CASE("track text: what the game writes otherwise than it was given, the sam
|
||||
// what doesn't survive yet: each fails until it does, then doctest reports the test passing against should_fail, and the entry goes
|
||||
// over to the files of the entries which come out the same
|
||||
|
||||
// what those tests start from, checked apart from them: under should_fail a missing file or entry would pass for a loss
|
||||
TEST_CASE("track text: the entries known to be lost are there, with what they're about, and read") {
|
||||
track_reading const reading;
|
||||
struct known {
|
||||
char const *name;
|
||||
char const *about;
|
||||
};
|
||||
for (auto const &[name, about] : {known{"angles", " angle1 15 "}, known{"fouling", " fouling1 ukres_a "}, known{"tor1@iso1", "tor1@iso1"}, known{"digits", " digits "}}) {
|
||||
CAPTURE(name);
|
||||
auto const text{entry("known_lost.scn", name)};
|
||||
REQUIRE(false == text.empty());
|
||||
CHECK(text.find(about) != std::string::npos);
|
||||
CHECK(read_track(text) != nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("track text: the angles the ends are cut at are written back (known lost: read and dropped)" * doctest::should_fail()) {
|
||||
track_reading const reading;
|
||||
round_trip const trip{entry("known_lost.scn", "angles")};
|
||||
|
||||
Reference in New Issue
Block a user