From 70554cc40efaa18f04ba900c9a2fb9d227771cec Mon Sep 17 00:00:00 2001 From: maj00r Date: Sat, 24 Oct 2026 21:12:40 +0200 Subject: [PATCH] fix(editor): a stretch traced is two curves only where both turn and fit between the straights at radii short of the ends of the ones tried, not a long one with a kink; the line of a stretch sampled every 4 m at most while it's fitted, the fit some times quicker --- editor/editorAlignment.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/editorAlignment.cpp b/editor/editorAlignment.cpp index 2907d3af..bbbe3ab3 100644 --- a/editor/editorAlignment.cpp +++ b/editor/editorAlignment.cpp @@ -2987,7 +2987,14 @@ trace_stretch fit_trace_stretch(design const &Base, std::vector cons { for (auto &curve : two.vertices) plain_curve(curve, std::max(kTraceRadiusMin, std::round(curve.radius)), std::round(curve.transition_in), speed, two.norms); - take(stretch_of(two, Points)); + // none where a curve ran to the end of the radii tried, turns hardly at all, or doesn't fit between the straights: the + // points made the fit find two curves where they show one + auto const laid{compute(two)}; + auto const sound{laid.valid && laid.radius_warnings.empty() && laid.curves.size() == 2 && std::all_of(laid.curves.begin(), laid.curves.end(), [](curve_report const &Curve) { + return Curve.radius > 1.05 * kTraceRadiusMin && Curve.radius < 0.95 * kTraceRadiusMax && Curve.deflection > 0.25 * kPi / 180.0; + })}; + if (sound) + take(stretch_of(two, Points)); } } return chosen;