17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 13:19:20 +02:00
Files
maszyna/editor/turnouts.cpp
maj00r d069743265 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.
2026-08-27 19:36:55 +02:00

31 lines
809 B
C++

/*
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