17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 16:09:19 +02:00

Editor: rebuild the plan library around a solved document, and bend turnouts onto curves

The library was a heap of half-built services - fitting, parallelism, niwelety,
an SVG writer - that never met each other. In their place is one authored
Document and one solver that lays it whole: tracks as element chains, turnouts
placed on them, and a Solution that is rebuilt from scratch every time and never
fed back into the document. What cannot be laid comes back as a diagnostic with
the number in it rather than as silence or a fitted-away error.

Turnouts are dimensioned the way the drawings dimension them. The blade follows
Koc's rys. 5.9 - the curve is theoretically tangent to the opornica at PR, the
blade starts at a with a planed nose of d, and A is where the rail stands u
thick - and a + d derived that way lands on his tablica 5.1. Bending follows
5.3.6: it rotates the triangle OBC about the centre of the turnout, so the
tangent t and the crossing angle stand and both radii follow from them. That is
Koc's (5.7) and (5.8) without coding either, and it puts a symmetrically bent
Rz 49E1-190-1:9 on the catalogue's Rlus 49E1-380,292-1:9. A rozjazd standing on
a curve is bent onto it; one on a track drawn straight can carry a bend of its
own. The szyny laczace take up the difference, because the switch and the frog
are only bent, not re-cut.

The plan panel draws all of it: the catalogue drawing of a type with its
construction points, the theoretical arc dashed where no rail runs, and the
blade nose as the straight it is cut as. Dragging a straight now stops where it
would pull the track out from under a turnout.

File format goes to m0s 6. Versions 3 to 5 still open.
This commit is contained in:
maj00r
2026-08-29 19:32:46 +02:00
parent 8cd42980e6
commit 2376e4867b
97 changed files with 8608 additions and 9792 deletions

View File

@@ -10,27 +10,74 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "editor/turnouts.h"
#include "maj0sted/domain/geometry/turnout.hpp"
#include <cmath>
namespace editor
{
namespace
{
// the blade ends where the gap to the stock rail takes the przekladka in its heel.
// this is what fixes the length of a curved blade, so it is said once here.
// TODO: dlugosci iglic z tablic Id-1, gdy beda pod reka
double const heel_offset{0.136}; // metres
// 49E1 railhead. the blade is planed from its tip until it is this wide
double const railtop_width{0.070};
// a turnout with an iglica lukowa styczna do opornicy o scietym ostrzu (Koc, rys. 5.9).
// the curve is theoretically tangent to the opornica at PR, but the blade cannot begin
// there - it begins where there is metal enough, at the ostrze, and its planed nose (d)
// runs on to the point where the rail is u thick. what lies between PR and the ostrze is
// the odcinek przediglicowy: the curve is already there, the vehicle is still on the
// through track. Koc's tablica 5.1 gives a, d and u per type, and they obey
// a + d = the run to a gap of u, taken on the blade's curve R + s/2
// so a is derived from u and d here rather than copied. The drawing dimensions it on the
// rail and a piece length is on the axis, so what goes in is the run scaled by R/(R+s/2);
// against the table itself that is a tenth of a millimetre at 1200-1:18,5, six at 190-1:9.
//
// b is the rear tangent from the drawing: a rozjazd podstawowy (krzyzownica lukowa) has
// b = R*tg(alfa/2) and no straight at all, while a straight crossing carries the arc out
// on a prosta krzyzownicowa of b - R*tg(alfa/2). Passing 0 asks for the podstawowy.
turnout_preset curved_tangent(std::string name, double crossing_n, double radius, double tip_thickness, double nose, double back_tangent = 0.0)
{
auto const alfa{std::atan(1.0 / crossing_n)};
auto const tangent{radius * std::tan(0.5 * alfa)};
auto const b{back_tangent > 0.0 ? back_tangent : tangent};
auto const lead{maj0sted::domain::blade_run_to_offset(radius, 0.0, tip_thickness) - nose};
auto const blade{maj0sted::domain::blade_run_to_offset(radius, 0.0, heel_offset) - lead};
turnout_preset preset{std::move(name), crossing_n, tangent + b, tip_thickness, nose, railtop_width, {}};
preset.pieces.push_back({0, lead, radius, radius, 0.0});
preset.pieces.push_back({1, blade, radius, radius, 0.0});
preset.pieces.push_back({2, radius * alfa - lead - blade, radius, radius, 0.0});
if (b - tangent > 1e-6)
{
preset.pieces.push_back({3, b - tangent, 0.0, 0.0, 0.0});
}
return preset;
}
} // namespace
std::vector<turnout_preset> const &turnout_presets()
{
// the standard PKP rozjazdy zwyczajne (49E1 / 60E1). crossing mark, radius and catalogue length
// (PR→KR along the through track). the crossing angles check out as atan(1/n); the lengths follow
// the type tables (metres). the diverging leaves not tangent but at the blade angle (beta) after a
// straight pre-blade lead, then arcs by (alfa - beta) to the frog.
//
// blade_angle, pre_blade and blade_length are NOT yet from Id-1 - left at 0, which lays a tangent
// arc straight from PR. Fill them per type when the catalogue figures are in; the geometry
// (domain::lay_turnout) already lays the pre-blade lead, the blade break and the shortened arc.
// the standard PKP rozjazdy zwyczajne. u and d come from Koc, tablica 5.1 (iglice
// styczne do opornicy o scietym ostrzu); the rear tangents from the catalogue drawings:
// rys. 5.13 gives Rz 49E1-190-1:9 as 27138 = 10523 + 16615 (krzyzownica prosta) and
// rys. 5.15 gives Rz 49E1-300-1:9 as 33230 = 16615 + 16615 (lukowa, rozjazd podstawowy).
// krzyzownice proste sa w 49E1-190-1:9 i 49E1-500-1:14, lukowe w 300-1:9, 500-1:12 i
// 1200-1:18,5. TODO: 1:7,5 R190 i 1:14 R500 czekaja na wlasne u/d i styczne z Id-1
static std::vector<turnout_preset> const presets{
{"Rz 1:7,5 R190", 7.5, 190.0, 25.222, 0.0, 0.0, 0.0},
{"Rz 1:9 R190", 9.0, 190.0, 27.138, 0.0, 0.0, 0.0},
{"Rz 1:9 R300", 9.0, 300.0, 33.230, 0.0, 0.0, 0.0},
{"Rz 1:12 R500", 12.0, 500.0, 41.594, 0.0, 0.0, 0.0},
{"Rz 1:14 R500", 14.0, 500.0, 42.371, 0.0, 0.0, 0.0},
{"Rz 1:14 R760", 14.0, 760.0, 54.216, 0.0, 0.0, 0.0},
{"Rz 1:18,5 R1200", 18.5, 1200.0, 64.818, 0.0, 0.0, 0.0}};
curved_tangent("Rz 1:7,5 R190", 7.5, 190.0, 0.0049, 0.1250),
curved_tangent("Rz 1:9 R190", 9.0, 190.0, 0.0049, 0.1250, 16.615),
curved_tangent("Rz 1:9 R300", 9.0, 300.0, 0.0044, 0.1250),
curved_tangent("Rz 1:12 R500", 12.0, 500.0, 0.0053, 0.1250),
curved_tangent("Rz 1:14 R500", 14.0, 500.0, 0.0053, 0.1250, 24.544),
curved_tangent("Rz 1:14 R760", 14.0, 760.0, 0.0050, 0.1250),
curved_tangent("Rz 1:18,5 R1200", 18.5, 1200.0, 0.0050, 0.1304)};
return presets;
}