mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 09:49:19 +02:00
feat(editor): the horizontal alignment designed in the route design kept in the scenery as //$h lines: its vertices and the elements they make (straight, transition, arc, with the radius at the start and the end and the cant), so the paths laid by it are known again without guessing from their curvature; a curve read from the paths takes the radius, the transitions, the cant and the compound arcs of the kept design when its paths lie on it within 2 cm, the other way round too; the whole line design taken back when the fragment has its ends; a curve redesigned alone taken into the line it belongs to; km of the start kept with the design and carried on to the vertical profile of the same paths; paths which no longer follow the kept design shown in the route window, with the kept design to take or to forget; self-test commands for the route design and the kept alignments; Polish translation
This commit is contained in:
91
editor/editorAlignmentStore.hpp
Normal file
91
editor/editorAlignmentStore.hpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
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 <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "editor/editorAlignment.hpp"
|
||||
#include "scene/scenelayers.h"
|
||||
|
||||
class TTrack;
|
||||
|
||||
// horizontal alignments designed in the track editor, kept in the scenery files as "//$h" comment lines: the design (its
|
||||
// vertices) and the elements it makes, so the tracks laid by it are known for straights, transition curves and arcs
|
||||
namespace alignment_store
|
||||
{
|
||||
|
||||
// an element as the file gives it: radii signed with the turn, 0 for no curvature
|
||||
struct stored_element
|
||||
{
|
||||
std::string kind; // straight, transition, arc
|
||||
int vertex{-1};
|
||||
double chainage{0.0};
|
||||
double length{0.0};
|
||||
double radius_start{0.0};
|
||||
double radius_end{0.0};
|
||||
double cant{0.0};
|
||||
};
|
||||
stored_element describe(alignment::element const &Element);
|
||||
|
||||
struct record
|
||||
{
|
||||
scene::layer_handle layer{null_handle};
|
||||
std::string source{"designed"};
|
||||
double origin{0.0}; // chainage of the start, m
|
||||
alignment::design design;
|
||||
alignment::result result; // made of the design
|
||||
std::vector<stored_element> elements; // as written in the file
|
||||
bool consistent{true}; // the design makes the elements written in the file
|
||||
glm::dvec2 low{0.0}, high{0.0};
|
||||
std::vector<glm::dvec2> samples;
|
||||
};
|
||||
|
||||
struct hit
|
||||
{
|
||||
int record{-1};
|
||||
int element{-1};
|
||||
double chainage{0.0}; // from the start of the record
|
||||
double offset{0.0}; // sideways from its line
|
||||
};
|
||||
|
||||
// the designed vertex a curve made of the tracks follows: its parameters in the direction of the tracks
|
||||
struct designed_vertex
|
||||
{
|
||||
int record{-1};
|
||||
int vertex{-1};
|
||||
alignment::vertex shape;
|
||||
bool reversed{false};
|
||||
};
|
||||
|
||||
double constexpr tolerance{0.02};
|
||||
|
||||
void reset();
|
||||
void load();
|
||||
std::vector<record> const &records();
|
||||
std::optional<hit> at(glm::dvec3 const &Point, double const Reach = tolerance);
|
||||
// the track lies along a stored alignment, its middle is the hit
|
||||
std::optional<hit> on_track(TTrack const &Track, double const Reach = tolerance);
|
||||
// the vertex the tracks follow, if they all lie along one stored alignment and the curve elements under them belong to one vertex
|
||||
std::optional<designed_vertex> vertex_of(std::vector<std::pair<TTrack *, bool>> const &Run);
|
||||
// stored alignment with these ends, either way
|
||||
int find(glm::dvec3 const &Start, glm::dvec3 const &End, bool &Reversed);
|
||||
// stored alignment near the tracks, whose line they no longer follow; Departure receives the largest distance
|
||||
int departed(std::vector<TTrack *> const &Tracks, double &Departure);
|
||||
// keeps the design in the file of the layer, in place of the one with the same ends
|
||||
int store(alignment::design const &Design, alignment::result const &Result, double const Origin, scene::layer_handle const Layer);
|
||||
void forget(int const Index);
|
||||
// km of the point on the stored alignments, if it lies on one
|
||||
std::optional<double> chainage_at(glm::dvec3 const &Point);
|
||||
|
||||
} // namespace alignment_store
|
||||
Reference in New Issue
Block a user