17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 22:49:16 +01:00
Files
maszyna/maj0sted/include/maj0sted/editor/ribbon.hpp
maj00r 707b4de2f4 Editor checkpoint: turnout domain service, web->editor rename, Id-1 templates
Checkpoint of the editor branch so work isn't carried loose across a branch
switch. Builds.

- maj0sted turnout geometry moved into the domain: domain::lay_turnout lays the
  diverging path (pre-blade lead, blade at beta, arc of alfa-beta, frog rail) and
  solve_junction is a thin adapter onto it.
- the maj0sted web/ tree renamed to editor/ (namespace and paths) - there is no
  WASM here, it's plain native C++ the editor calls.
- click places the switch at its start (początek rozjazdu); the branch's leaving
  straight is locked tangent to the frog; switches can be slid along the through
  track and flipped L/P.
- Polish turnout templates carry catalogue length (Id-1-consistent lengths), plus
  blade-angle and pre-blade fields (left 0 until the catalogue figures are in).
- TURNOUT_SPEC.md: the Bezier-based runtime/model contract.
- also folds in other pending branch changes (scenery, tests) to leave a clean tree.
2026-08-27 19:36:55 +02:00

33 lines
1.2 KiB
C++

#pragma once
#include <vector>
#include "maj0sted/editor/solve.hpp" // PlanPoint, PlanPolyline
namespace maj0sted::editor {
/// One element of an alignment "ribbon" (element chain), defined intrinsically.
struct RibbonElement {
int kind{0}; ///< 0 = line, 1 = arc, 2 = spiral (clothoid)
double length{0.0}; ///< line / spiral length (arc length is derived)
double radius{0.0}; ///< arc radius; spiral end radius (0 = straight / infinite)
double angle{0.0}; ///< arc central angle (radians)
double radius_start{0.0}; ///< spiral start radius (0 = infinite)
int dir{1}; ///< +1 left, -1 right (arc / spiral)
};
/// A whole alignment defined as a start pose plus an ordered element chain,
/// laid out head-to-tail. Handles any arc angle (including 180°+, loops) because
/// nothing depends on tangent intersection.
struct RibbonRequest {
double x0{0.0};
double y0{0.0};
double az0{0.0}; ///< start azimuth (radians, clockwise from north)
std::vector<RibbonElement> elements;
};
/// Lays the ribbon out and returns one polyline per element, ready to draw.
[[nodiscard]] std::vector<PlanPolyline> solve_ribbon(const RibbonRequest& request);
} // namespace maj0sted::editor