From 28e9f96c603f7dfa108edbe21026fbeb8f2a5e44 Mon Sep 17 00:00:00 2001 From: Reenforcements Date: Sat, 17 Nov 2018 13:06:26 -0500 Subject: [PATCH] Updates --- .idea/workspace.xml | 127 +++++++++++++++++++++-------------------- LOG.md | 16 ++++++ Tests/debugPicture.png | Bin 0 -> 69 bytes src/PES.py | 95 ++++++++++++++++++++++++++++-- src/PES.pyc | Bin 1676 -> 3881 bytes src/main.py | 10 +++- 6 files changed, 178 insertions(+), 70 deletions(-) create mode 100644 Tests/debugPicture.png diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2ca5a6e..2196308 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,11 +3,9 @@ - - - + + - - + - + - + + - + @@ -51,18 +50,18 @@ - + - + - - + + @@ -70,26 +69,18 @@ - - - - - - - - - - - - - + - - + + - - + + + + + + @@ -98,8 +89,8 @@ - - + + @@ -126,6 +117,15 @@ + + + + + + + + + @@ -145,12 +145,12 @@ @@ -292,7 +292,7 @@ - + @@ -343,6 +343,18 @@ + + + + + + + + + + + + @@ -358,48 +370,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LOG.md b/LOG.md index e566668..06680de 100644 --- a/LOG.md +++ b/LOG.md @@ -1,3 +1,19 @@ +# 11/16 + +I haven't had the chance to work on this in a while. That's ok, this weekend is partially dedicated to coding this project (among other things.) + +I added a debug flag to generate an image based on the exported PES. This will be my first and most basic testing. I'm starting to really understand the format. + +Man, the PEC stitch coordinate system is weird. + +Okay, it's less weird after finding [this resource](https://edutechwiki.unige.ch/en/Embroidery_format_PEC) which explains it much better. Apparently stitches have a short and long form. I'm going to always use the long form to make things simpler. That way, I won't have to worry about making multiple jumps or not. + +I'd like to try to optimize the groups of stitches to minimize jumps and make the jumps optimal if possible. + +In version 1 of the .PES format, the PES and PEC sections contain the same data. + +I think I'm going to try totally skipping the PES section because it won't be needed for embroidering, which is the purpose of this software. + # 11/6 Trying to make sense of the "d" string in the path object. I need to be able to parse this myself I think to find intersections. diff --git a/Tests/debugPicture.png b/Tests/debugPicture.png new file mode 100644 index 0000000000000000000000000000000000000000..e740b466563c17ce669bf0d1ba89382ae8aff18d GIT binary patch literal 69 zcmeAS@N?(olHy`uVBq!ia0vp^%plCc1|-8Yw(bW~Jf1F&Ar-fh6BIzo)EOAR>^cOJ OX7F_Nb6Mw<&;$UJ*$v?U literal 0 HcmV?d00001 diff --git a/src/PES.py b/src/PES.py index 72b80bb..b2b4ded 100644 --- a/src/PES.py +++ b/src/PES.py @@ -1,17 +1,104 @@ -import struct +from struct import pack +def encodeU8(num): + return pack("h>^B%kbufPQl0N;0Z<4secDhMZbW^&H#nVECWcYfCXUkmep{QT#affOGf z|3AdYe!&#t&&a;Wz{r*n6MFKK$d)IeuY@n*j1n^v&PrI9utN4o{%f4$osZZg^}8i&zn+|EV;m+lP5 zu8MP`BuK+(^B!+ig~XiEfKN^tU}^g~XkRO}zx!V0Kdb-n;?;lWZQ4?J-_=2vc&$fS zypsf2(+_>Sijgg0iV*yUS&?Uf?W!pg_$aIKN1P#LFmjQNJkn;czL6$T$z{?0*XIBo z73%fkBzC>tRnUd$Ee4@RWv`d?2T`x*=2dc#h6np#EjO0>DK)L^u(P;p8AFw;c#g^; zah`|bRXjKa1Zc`G=bmH_aOrWQW;NlMXv%uUJklIvy+2v=DQPK@E3Pc#%ko90#A|9$F)Tj9P^iSr zn+p$~m!QoD#~M{k&Ci3U8-3r6cAgKO|DoqzOw4>t8;Q4=ysSK%uqF1>&DEEoK<8MM ziqT@%b+HS+Ig_thH92U|8jt$|6WU5%nNcnGd>P#khc2qM`bQ&4E}*@m5Li_KUC9No zo!!`HohN}_Q#N5bCReq2yP3KE$Tf#)oVaF^x@Nzi(`~+R-^t!ODU6E$@1iYsacv%M zJd8B@f^;z4N2ee}ox>m+vX`TI!A@SQ?E+_(?ZL9`+UuA~9H*AURb2Bab-9d5%(7YZ zIBFLfSFb>ohg6CYQ862(A5K&3Q5trc8yy5re|1?cgbXOF&5W+LY%7-K!7^wqZ#Z?< hv|OyOaQE{!-Ulq~8GjJey_%12tx;>-Y*ZUF{{X}uA~FB~ delta 419 zcmZusJxc>Y5S{(FO>QrngG5`2q&dXm`~xD0MGAx5RmMVss}R%#+>lC9Fs0q}*0J`F z_#5;mXsGdsZ)a!by|??a@#OB+r?d0*_meYNE=A`aMd%TD+5)Zs29!wfb?^%2 z0FMC20|8!xkHJT)5{($}7JO}0QmjyB38{^~Y4xY=3V2 zQx+26+(n05_O}fp<9neQB8EyMGL*)zAIYIeSfyw%IOcEhJbMJLfoO?Ta>V~Db@=W4 dujOkpCj9}8!{(YWI8G+0(w1f8hHRU*{sA%sJ*)r# diff --git a/src/main.py b/src/main.py index 7c8c299..cb0babe 100644 --- a/src/main.py +++ b/src/main.py @@ -3,6 +3,7 @@ import sys from svgFunctions import * import pyembroidery from utilities import * +from PES import * parser = argparse.ArgumentParser(description="Converts an SVG file into a PES embroidery file.") @@ -24,10 +25,13 @@ for shape in paths: stitchLines = makeStitchLines(shape) print(shape) +pes = PES() +pes.encode() + if args.debug: - pes = pyembroidery.read(args.outputFile) - if pes is not None: + loadedPES = pyembroidery.read(args.outputFile) + if loadedPES is not None: print("Generating debug image.") - pyembroidery.write_png(pes, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png")) + pyembroidery.write_png(loadedPES, replaceFilenameAndExtensionFromPath(args.inputFile, "debugPicture", "png")) else: print("Couldn't find output file.")