diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-05-10 09:02:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-10 09:02:17 +0200 |
| commit | 9d5cc6013ef769718b47d64a558df7e4210505d1 (patch) | |
| tree | 2231a4c373042704e0684c39b253c93b147d31ef /lib | |
| parent | 97645751f67d2f76b1aadeb36152260a45c12e6a (diff) | |
circular fill bean: ignore travel stitches (#2281)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/stitches/circular_fill.py | 15 | ||||
| -rw-r--r-- | lib/stitches/running_stitch.py | 6 |
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/stitches/circular_fill.py b/lib/stitches/circular_fill.py index 233e326e..9a4d6fbc 100644 --- a/lib/stitches/circular_fill.py +++ b/lib/stitches/circular_fill.py @@ -66,7 +66,11 @@ def circular_fill(shape, segments = [] for line in intersection.geoms: if isinstance(line, shgeo.LineString): - segments.append(line.coords[:]) + # use running stitch here to adjust the stitch length + coords = running_stitch([Stitch(point[0], point[1]) for point in line.coords], + running_stitch_length, + running_stitch_tolerance) + segments.append([(point.x, point.y) for point in coords]) fill_stitch_graph = build_fill_stitch_graph(shape, segments, starting_point, ending_point) if not graph_is_valid(fill_stitch_graph, shape, running_stitch_length): @@ -75,15 +79,14 @@ def circular_fill(shape, travel_graph = build_travel_graph(fill_stitch_graph, shape, angle, underpath) path = find_stitch_path(fill_stitch_graph, travel_graph, starting_point, ending_point) result = path_to_stitches(path, travel_graph, fill_stitch_graph, running_stitch_length, running_stitch_tolerance, skip_last) - - # use running stitch to adjust the stitch length - result = running_stitch(result, running_stitch_length, running_stitch_tolerance) - return _apply_bean_stitch_and_repeats(result, repeats, bean_stitch_repeats) + result = _apply_bean_stitch_and_repeats(result, repeats, bean_stitch_repeats) + return result def _apply_bean_stitch_and_repeats(stitches, repeats, bean_stitch_repeats): if any(bean_stitch_repeats): - stitches = bean_stitch(stitches, bean_stitch_repeats) + # add bean stitches, but ignore travel stitches + stitches = bean_stitch(stitches, bean_stitch_repeats, ['auto_fill_travel']) if repeats: for i in range(1, repeats): diff --git a/lib/stitches/running_stitch.py b/lib/stitches/running_stitch.py index 18eeb3c9..50e3be5f 100644 --- a/lib/stitches/running_stitch.py +++ b/lib/stitches/running_stitch.py @@ -258,7 +258,7 @@ def running_stitch(points, stitch_length, tolerance): return stitches -def bean_stitch(stitches, repeats): +def bean_stitch(stitches, repeats, tags_to_ignore=None): """Generate bean stitch from a set of stitches. "Bean" stitch is made by backtracking each stitch to make it heavier. A @@ -284,6 +284,10 @@ def bean_stitch(stitches, repeats): repeat_list_pos = i % repeat_list_length new_stitches.append(stitch) + # ignore stitches with specified tags + if tags_to_ignore and set(tags_to_ignore).intersection(stitch.tags): + continue + for i in range(repeats[repeat_list_pos]): new_stitches.extend(copy(new_stitches[-2:])) |
