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

feat(track): at a crossing at a wide angle the rails and guard rails ending against the side of another rail or guard rail are glued to it, their ends fitted to its profile height by height instead of square ends with caps and a gap of 5 mm, so the corners of the crossing are closed; the ends at the flangeways stay open for the flanges; a loft span can shift its first and last cross-section along the track by a fit given per height of the profile, and the rail profile gives the outlines of its field and gauge sides

This commit is contained in:
maj00r
2026-10-14 03:09:08 +02:00
parent 5544fbc43b
commit 2804978464
5 changed files with 105 additions and 15 deletions

View File

@@ -2635,6 +2635,36 @@ TTrack::rail_dimensions() const {
}
result.height = top - bottom;
result.crest = top;
std::size_t firsttop { count };
std::size_t lasttop { 0 };
for( std::size_t i = 0; i < count; ++i ) {
if( profile[ i ].position.y > top - 1e-4 ) {
firsttop = std::min( firsttop, i );
lasttop = std::max( lasttop, i );
}
}
std::vector<glm::dvec2> sides[ 2 ];
for( std::size_t i = 0; i < count; ++i ) {
auto const &point { profile[ i ].position };
if( i <= firsttop ) {
sides[ 0 ].emplace_back( point.y, point.x );
}
if( i >= lasttop ) {
sides[ 1 ].emplace_back( point.y, point.x );
}
}
for( auto &side : sides ) {
std::sort( side.begin(), side.end(), []( glm::dvec2 const &A, glm::dvec2 const &B ) { return A.x < B.x; } );
}
auto const mean = []( std::vector<glm::dvec2> const &Side ) {
auto sum { 0.0 };
for( auto const &knot : Side ) {
sum += knot.y;
}
return sum / std::max<std::size_t>( Side.size(), 1 ); };
auto const fieldfirst { mean( sides[ 0 ] ) > mean( sides[ 1 ] ) };
result.field = sides[ fieldfirst ? 0 : 1 ];
result.gauge = sides[ fieldfirst ? 1 : 0 ];
auto const middle { top - 0.5 * result.height };
auto webfrom { 1e9 };
auto webto { -1e9 };