mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 05:57:08 +01:00
feat(editor): the joints of old tracks as hard points of the pieces, the names, events and circuits of the old tracks kept by the lines
E6 (editor-tracks-domain.md §5 "Podział na kawałki zachowuje miejsca...", §10 "Stare złącza jako twarde punkty podziału"), the hook of the generator E2a left (generator_options::hard_splits, a line given any refused). - A line keeps the old tracks it was taken over from (line::hard_splits): where along it the stretch of each begins, its name, the words of its entry before the path (the width, the friction, ... the visibility and the materials) and after it (the speed, the events, the isolated circuits and the rest), whether it ran against the line. In the line rather than in the options of the generator, so a command which cuts or joins lines carries them and an undo puts them back: a line cut (split_line, a turnout laid into it) gives those past the cut to the part after it, and the old track cut in two keeps its name and its events on the part it ran into first, the other part a stretch of it the generator names (continued); two lines joined, the second one's after the first one's. - The generator ends the pieces at each joint inside the line (a joint stays, a break of the elements next to it gives way) and writes the pieces of a stretch as the old track was: its name on the piece it ran into first with all its attributes, <name>_2, <name>_3... on the others with them but its events (an event of a track is called once), its surface, the path written the way it ran (event1 and event2, the sign of the rolls); an old track of no name named by the generator, its events kept. A line with none is made as before. - The project file: "old <chainage> <name> reversed <0|1> continued <0|1> surface <words> attributes <words>" in the block of a line; version 1, unreleased, read as before without them. Tests: G: a line of three curves given three old tracks (one named with its events and its circuit, one of no name, one which ran against the line): the pieces end at the joints, each name once, the attributes of the first on its first piece and without its event on the others, the event of the unnamed one once, the one which ran against the line written from the end of the line; written into the project file and read back the same. It takes the place of the E2a case of the hook refusing. Unit tests 1103 -> 1103.
This commit is contained in:
@@ -150,6 +150,32 @@ std::optional<glm::dvec2> crossing(glm::dvec2 const &A, glm::dvec2 const &AlongA
|
||||
return A + AlongA * first;
|
||||
}
|
||||
|
||||
// the joints of the old tracks of a line cut at the chainage: those past it go with the part after it; the old track cut in two keeps its
|
||||
// name and its events on the part it ran into first, the other part a stretch of it which the generator names, with the rest of what it had
|
||||
void split_old_tracks(std::vector<hard_split> const &All, double const Chainage, std::vector<hard_split> &Head, std::vector<hard_split> &Tail)
|
||||
{
|
||||
Head.clear();
|
||||
Tail.clear();
|
||||
for (auto const &split : All)
|
||||
{
|
||||
if (split.chainage < Chainage - 1e-6)
|
||||
Head.push_back(split);
|
||||
else
|
||||
Tail.push_back({std::max(0.0, split.chainage - Chainage), split.track});
|
||||
}
|
||||
if (Head.empty() || (false == Tail.empty() && Tail.front().chainage <= 1e-6))
|
||||
return;
|
||||
auto cut_off{Head.back().track};
|
||||
cut_off.continued = true;
|
||||
if (Head.back().track.reversed)
|
||||
{
|
||||
Tail.insert(Tail.begin(), {0.0, Head.back().track});
|
||||
Head.back().track = cut_off;
|
||||
}
|
||||
else
|
||||
Tail.insert(Tail.begin(), {0.0, cut_off});
|
||||
}
|
||||
|
||||
// the new node and the new line a split made
|
||||
struct split_made
|
||||
{
|
||||
@@ -290,6 +316,7 @@ reasons split_at(transaction &Change, line_id const Line, double const Chainage,
|
||||
else if (point.chainage > s)
|
||||
tail_line.shape.grades.push_back({point.chainage - s, point.elevation, point.vertical_radius});
|
||||
}
|
||||
split_old_tracks(original.hard_splits, s, head_line.hard_splits, tail_line.hard_splits);
|
||||
// the node at the end of the line holds the end of the new one now
|
||||
auto &last{Change.change(original.end)};
|
||||
for (auto &end : last.ends)
|
||||
@@ -354,6 +381,8 @@ bool merge_at(transaction &Change, node_id const Node)
|
||||
merged.end_continues = second->end_continues;
|
||||
for (auto const &point : second->shape.grades)
|
||||
merged.shape.grades.push_back({point.chainage + a.length, point.elevation, point.vertical_radius});
|
||||
for (auto const &split : second->hard_splits)
|
||||
merged.hard_splits.push_back({split.chainage + a.length, split.track});
|
||||
auto const &before{first->shape.vertices};
|
||||
auto const &after{second->shape.vertices};
|
||||
std::vector<std::vector<vertex>> candidates;
|
||||
|
||||
@@ -48,6 +48,25 @@ std::string number_text(float const Value)
|
||||
return std::format("{}", Value);
|
||||
}
|
||||
|
||||
std::string point_text(glm::dvec3 const &Point)
|
||||
{
|
||||
return std::format("{} {} {}", number_text(Point.x), number_text(Point.y), number_text(Point.z));
|
||||
}
|
||||
|
||||
// a path as an entry has it: the start, its roll, the control vectors, the end, its roll, the radius
|
||||
std::string path_text(segment_data const &Path)
|
||||
{
|
||||
auto const &p{Path.points};
|
||||
return std::format("{} {} {} {} {} {} {}", point_text(p[segment_data::point::start]), number_text(Path.rolls[0]), point_text(p[segment_data::point::control1]),
|
||||
point_text(p[segment_data::point::control2]), point_text(p[segment_data::point::end]), number_text(Path.rolls[1]), number_text(Path.radius));
|
||||
}
|
||||
|
||||
// the entry of a plain track of the piece: its name, its length, the surface, its path and the attributes
|
||||
std::string entry_text(generated_piece const &Piece, std::string_view const Surface, std::string_view const Attributes)
|
||||
{
|
||||
return std::format("node -1 0 {} track normal {:.3f} {} {} {} endtrack\n", Piece.name, std::abs(Piece.to - Piece.from), Surface, path_text(Piece.path), Attributes);
|
||||
}
|
||||
|
||||
class cutter
|
||||
{
|
||||
public:
|
||||
@@ -138,12 +157,15 @@ class cutter
|
||||
result.push_back(stretch.from);
|
||||
result.push_back(stretch.to);
|
||||
}
|
||||
auto const hard{hard_points()};
|
||||
result.insert(result.end(), hard.begin(), hard.end());
|
||||
std::ranges::sort(result);
|
||||
std::erase_if(result, [&](double const Chainage) { return Chainage < 0.0 || Chainage > m_solved.length; });
|
||||
auto const last{std::unique(result.begin(), result.end(), [](double const A, double const B) { return std::abs(A - B) < 1e-9; })};
|
||||
result.erase(last, result.end());
|
||||
result.front() = 0.0;
|
||||
result.back() = m_solved.length;
|
||||
auto const is_hard = [&result, &hard](std::size_t const At) { return At == 0 || At + 1 == result.size() || std::ranges::find(hard, result[At]) != hard.end(); };
|
||||
for (std::size_t i = 0; i + 1 < result.size() && result.size() > 2;)
|
||||
{
|
||||
if (result[i + 1] - result[i] >= kShortestPiece)
|
||||
@@ -151,12 +173,28 @@ class cutter
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
// the short stretch goes to its neighbour: the break after it goes, or the one before it at the end
|
||||
result.erase(result.begin() + static_cast<std::ptrdiff_t>(i + 1 + 1 < result.size() ? i + 1 : i));
|
||||
// the short stretch goes to its neighbour: the break after it goes, or the one before it; a joint of an old track stays, the
|
||||
// short piece with it where both ends are
|
||||
if (false == is_hard(i + 1))
|
||||
result.erase(result.begin() + static_cast<std::ptrdiff_t>(i + 1));
|
||||
else if (false == is_hard(i))
|
||||
result.erase(result.begin() + static_cast<std::ptrdiff_t>(i));
|
||||
else
|
||||
++i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// the joints of the old tracks inside the line
|
||||
std::vector<double> hard_points() const
|
||||
{
|
||||
std::vector<double> result;
|
||||
for (auto const &split : m_line.hard_splits)
|
||||
if (split.chainage > 0.0 && split.chainage < m_solved.length)
|
||||
result.push_back(split.chainage);
|
||||
return result;
|
||||
}
|
||||
|
||||
// the element the chainage lies in, the curve of a span all in one
|
||||
element const *only_element(double const From, double const To) const
|
||||
{
|
||||
@@ -367,28 +405,74 @@ class cutter
|
||||
piece.to = To.chainage;
|
||||
piece.path = path;
|
||||
piece.deviation = off;
|
||||
auto const &p{path.points};
|
||||
auto const point = [](glm::dvec3 const &Point) { return std::format("{} {} {}", number_text(Point.x), number_text(Point.y), number_text(Point.z)); };
|
||||
piece.text = std::format("node -1 0 {} track normal {:.3f} {} {} {} {} {} {} {} {} velocity {} endtrack\n", piece.name, To.chainage - From.chainage, m_options.surface, point(p[segment_data::point::start]),
|
||||
number_text(path.rolls[0]), point(p[segment_data::point::control1]), point(p[segment_data::point::control2]), point(p[segment_data::point::end]), number_text(path.rolls[1]),
|
||||
number_text(path.radius), number_text(m_line.category.vmax));
|
||||
piece.text = entry_text(piece, m_options.surface, std::format("velocity {}", number_text(m_line.category.vmax)));
|
||||
Into.push_back(std::move(piece));
|
||||
}
|
||||
|
||||
std::map<std::string, int> m_counts;
|
||||
};
|
||||
|
||||
std::string point_text(glm::dvec3 const &Point)
|
||||
// the attributes of an old track without its events, for the pieces of its stretch which don't carry its name
|
||||
std::string without_events(std::string_view const Attributes)
|
||||
{
|
||||
return std::format("{} {} {}", number_text(Point.x), number_text(Point.y), number_text(Point.z));
|
||||
static constexpr std::array<std::string_view, 6> events{"event0", "event1", "event2", "eventall0", "eventall1", "eventall2"};
|
||||
std::string result;
|
||||
std::size_t at{0};
|
||||
bool skip{false};
|
||||
while (at < Attributes.size())
|
||||
{
|
||||
auto const start{Attributes.find_first_not_of(' ', at)};
|
||||
if (start == std::string_view::npos)
|
||||
break;
|
||||
auto const end{std::min(Attributes.find(' ', start), Attributes.size())};
|
||||
auto const word{Attributes.substr(start, end - start)};
|
||||
at = end;
|
||||
if (skip)
|
||||
skip = false;
|
||||
else if (std::ranges::find(events, word) != events.end())
|
||||
skip = true;
|
||||
else
|
||||
result += (result.empty() ? "" : " ") + std::string{word};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// a path as an entry has it: the start, its roll, the control vectors, the end, its roll, the radius
|
||||
std::string path_text(segment_data const &Path)
|
||||
// the pieces of the stretches of the old tracks named and written as each old track was: its name on the piece it ran into first, with
|
||||
// its events, <name>_2... on the others, its surface and its attributes, the path the way it ran; a piece out of any stretch as the generator
|
||||
// names and writes it
|
||||
void keep_old_tracks(line const &Line, std::vector<generated_piece> &Pieces, generator_options const &Options)
|
||||
{
|
||||
auto const &p{Path.points};
|
||||
return std::format("{} {} {} {} {} {} {}", point_text(p[segment_data::point::start]), number_text(Path.rolls[0]), point_text(p[segment_data::point::control1]),
|
||||
point_text(p[segment_data::point::control2]), point_text(p[segment_data::point::end]), number_text(Path.rolls[1]), number_text(Path.radius));
|
||||
auto const &splits{Line.hard_splits};
|
||||
auto const stretch_of = [&splits](generated_piece const &Piece) {
|
||||
auto const after{std::ranges::upper_bound(splits, Piece.from + 1e-6, {}, &hard_split::chainage)};
|
||||
return after == splits.begin() ? splits.size() : static_cast<std::size_t>(after - splits.begin()) - 1;
|
||||
};
|
||||
std::size_t first{0};
|
||||
while (first < Pieces.size())
|
||||
{
|
||||
auto const stretch{stretch_of(Pieces[first])};
|
||||
auto last{first + 1};
|
||||
while (last < Pieces.size() && stretch_of(Pieces[last]) == stretch)
|
||||
++last;
|
||||
if (stretch < splits.size())
|
||||
{
|
||||
auto const &old{splits[stretch].track};
|
||||
for (auto i = first; i < last; ++i)
|
||||
{
|
||||
auto &piece{Pieces[i]};
|
||||
auto const order{old.reversed ? last - 1 - i : i - first};
|
||||
if (false == old.name.empty() && false == old.continued)
|
||||
piece.name = order == 0 ? old.name : std::format("{}_{}", old.name, order + 1);
|
||||
if (old.reversed)
|
||||
piece.path = geometry::reversed(piece.path);
|
||||
auto attributes{order == 0 && false == old.continued ? old.attributes : without_events(old.attributes)};
|
||||
if (old.attributes.empty())
|
||||
attributes = std::format("velocity {}", number_text(Line.category.vmax));
|
||||
piece.text = entry_text(piece, old.surface.empty() ? Options.surface : old.surface, attributes);
|
||||
}
|
||||
}
|
||||
first = last;
|
||||
}
|
||||
}
|
||||
|
||||
// the path the pieces make, from the start of the first to the end of the last, for the versions of the simulator which know only the path:
|
||||
@@ -516,13 +600,10 @@ generated_line generate(network const &Network, line_id const Line, generator_op
|
||||
result.errors.push_back(std::format("line {} is a track of turnout {}, made with it", number(Line), number(owner->turnout)));
|
||||
return result;
|
||||
}
|
||||
if (auto const hard{Options.hard_splits.find(Line)}; hard != Options.hard_splits.end() && false == hard->second.empty())
|
||||
{
|
||||
result.errors.push_back(std::format("line {}: the joints of old tracks as hard points of the pieces come with stage E6", number(Line)));
|
||||
return result;
|
||||
}
|
||||
cutter pieces{Network, *owner, Options};
|
||||
result.pieces = pieces.pieces(result.errors);
|
||||
if (false == owner->hard_splits.empty())
|
||||
keep_old_tracks(*owner, result.pieces, Options);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,16 +27,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
// the numbers of its nodes, its velocity as the speed rule gives it, its frog and its blades as its type has them; a double switch, a slip
|
||||
// and a crossing the switch tracks and the plain tracks the switch tool of the editor makes of them, their joints inside the turnout the
|
||||
// numbers of the points of its lines there.
|
||||
//
|
||||
// A line taken over from old tracks (stage E6) keeps their joints as hard points of the pieces (line::hard_splits, §10 "stare złącza jako
|
||||
// twarde punkty podziału"): the pieces end at each, and the pieces of the stretch of an old track carry its name, its surface and its
|
||||
// attributes (the speed, the events, the isolated circuits), each written the way the old track ran; where the stretch takes more than one
|
||||
// piece, the one the old track ran into first keeps the name and the events, the others are <name>_2, <name>_3... with the rest.
|
||||
namespace layout
|
||||
{
|
||||
|
||||
// a joint of an old track the pieces are to end at, the name of the old track kept for the piece before it (stage E6)
|
||||
struct hard_split
|
||||
{
|
||||
double chainage{0.0};
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct generator_options
|
||||
{
|
||||
std::string prefix{"l"}; // of the names of the tracks: <prefix><line>_<element><piece>
|
||||
@@ -46,9 +44,6 @@ struct generator_options
|
||||
// what an entry has between the type and the path: the width, the friction, the sound distance, the quality, the damage, the
|
||||
// environment and the visibility with the materials
|
||||
std::string surface{"1.435 0.15 25 20 0 flat vis rail_screw_used1 4 tpbps-new2 0.2 0.5 1.1"};
|
||||
// the joints of the old tracks as hard points of the pieces, by line: stage E6 (§10, "stare złącza jako twarde punkty podziału").
|
||||
// Not yet: a line given any is refused, so nothing is made which would lose the names and the events of the old tracks
|
||||
std::map<line_id, std::vector<hard_split>> hard_splits;
|
||||
};
|
||||
|
||||
struct generated_piece
|
||||
|
||||
@@ -60,6 +60,29 @@ struct node
|
||||
bool operator==(node const &) const = default;
|
||||
};
|
||||
|
||||
// an old track a line was taken over from (stage E6, editor-tracks-domain.md §5 and §10): its name and what its entry had besides the path,
|
||||
// whether it ran against the line. The pieces the generator makes of the stretch of the line it covered carry them, so the names, the events
|
||||
// and the isolated circuits the scenarios rely on stay where they were
|
||||
struct old_track
|
||||
{
|
||||
std::string name; // empty: one of no name (none), the pieces named by the generator
|
||||
std::string surface; // the words between the length and the path: the width, the friction, ... the visibility and the materials
|
||||
std::string attributes; // the words after the path up to endtrack: the speed, the events, the isolated circuits and the rest
|
||||
bool reversed{false}; // it ran against the line
|
||||
bool continued{false}; // a part of an old track a split cut off: named by the generator, its events left with the other part
|
||||
|
||||
bool operator==(old_track const &) const = default;
|
||||
};
|
||||
|
||||
// a joint of an old track as a hard point of the pieces: where along the line the stretch of the old track begins; the pieces end there
|
||||
struct hard_split
|
||||
{
|
||||
double chainage{0.0};
|
||||
old_track track;
|
||||
|
||||
bool operator==(hard_split const &) const = default;
|
||||
};
|
||||
|
||||
struct line
|
||||
{
|
||||
line_id id{line_id::none};
|
||||
@@ -73,6 +96,8 @@ struct line
|
||||
double chainage_start{0.0}; // m, the kilometrage of the start of the line
|
||||
norms::line_class category;
|
||||
std::optional<norms::profile_id> profile; // of the norms, its own; none: the one of the area it lies in
|
||||
// the old tracks it was taken over from, by the chainage each begins at, in order; none for a line laid in the editor
|
||||
std::vector<hard_split> hard_splits;
|
||||
// derived: the line laid between its nodes
|
||||
solved_line solved;
|
||||
|
||||
|
||||
@@ -344,6 +344,9 @@ std::string write(document const &Project)
|
||||
put(std::format("vertex {} at {} {} radius {} in {} out {} cant {}", layout::number(vertex.id), number(vertex.point.x), number(vertex.point.y), number(vertex.radius), number(vertex.transition_in), number(vertex.transition_out), number(vertex.cant)));
|
||||
for (auto const &grade : line.shape.grades)
|
||||
put(std::format("grade {} {} {}", number(grade.chainage), number(grade.elevation), number(grade.vertical_radius)));
|
||||
for (auto const &split : line.hard_splits)
|
||||
put(std::format("old {} {} reversed {} continued {} surface {} attributes {}", number(split.chainage), word(split.track.name), split.track.reversed ? 1 : 0, split.track.continued ? 1 : 0,
|
||||
word(split.track.surface), word(split.track.attributes)));
|
||||
put("end");
|
||||
}
|
||||
put("turnouts");
|
||||
@@ -585,6 +588,22 @@ read_result read(std::string_view const Text)
|
||||
words.finish();
|
||||
line->shape.grades.push_back(grade);
|
||||
}
|
||||
else if (keyword == "old")
|
||||
{
|
||||
layout::hard_split split;
|
||||
split.chainage = words.real("the chainage");
|
||||
split.track.name = unword(words.next("the name"));
|
||||
words.expect("reversed");
|
||||
split.track.reversed = words.choice("reversed", std::array<std::string_view, 2>{"0", "1"}) == 1;
|
||||
words.expect("continued");
|
||||
split.track.continued = words.choice("continued", std::array<std::string_view, 2>{"0", "1"}) == 1;
|
||||
words.expect("surface");
|
||||
split.track.surface = unword(words.next("the surface"));
|
||||
words.expect("attributes");
|
||||
split.track.attributes = unword(words.next("the attributes"));
|
||||
words.finish();
|
||||
line->hard_splits.push_back(std::move(split));
|
||||
}
|
||||
else if (keyword == "end")
|
||||
{
|
||||
words.finish();
|
||||
|
||||
@@ -35,6 +35,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
// 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>
|
||||
// old <chainage> <name> reversed <0|1> continued <0|1> surface <words> attributes <words> an old track the line was taken over from
|
||||
// (E6): where its stretch begins, its name, whether it ran against the line, whether it's
|
||||
// a part a split cut off, the words of its entry before the path and after it
|
||||
// end
|
||||
// turnouts
|
||||
// turnout <id> type <name> hand <1|-1> direction <1|-1> start <node> main <line> <node> diverging <line> <node> chainage <m>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "layout_fixture.h"
|
||||
#include "track_text.h"
|
||||
#include "editor/layout/layoutGenerator.hpp"
|
||||
#include "editor/project/projectFile.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
@@ -302,16 +303,48 @@ TEST_CASE("layout generator: the names come from the ids of the line and its ver
|
||||
CHECK(layout::generate(model.state(), id).text() == after.text());
|
||||
}
|
||||
|
||||
TEST_CASE("layout generator: the joints of old tracks as hard points of the pieces are stage E6, a line given them isn't made") {
|
||||
TEST_CASE("layout generator: the joints of old tracks as hard points of the pieces, their names, attributes and the way they ran kept") {
|
||||
auto const model{laid(three_curves())};
|
||||
auto const id{model.state().lines().begin()->first};
|
||||
layout::generator_options options;
|
||||
options.hard_splits[id] = {{350.0, "old_track"}};
|
||||
auto const made{layout::generate(model.state(), id, options)};
|
||||
CHECK(made.pieces.empty());
|
||||
REQUIRE(made.errors.size() == 1);
|
||||
CHECK(made.errors.front().find("E6") != std::string::npos);
|
||||
std::vector<std::string> errors;
|
||||
CHECK(layout::generate_all(model.state(), {}, errors).find("endtrack") != std::string::npos);
|
||||
CHECK(errors.empty());
|
||||
auto network{model.state()};
|
||||
auto &line{const_cast<layout::line &>(*network.find(id))};
|
||||
auto const length{line.solved.length};
|
||||
// three old tracks: one of a name with its events and circuit, one of none, one of a name which ran against the line
|
||||
layout::old_track first{"tor_a", "1.435 0.25 25.0 20 0 flat vis rail 4 bed 0.2 0.5 1.1", "velocity 60 event1 ev_a isolated obw_a", false, false};
|
||||
layout::old_track second{"", "", "velocity 70 event2 ev_b", false, false};
|
||||
layout::old_track third{"tor_c", "", "velocity 80 event1 ev_c", true, false};
|
||||
line.hard_splits = {{0.0, first}, {350.0, second}, {length - 100.0, third}};
|
||||
auto const made{layout::generate(network, id)};
|
||||
REQUIRE(made.errors.empty());
|
||||
// the pieces end at the joints
|
||||
auto const ends_at = [&](double const Chainage) { return std::ranges::any_of(made.pieces, [&](layout::generated_piece const &Piece) { return std::abs(Piece.to - Chainage) < 1e-9; }); };
|
||||
CHECK(ends_at(350.0));
|
||||
CHECK(ends_at(length - 100.0));
|
||||
std::map<std::string, std::string> texts;
|
||||
for (auto const &piece : made.pieces) {
|
||||
CHECK(texts.emplace(piece.name, piece.text).second);
|
||||
}
|
||||
// the first old track: its name on its first piece with all of its attributes, the others numbered on without its events
|
||||
REQUIRE(texts.contains("tor_a"));
|
||||
CHECK(texts["tor_a"].find("1.435 0.25 25.0 20 0 flat vis rail 4 bed 0.2 0.5 1.1") != std::string::npos);
|
||||
CHECK(texts["tor_a"].ends_with(" velocity 60 event1 ev_a isolated obw_a endtrack\n"));
|
||||
for (auto const &[name, text] : texts) {
|
||||
if (name.starts_with("tor_a_")) {
|
||||
CHECK(text.ends_with(" velocity 60 isolated obw_a endtrack\n"));
|
||||
}
|
||||
}
|
||||
// of no name: named by the generator, its events on the first piece only
|
||||
auto const events_b{std::ranges::count_if(texts, [](auto const &Each) { return Each.second.find("event2 ev_b") != std::string::npos; })};
|
||||
CHECK(events_b == 1);
|
||||
// the last one ran against the line: its piece written from the end of the line, the named one where it started
|
||||
REQUIRE(texts.contains("tor_c"));
|
||||
auto const named_c{std::ranges::find_if(made.pieces, [](layout::generated_piece const &Piece) { return Piece.name == "tor_c"; })};
|
||||
CHECK(std::abs(named_c->to - length) < 1e-9);
|
||||
CHECK(named_c->path.points[segment_data::point::start] == network.find(line.end)->position);
|
||||
// written and read back as the line has them
|
||||
project::document project;
|
||||
project.network = network;
|
||||
auto const read{project::read(project::write(project))};
|
||||
REQUIRE(read.project.has_value());
|
||||
CHECK(read.project->network.find(id)->hard_splits == line.hard_splits);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user