From 6aebbdeb5cb22884dee8883595adc9e024ce2725 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 3 Apr 2018 20:11:33 -0400 Subject: fix duplicate stitch filter --- inkstitch/stitch_plan/stitch_plan.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/inkstitch/stitch_plan/stitch_plan.py b/inkstitch/stitch_plan/stitch_plan.py index 3a7b8f18..3a95942c 100644 --- a/inkstitch/stitch_plan/stitch_plan.py +++ b/inkstitch/stitch_plan/stitch_plan.py @@ -36,6 +36,7 @@ def patches_to_stitch_plan(patches, collapse_len=3.0 * PIXELS_PER_MM): if color_block.last_stitch: if (patch.stitches[0] - color_block.last_stitch).length() > collapse_len: color_block.add_stitch(patch.stitches[0].x, patch.stitches[0].y, jump=True) + else: # add a color change color_block.add_stitch(color_block.last_stitch.x, color_block.last_stitch.y, stop=True) @@ -159,10 +160,14 @@ class ColorBlock(object): stitches = [self.stitches[0]] for stitch in self.stitches[1:]: - l = (stitch - stitches[-1]).length() - if l <= 0.1: - # duplicate stitch, skip this one - continue + if stitches[-1].jump or stitch.stop or stitch.trim: + # Don't consider jumps, stops, or trims as candidates for filtering + pass + else: + l = (stitch - stitches[-1]).length() + if l <= 0.1: + # duplicate stitch, skip this one + continue stitches.append(stitch) -- cgit v1.2.3