summaryrefslogtreecommitdiff
path: root/lib/stitches/auto_fill.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-08-18 20:05:37 +0200
committerGitHub <noreply@github.com>2024-08-18 20:05:37 +0200
commit7cf952dce27173c918340a839694802f332ae26a (patch)
tree3f5ec23ba29bedc403c39bb035acefe73ecad6d3 /lib/stitches/auto_fill.py
parent8591f81ecbf82bcd3538d81cefb5a5b5d5080c5c (diff)
fill: ensure polygon in pull comp adjusted shape (#3143)
Diffstat (limited to 'lib/stitches/auto_fill.py')
-rw-r--r--lib/stitches/auto_fill.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index 4800c994..067b0bcf 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -21,7 +21,7 @@ from ..svg import PIXELS_PER_MM
from ..utils import cache
from ..utils.clamp_path import clamp_path_to_polygon
from ..utils.geometry import Point as InkstitchPoint
-from ..utils.geometry import (ensure_multi_line_string,
+from ..utils.geometry import (ensure_multi_line_string, ensure_polygon,
line_string_to_point_list, offset_points)
from ..utils.list import is_all_zeroes
from ..utils.prng import join_args
@@ -139,18 +139,13 @@ def adjust_shape_for_pull_compensation(shape, angle, row_spacing, pull_compensat
buffer_amount = row_spacing/2 + 0.01
buffered_lines = [line.buffer(buffer_amount) for line in lines]
- polygon = unary_union(buffered_lines)
+ polygon = ensure_polygon(unary_union(buffered_lines))
exterior = smooth_path(polygon.exterior.coords, 0.2)
min_hole_area = row_spacing ** 2
interiors = [smooth_path(interior.coords) for interior in polygon.interiors if shgeo.Polygon(interior).area > min_hole_area]
shape = make_valid(shgeo.Polygon(exterior, interiors))
- if shape.geom_type == 'MultiPolygon':
- # the shape is somehow messed up
- # rescue it by just using the first geometry
- shape = list(shape.geoms)
- shape.sort(key=lambda polygon: polygon.area, reverse=True)
- shape = shape[0]
+ shape = ensure_polygon(shape)
return shape