17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 15:07:29 +01:00

Switches: enforced branch tangency, internal basket, Polish turnout templates

A switch (rozjazd) is a relation on a through niweleta, not a niweleta - the
through track is never split. It marks the theoretical point on the through
centreline; two tangent lines cross there (the through heading and that heading
turned by the crossing mark 1:n), and the internal diverging curve is fitted to
round the corner between them, reusing the same GapFitter the gap fits go
through. So the curve is free: a plain arc, or a łuk koszowy right inside the
switch. The theoretical tangent lengths and the curve length follow from it and
are read off, not set.

The branch niweleta's leaving straight is now locked to the frog: it starts at
the frog and runs along the frog heading every solve, only its length is the
user's. That enforces tangency no matter what is drawn, and because the first
straight is pinned tangent, any fit in the branch's first gap - including a
basket - meets the switch tangentially by construction.

solve_layout solves the niwelety and the switches together in two passes: solve,
read each frog, pin the branches, solve again. Switches serialize as an ejuncs /
ejunc section; older files without it still load.

Typical Polish turnouts (rozjazdy zwyczajne) are offered as templates that set
the crossing mark and radius together; the length each spans is computed from
them (arc = R*atan(1/n)) and shown, so how long the switch is is known.
This commit is contained in:
maj00r
2026-08-01 07:44:58 +02:00
committed by maj00r
parent d4b1d73338
commit d069743265
9 changed files with 3381 additions and 214 deletions

30
editor/turnouts.cpp Normal file
View File

@@ -0,0 +1,30 @@
/*
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/.
*/
#include "stdafx.h"
#include "editor/turnouts.h"
namespace editor
{
std::vector<turnout_preset> const &turnout_presets()
{
// the everyday PKP rozjazdy zwyczajne. the crossing mark and radius are the defining pair;
// the length the switch spans follows from them and is shown in the editor
static std::vector<turnout_preset> const presets{
{"Rz 1:9 R190", 9.0, 190.0},
{"Rz 1:9 R300", 9.0, 300.0},
{"Rz 1:12 R300", 12.0, 300.0},
{"Rz 1:14 R500", 14.0, 500.0},
{"Rz 1:18,5 R1200", 18.5, 1200.0},
{"Rz 1:26,5 R2500", 26.5, 2500.0}};
return presets;
}
} // namespace editor

33
editor/turnouts.h Normal file
View File

@@ -0,0 +1,33 @@
/*
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 <string>
#include <vector>
namespace editor
{
// a standard turnout template: its designation and the defining pair a catalogue entry is built on -
// the crossing mark 1:n (skos) and the radius of the diverging arc. the actual length the switch
// works out to is computed geometrically from these (arc = R * atan(1/n)), shown next to it; the
// exact catalogue length can be pinned later if the Id-1 tables call for a different figure
struct turnout_preset
{
std::string name;
double crossing_n;
double radius;
};
// typical Polish turnouts (rozjazdy zwyczajne). the (skos, R) pairs are the recognised standard;
// confirm against Id-1 before treating the derived length as the catalogue length
std::vector<turnout_preset> const &turnout_presets();
} // namespace editor