From aa115294850753eae6eb8857193550292f4c41f9 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 3 May 2025 13:11:38 +0200 Subject: legacy fill: do not ignore end_row_spacing when grouping sections (#3703) --- lib/stitches/fill.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/stitches/fill.py') diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 8d592c54..e05ee8c1 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -17,7 +17,7 @@ from .running_stitch import split_segment_random_phase def legacy_fill(shape, angle, row_spacing, end_row_spacing, max_stitch_length, flip, reverse, staggers, skip_last): rows_of_segments = intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing, flip) - groups_of_segments = pull_runs(rows_of_segments, shape, row_spacing) + groups_of_segments = pull_runs(rows_of_segments, shape, row_spacing, end_row_spacing) stitches = [section_to_stitches(group, angle, row_spacing, max_stitch_length, staggers, skip_last) for group in groups_of_segments] @@ -210,11 +210,15 @@ def make_quadrilateral(segment1, segment2): return shapely.geometry.Polygon((segment1[0], segment1[1], segment2[1], segment2[0], segment1[0])) -def is_same_run(segment1, segment2, shape, row_spacing): +def is_same_run(segment1, segment2, shape, row_spacing, end_row_spacing): line1 = shapely.geometry.LineString(segment1) line2 = shapely.geometry.LineString(segment2) - if line1.distance(line2) > row_spacing * 1.1: + spacing = row_spacing + if end_row_spacing is not None: + spacing = max(spacing, end_row_spacing) + + if line1.distance(line2) > spacing * 1.1: return False quad = make_quadrilateral(segment1, segment2) @@ -224,7 +228,7 @@ def is_same_run(segment1, segment2, shape, row_spacing): return (intersection_area / quad_area) >= 0.9 -def pull_runs(rows, shape, row_spacing): +def pull_runs(rows, shape, row_spacing, end_row_spacing): # Given a list of rows, each containing a set of line segments, # break the area up into contiguous patches of line segments. # @@ -247,7 +251,7 @@ def pull_runs(rows, shape, row_spacing): first, rest = row[0], row[1:] # TODO: only accept actually adjacent rows here - if prev is not None and not is_same_run(prev, first, shape, row_spacing): + if prev is not None and not is_same_run(prev, first, shape, row_spacing, end_row_spacing): break run.append(first) -- cgit v1.2.3