diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-03 20:11:33 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-03 20:11:33 -0400 |
| commit | 6aebbdeb5cb22884dee8883595adc9e024ce2725 (patch) | |
| tree | 98d470e5f623ca1fd2e934c2cd65c3df9b11ba9b | |
| parent | 76f7bcd92a383da451f76de296056221d25db315 (diff) | |
fix duplicate stitch filter
| -rw-r--r-- | inkstitch/stitch_plan/stitch_plan.py | 13 |
1 files 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) |
