Fix uneven corner rounding in multiline infill (#15352)

* Skip straight-run splits in corner smoothing

Teach `CornerSmoother` to treat vertices that only continue a straight segment as part of the same leg instead of rounding them as corners. The smoother now keeps a three-point window so it can emit a corner only once both adjoining legs are known, which avoids unnecessary corner processing while preserving real turns such as hairpins.

* Add regression test for split-leg smoothing

Adds a FillCornerSmoothing regression test covering polylines with an extra collinear vertex in a straight run. The test ensures corner smoothing treats split and unsplit geometry identically, preventing inconsistent rounding radii in triangular/grid infill paths.
This commit is contained in:
Ian Bassi
2026-08-25 12:46:34 -03:00
committed by GitHub
parent 265ae16160
commit a5223279ac
3 changed files with 78 additions and 18 deletions

View File

@@ -171,3 +171,24 @@ TEST_CASE("Corner smoothing keeps the ends of a path that returns to its start",
REQUIRE(retrace.front() == sharp.front());
REQUIRE(retrace.back() == sharp.back());
}
TEST_CASE("Corner smoothing ignores vertices splitting a straight leg", "[FillCornerSmoothing][Regression]")
{
// The triangular and grid infills emit a vertex halfway along the straight run joining two of
// their corners. Measuring the legs up to that vertex instead of up to the next corner let the
// rounding reach only half as far there as it did into the very same run elsewhere in the
// pattern, so geometrically identical corners came out rounded to different radii.
const Polyline plain{ Point::new_scale(0., 20.), Point::new_scale(10., 0.),
Point::new_scale(20., 0.), Point::new_scale(30., 20.) };
Polyline split = plain;
split.points.insert(split.points.begin() + 2, Point::new_scale(15., 0.));
Polyline smooth_plain = plain;
smooth_polyline_corners(smooth_plain, 1., tolerance);
Polyline smooth_split = split;
smooth_polyline_corners(smooth_split, 1., tolerance);
REQUIRE(smooth_split.points == smooth_plain.points);
// Both corners reach the middle of the 10mm run they share, which the extra vertex sat on.
REQUIRE(contains(smooth_plain, Point::new_scale(15., 0.)));
}