From bec33656ece737e134ca4b7ec2dc9a7dc9c71fd1 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 4 Jul 2019 17:20:31 -0400 Subject: add trim commands in import and stitch plan --- lib/elements/stroke.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/elements/stroke.py') diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index 3ae2b143..e0a0aacc 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -1,11 +1,13 @@ import sys + import shapely.geometry -from .element import param, EmbroideryElement, Patch from ..i18n import _ -from ..utils import cache, Point from ..stitches import running_stitch, bean_stitch from ..svg import parse_length_with_units +from ..utils import cache, Point +from .element import param, EmbroideryElement, Patch + warned_about_legacy_running_stitch = False @@ -85,7 +87,11 @@ class Stroke(EmbroideryElement): @cache def shape(self): line_strings = [shapely.geometry.LineString(path) for path in self.paths] - return shapely.geometry.MultiLineString(line_strings) + + # Using convex_hull here is an important optimization. Otherwise + # complex paths cause operations on the shape to take a long time. + # This especially happens when importing machine embroidery files. + return shapely.geometry.MultiLineString(line_strings).convex_hull @property @param('manual_stitch', -- cgit v1.2.3