diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2022-05-18 16:02:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-18 16:02:07 +0200 |
| commit | bc4f3b4699555f48c571be9a22a6768635c38cd0 (patch) | |
| tree | 6a0bcd47bd19742857d0a7ed6bc034b22a4621a6 /lib/elements/stroke.py | |
| parent | bb0f3b8168ea2c889935b96b532188b79d7f952e (diff) | |
Auto route for running stitch (#1638)
* add auto route for running stitch
* introduce free motion commands
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/elements/stroke.py')
| -rw-r--r-- | lib/elements/stroke.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index 307c78b8..6f8d8bb1 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -87,7 +87,7 @@ class Stroke(EmbroideryElement): # manipulate invalid path if len(flattened[0]) == 1: - return [[[flattened[0][0][0], flattened[0][0][1]], [flattened[0][0][0]+1.0, flattened[0][0][1]]]] + return [[[flattened[0][0][0], flattened[0][0][1]], [flattened[0][0][0] + 1.0, flattened[0][0][1]]]] if self.manual_stitch_mode: return [self.strip_control_points(subpath) for subpath in path] @@ -97,12 +97,13 @@ class Stroke(EmbroideryElement): @property @cache def shape(self): + return self.as_multi_line_string().convex_hull + + @cache + def as_multi_line_string(self): line_strings = [shapely.geometry.LineString(path) for path in self.paths] - # 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 + return shapely.geometry.MultiLineString(line_strings) @property @param('manual_stitch', |
