diff options
| author | Stefan Siegl <stesie@brokenpipe.de> | 2014-12-29 23:34:37 +0100 |
|---|---|---|
| committer | Stefan Siegl <stesie@brokenpipe.de> | 2014-12-29 23:34:37 +0100 |
| commit | 60199fffe0c2028794f0d969e71f6a55f457b782 (patch) | |
| tree | 36550be6933967b652177958b4a41ac94d2fafef | |
| parent | 35e5c09c99269615207242cf67409b8cc4c88d2a (diff) | |
Filter out duplicate stitches
| -rw-r--r-- | embroider.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/embroider.py b/embroider.py index d92f733a..ffeb99f1 100644 --- a/embroider.py +++ b/embroider.py @@ -335,13 +335,20 @@ class EmbroideryObject: for patch in self.patchList.patches: jumpStitch = True for stitch in patch.stitches: - if jumpStitch and lastStitch and lastColor == patch.color: - # consider collapsing jump stich, if it is pretty short - c = math.sqrt((stitch.x - lastStitch.x) ** 2 + (stitch.y + lastStitch.y) ** 2) - dbg.write("jump stitch length: %f (%d/%d -> %d/%d)\n" % (c, lastStitch.x, lastStitch.y, stitch.x, stitch.y)) - if c < collapse_len_px: - dbg.write("... collapsed\n") - jumpStitch = False + if lastStitch and lastColor == patch.color: + c = math.sqrt((stitch.x - lastStitch.x) ** 2 + (stitch.y + lastStitch.y) ** 2) + dbg.write("stitch length: %f (%d/%d -> %d/%d)\n" % (c, lastStitch.x, lastStitch.y, stitch.x, stitch.y)) + + if c == 0: + # filter out duplicate successive stitches + jumpStitch = False + continue + + if jumpStitch: + # consider collapsing jump stich, if it is pretty short + if c < collapse_len_px: + dbg.write("... collapsed\n") + jumpStitch = False dbg.write("stitch color %s\n" % patch.color) |
