17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-01 01:09:04 +01:00

fix(editor): the heights from point to point broke the grade only at the bends of straights which stay bends, a curve traced or bends clicked close along a curve going at one grade from one of its ends to the other, attached there; and two tracks laid no longer meet at two heights where a point was clicked within 5 m of their joint, each end of a piece not cut there taking the height of its own stretch, not of the one the middle of the piece lies on (steps of 0.6 m on a steep grade in abc). Unit tests of the heights from point to point

This commit is contained in:
maj00r
2026-10-24 22:28:43 +02:00
parent 4602f727bb
commit 133ba9cb45
6 changed files with 70 additions and 4 deletions

View File

@@ -427,10 +427,13 @@ void follow_points(std::vector<segment_data> &Pieces, std::vector<glm::dvec3> co
knots.push_back(total);
heights.push_back(Ends.height1);
auto const last{knots.size() - 1};
// the height at the chainage on the stretch Middle is on, an end of it taken at a knot
// the height at the chainage on its stretch; at a knot itself on the one Middle is on, for the grade of the piece there. A piece
// not cut at a knot too near its end lies on two stretches, each of its ends on its own
auto const at = [&](double const Chainage, double const Middle, double &Grade) {
std::size_t stretch{0};
while (stretch + 1 < last && Middle > knots[stretch + 1])
while (stretch + 1 < last && Chainage > knots[stretch + 1] + 1e-6)
++stretch;
if (stretch + 1 < last && std::abs(Chainage - knots[stretch + 1]) <= 1e-6 && Middle > knots[stretch + 1])
++stretch;
auto const span{knots[stretch + 1] - knots[stretch]};
auto const even{(heights[stretch + 1] - heights[stretch]) / span};