From a180cd7b16cba2f6c5154e8ba4b9ca9f85e3d1dd Mon Sep 17 00:00:00 2001 From: Lex Neva <github@lexneva.name> Date: Mon, 7 Nov 2016 20:55:12 -0500 Subject: [PATCH] don't do auto-fill for regions with holes --- embroider.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/embroider.py b/embroider.py index 706cc774e..f5411818e 100644 --- a/embroider.py +++ b/embroider.py @@ -501,6 +501,10 @@ class AutoFill(Fill): def fill_underlay_max_stitch_length(self): return self.get_float_param("fill_underlay_max_stitch_length_mm" or self.max_stitch_length) + def validate(self): + if len(self.shape.boundary) > 1: + self.fatal("auto-fill: object %s cannot be auto-filled because it has one or more holes. Please disable auto-fill for this object or break it into separate objects without holes." % self.node.get('id')) + def is_same_run(self, segment1, segment2): if shgeo.Point(segment1[0]).distance(shgeo.Point(segment2[0])) > self.max_stitch_length: return False @@ -540,7 +544,7 @@ class AutoFill(Fill): distance = self.perimeter_distance(p1, p2) stitches = abs(int(distance / self.running_stitch_length)) - direction = distance / abs(distance) + direction = math.copysign(1.0, distance) stitch = self.running_stitch_length * direction for i in xrange(stitches): @@ -592,6 +596,7 @@ class AutoFill(Fill): def to_patches(self, last_patch): print >> dbg, "autofill" + self.validate() patches = []