mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 04:47:06 +01:00
ca1f2239df
E5 (editor-tracks-domain.md §4 "Rozjazd", §7): every type of the catalogue is a turnout the model lays, its tracks lines it owns and its legs nodes, kept whole or refused like the ordinary switches E2b laid. E2b refused the rest with "stage E5". - Secant blades (S42): the diverging track runs along the main one for the pre-blade stretch and turns off it by the angle of the blades at their tips, the rest of 1:n on its arc; a turn inside the track, the node at the start keeping the heading of the main track. The generator ends a piece there with the heading of the element before it (unchanged where a line runs on in its heading). - Double switches (Rpd, Rpj, Rps): the main track cut at the start of the second switch, its node holding the main track, the main track of the second switch (main2) and its diverging track, to the other side or the same one, as switch_design::build() lays it. Written as the switch tool writes them: the first switch, a plain track of a metre before the second one (the simulation joins a switch to plain tracks only), the second switch. - Symmetric switches (Rls): both tracks turning off by half of the angle, to both sides, laid at a free end of a line, which they end (the line beyond it would have to turn at the node); not moved along the line. - Slips (Rkp, Rkpd) and diamond crossings (Skrz): the main track a part of the line, the crossing track across its middle at the angle of the slip between two nodes of its own, the slip curves from the start to the end of the crossing track and, of a double slip, from its start to the end of the main track; slip_of() lays the curves with the blades of the ordinary switch of the rail, radius and angle (no data of the slips' own blades was found), passing the crossing as near as the rails of the simulator's profile let them. The three with the blades outside of the diamond whose curves then reach past the half length of Id-4 (49E1 190-1:6,6, 300-1:9, 500-1:9, by up to 0.3 m) are laid as long as their curves. Written as the switch tool writes them: a switch at each leg a slip curve leaves, the tracks crossing and the middles of the slip curves plain tracks, the joints inside it the same numbers on both sides. - The rules: a double switch, a slip, a crossing (11.4 pkt 4 a, b) and a symmetric switch (no rule of table 11.8 for it) lie on straights only; an invariant, refused with the reason before anything is laid. The norms judge the tracks crossing at a slip or a crossing as crossings (no cant, tab. 9.6), its slip curves as diverging tracks. - The ends of the tracks of a turnout which carry no line through their node (the starts of the diverging tracks, the ends of the slip curves) are branch_end(); a node holds such an end beside a track of the same turnout on its side. settle() lays all the tracks a turnout lays itself (lay_tracks()), the nodes of its own where they end; lifting, moving, changing (to another kind too) and removing a turnout take all of them along. - The project file: the turnout record gets "second <node> <main2> <diverging2> <node>" and "crossing <line> <node> <node> slip <line>" where the turnout has them (diverging 0 0 for a crossing); version 1, unreleased, read as before without them. The generated section keeps each track a turnout is made of. - TSI INF 4.2.3.4(1), 150 m at least, judges the plain line, not the curves of switches (4.2.5): its hard row leaves out the tracks of the turnouts, so the industrial S42 switches of R 70 and 140 m are laid. Tests: U: every type of the catalogue laid (41 ordinary, 3 symmetric, 15 double, 18 slips, 20 crossings) on a straight to both sides along the line and against it, its legs where the catalogue puts them (the main track a + b, 1:n at the ends, the second switch at the stagger, the crossing track at the angle of the slip, half its length from the crossing), moved and taken out, the line one again, each a step to undo; the turn of the secant blades of S42-190-1:7 at the end of the pre-blade stretch; a double switch, two slips and a crossing refused in a curve, a secant S42 bent in a side track, a symmetric switch refused at the end of a curve. The three fitted to the tangents of S42-140-1:6,6 16/12 measured are refused by the norms (tab. 9.14) where the transition one is. P: 200 random edits with every type along arcs and transitions, seeds 5150, 2718 and 1618: the invariants after each, a refusal changing nothing, undone back to the start exactly. G: every type made into the tracks of the simulator and read back by TTrack::Load, the ends of the paths at the legs or at each other to the bit, the velocity and the frog; a double switch, a double slip and a crossing written to the project file and read back, their tracks laid again the same to the bit. The E2b case of the types refused now checks that they're laid. Unit tests 1077 -> 1086.
123 lines
6.0 KiB
C++
123 lines
6.0 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "editor/layout/layoutNetwork.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <optional>
|
|
#include <set>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
// The project file of the track geometry (editor-tracks-domain.md §9): the domain of the editor written next to the scenery, the
|
|
// .scn and .scm files staying what the simulator reads. One file per map, shared by its scenarios: <map>.eu07proj next to the file of
|
|
// the map. Plain text, a line a record, read and written here only; the schema version on the first line, a file of a newer one refused.
|
|
//
|
|
// Version 1:
|
|
// eu07proj 1
|
|
// next node <n> line <n> vertex <n> turnout <n> the identifiers handed out next; none is handed out again
|
|
// norms <profile> the profile of the scenery: plk, tsi, en13803, ch
|
|
// area <name> <profile> <count> <x z>... a profile for an area outlined in the plan
|
|
// lineprofile <name> <profile> a profile for a line by name
|
|
// class <n> vmax <km/h> vmin <km/h> traffic <passenger|mixed|freight> track <main|side> load <Tg> features <flags>
|
|
// node <id> at <x y z> heading <x z> curvature <1/m> cant <mm> grade <ratio> ends <count> {<line> <start|end> <sense 1|-1>}
|
|
// line <id> from <node> to <node> class <n> chainage <m> transition <clothoid|parabola|bloss> ramp <linear|bloss> continues <0|1> <0|1>
|
|
// turnout <id, 0 for a line of its own> profile <profile, - for the one of its place>
|
|
// vertex <id> at <x z> radius <m> in <m> out <m> cant <mm>
|
|
// grade <chainage> <elevation> <vertical radius>
|
|
// end
|
|
// turnouts
|
|
// turnout <id> type <name> hand <1|-1> direction <1|-1> start <node> main <line> <node> diverging <line> <node> chainage <m>
|
|
// radii <main> <diverging> cant <mm> speeds <main> <diverging> velocity <km/h> movable <0|1>
|
|
// [second <node> <main track on> <diverging track> <node at its end>] a double switch: its second switch (E5)
|
|
// [crossing <line> <node> <node> slip <line, 0 for none>] a slip or a crossing: the crossing track, the second slip
|
|
// curve; the diverging track 0 0 of a crossing (E5)
|
|
// end the turnouts (E2b), their tracks lines of them; the ones they lay laid by the turnouts
|
|
// anchors ... end kept for the anchors of the lineside objects (E6), as read; empty in version 1
|
|
// generated
|
|
// track <name> line <id> file <file> sum <16 hex digits> a track written by the generator, the checksum of its text
|
|
// switch <name> line <id> file <file> sum <16 hex digits> the switch track of a turnout, by its main track
|
|
// hand <line> a line whose tracks were changed outside the editor, not written over
|
|
// end
|
|
// legacy <mark> <file> line <id> [why <the rest of the line>] //$ lines read when the map was first opened, as they were
|
|
// | <the line>
|
|
// end
|
|
// Lines starting with # are comments. The numbers are written in the shortest form which reads back to the same double; names and files
|
|
// with %20 for a blank and %25 for a percent sign.
|
|
namespace project
|
|
{
|
|
|
|
inline constexpr int schema_version{1};
|
|
inline constexpr std::string_view extension{".eu07proj"};
|
|
|
|
// a node of the simulator written by the generator: the name, the line it's made of (the main track of a turnout for its switch track),
|
|
// the file it's written into and the checksum of its text (checksum()), to tell a change made outside the editor
|
|
struct generated_node
|
|
{
|
|
std::string kind{"track"};
|
|
std::string name;
|
|
layout::line_id line{layout::line_id::none};
|
|
std::string file; // relative to the folder of the scenery, as the includes name it
|
|
std::uint64_t sum{0};
|
|
|
|
bool operator==(generated_node const &) const = default;
|
|
};
|
|
|
|
// the //$ lines of a kind read from a scenery file when the map was first opened (§9: they stay in the file until the author removes
|
|
// them): an //$h or an //$p record with the line it became, if it became one, and why not; the lines of the other kinds as a whole
|
|
struct legacy_record
|
|
{
|
|
char mark{'h'};
|
|
std::string file;
|
|
layout::line_id line{layout::line_id::none};
|
|
std::string why;
|
|
std::vector<std::string> lines; // the mark taken off
|
|
|
|
bool operator==(legacy_record const &) const = default;
|
|
};
|
|
|
|
struct document
|
|
{
|
|
layout::network network; // the lines, the nodes and the turnouts, the profiles of the norms by place, the identifiers handed out
|
|
std::vector<generated_node> generated;
|
|
std::set<layout::line_id> hand_changed;
|
|
std::vector<std::string> anchors; // the section reserved for the anchors of the lineside objects, kept as read
|
|
std::vector<legacy_record> legacy;
|
|
};
|
|
|
|
// the same contents: the lines and the nodes, the norms, the identifiers handed out and the rest
|
|
bool same(document const &A, document const &B);
|
|
|
|
std::string write(document const &Project);
|
|
|
|
struct read_result
|
|
{
|
|
std::optional<document> project;
|
|
std::string error; // why there's none: not a project file, a newer schema, a line it can't read
|
|
std::vector<std::string> notes; // the lines which can't be laid as they are written
|
|
};
|
|
// the lines are laid between their nodes as read; the nodes keep what's written of them
|
|
read_result read(std::string_view const Text);
|
|
|
|
// <map>.eu07proj next to the file of the map
|
|
std::filesystem::path path_of(std::filesystem::path const &Map);
|
|
read_result load(std::filesystem::path const &Path);
|
|
// written whole, through a file next to it put in its place, so a failed write leaves the old one; false with the reason in Error
|
|
bool save(document const &Project, std::filesystem::path const &Path, std::string &Error);
|
|
|
|
// the words of the file: a name with no blanks, %20 for a blank, %25 for a percent sign; - for none
|
|
std::string word(std::string_view const Text);
|
|
std::string unword(std::string_view const Word);
|
|
|
|
} // namespace project
|