Embroidermodder / libembroidery

Library for reading/writing/manipulating machine and design embroidery files
https://www.libembroidery.org
zlib License
47 stars 14 forks source link

PES to SEW conversion not working #190

Open BartmanEH opened 2 years ago

BartmanEH commented 2 years ago

fresh build of libembroiderery on mac 12.1 but conversion from PES to SEW produces invalid results

robin-swift commented 2 years ago

Ok, can you show me the terminal output from the conversion?

Let's work this out.

BartmanEH commented 2 years ago
%./libembroidery/embroider test.pes test.sew                                                       
test.pes

maybe I'm missing -t sew?

robin-swift commented 2 years ago

No that should work. What's the file size of the output?

BartmanEH commented 2 years ago

22KB (input PES is 117KB)

robin-swift commented 2 years ago

Does the sew file not load at all? Or is it incomplete?

BartmanEH commented 2 years ago

using StitchBuddy, the PES previews fine but the SEW is blank. Trying to open it in StitchBuddy yields:

Screen Shot 2022-01-25 at 4 20 02 PM
robin-swift commented 2 years ago

Ah, that's the error message I need. Can you paste the output of:

% xxd test.sew | head

I.e. the first 256bytes in hex format.

BartmanEH commented 2 years ago
00000000: 6004 0000 0a00 0000 1d00 0000 2900 0000  `...........)...
00000010: 0100 0000 3a00 0000 1d00 0000 2900 0000  ....:.......)...
00000020: 0100 0000 4200 0000 1d00 0000 1e00 0000  ....B...........
00000030: 0100 0000 0c00 0000 1d00 0000 1e00 0000  ................
00000040: 0100 0000 4200 0000 1d00 0000 1e00 0000  ....B...........
00000050: 0100 0000 0100 0000 0100 0000 3200 0000  ............2...
00000060: 0100 0000 0100 0000 0100 0000 3200 0000  ............2...
00000070: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
00000080: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
00000090: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
BartmanEH commented 2 years ago

I tried DST conversion but it doesn't work either and I get a lot of screen output:

 libembroidery % ./embroider test.pes test.dst
test.pes
0 90.933333 19.111111 909 191 909 191
ERROR: format-t01.c encode_record(), x is not in valid range [-121,121] , x = 909
1 79.566667 16.722222 -113 -24 796 167
2 68.200000 14.333333 -114 -24 682 143
3 56.833333 11.944444 -114 -24 568 119
4 45.466667 9.555556 -113 -23 455 96
5 34.100000 7.166667 -114 -24 341 72
6 22.733333 4.777778 -114 -24 227 48
7 11.366667 2.388889 -113 -24 114 24
8 102.300000 21.500000 909 191 1023 215
ERROR: format-t01.c encode_record(), x is not in valid range [-121,121] , x = 909

[truncated]

robin-swift commented 2 years ago

Yeah, that's big jumps not being split properly. I know about that bug.

If you hang on 5 minutes I may work out what this colour change bug is.

robin-swift commented 2 years ago

Can you paste the output of

% ./libembroidery/embroider test.pes test.csv
% head test.csv
BartmanEH commented 2 years ago
% head test.csv      
"#","Embroidermodder 2 CSV Embroidery File"
"#","http://embroidermodder.github.io"

"#","General Notes:"
"#","This file can be read by Excel or LibreOffice as CSV (Comma Separated Value) or with a text editor."
"#","Lines beginning with # are comments."
"#","Lines beginning with > are variables: [VAR_NAME], [VAR_VALUE]"
"#","Lines beginning with $ are threads: [THREAD_NUMBER], [RED], [GREEN], [BLUE], [DESCRIPTION], [CATALOG_NUMBER]"
"#","Lines beginning with * are stitch entries: [STITCH_TYPE], [X], [Y]"
robin-swift commented 2 years ago

So what I want to see is slightly below that:

% head -n40 test.csv
BartmanEH commented 2 years ago
% head -n40 test.csv
"#","Embroidermodder 2 CSV Embroidery File"
"#","http://embroidermodder.github.io"

"#","General Notes:"
"#","This file can be read by Excel or LibreOffice as CSV (Comma Separated Value) or with a text editor."
"#","Lines beginning with # are comments."
"#","Lines beginning with > are variables: [VAR_NAME], [VAR_VALUE]"
"#","Lines beginning with $ are threads: [THREAD_NUMBER], [RED], [GREEN], [BLUE], [DESCRIPTION], [CATALOG_NUMBER]"
"#","Lines beginning with * are stitch entries: [STITCH_TYPE], [X], [Y]"

"#","Stitch Entry Notes:"
"#","STITCH instructs the machine to move to the position [X][Y] and then make a stitch."
"#","JUMP instructs the machine to move to the position [X][Y] without making a stitch."
"#","TRIM instructs the machine to cut the thread before moving to the position [X][Y] without making a stitch."
"#","COLOR instructs the machine to stop temporarily so that the user can change to a different color thread before resuming."
"#","END instructs the machine that the design is completed and there are no further instructions."
"#","UNKNOWN encompasses instructions that may not be supported currently."
"#","[X] and [Y] are absolute coordinates in millimeters (mm)."

"#","[VAR_NAME]","[VAR_VALUE]"
">","STITCH_COUNT:","3896"
">","THREAD_COUNT:","251"
">","EXTENTS_LEFT:","-3499.600000"
">","EXTENTS_TOP:","-2996.000000"
">","EXTENTS_RIGHT:","3458.800000"
">","EXTENTS_BOTTOM:","4564.200000"
">","EXTENTS_WIDTH:","6958.400000"
">","EXTENTS_HEIGHT:","7560.200000"

"#","[THREAD_NUMBER]","[RED]","[GREEN]","[BLUE]","[DESCRIPTION]","[CATALOG_NUMBER]"
"$","1","32","100","120","f. Unimplemented for now.","an the header."
"$","2","58","32","101","mb-polyline.c embArray_create(), ","memory for heapPolylineObj
"
"$","3","0","0","0","Unknown",""
"$","4","58","32","37","d
Name  : %s

","on  : %s
Description: %s
Reade"
robin-swift commented 2 years ago

Oh dear, that's a new one. I've not cleared out the memory for the strings so it's got whatever rubbish is there.

I'm writing a patch that should help with this testing and fix some minor bugs, hang on.

robin-swift commented 2 years ago

Ok, git pull and rebuild with cmake --build ..

BartmanEH commented 2 years ago

oh man... I'm not a dev, I'm a hack... this is gonna go horribly wrong :-)

EDIT: how do I git pull for just libembroidery?

robin-swift commented 2 years ago

You've followed me to here I've not been confused by your replies at any point.

This is a good real world test of the software, so I'm enjoying it.

robin-swift commented 2 years ago

You do git pull from inside the code directory.

So from where your terminal appears to be:

cd libembroidery
git pull
BartmanEH commented 2 years ago
% ./libembroidery/embroider test.pes test.sew
test.pes
Debugging Information
number of colors = 251
number of stitches = 3896
Color: 0 1
Color: 1 1
Color: 2 1
Color: 3 1
Color: 4 1
Color: 5 1
Color: 6 1

[truncated]

same size SEW results file (22KB) and still 'blank' or invalid

robin-swift commented 2 years ago

Huh, now that's surprising.

How similar to your design is

number of colors = 251
number of stitches = 3896

I doubt it really is a 251 thread color pattern.

BartmanEH commented 2 years ago

lol, indeed not: 2 colors

robin-swift commented 2 years ago

and how many stitches?

BartmanEH commented 2 years ago
Screen Shot 2022-01-25 at 4 57 42 PM

According to StitchBuddy

robin-swift commented 2 years ago

That's useful. I'm thinking...

robin-swift commented 2 years ago

Ok, so can I see the same hexdump for your input?

xxd test.pes | head
BartmanEH commented 2 years ago
% xxd test.pes | head
00000000: 2350 4553 3030 3031 802f 0100 0100 0100  #PES0001./......
00000010: 0100 ffff 0000 0700 4345 6d62 4f6e 6500  ........CEmbOne.
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0080 3f00 0000 0000 0000 0000 0080 3f00  ..?...........?.
00000040: d80e 4480 eba5 4401 0000 0000 0059 038e  ..D...D......Y..
00000050: 0200 0000 0000 0000 0062 00ff ff00 0007  .........b......
00000060: 0043 5365 7753 6567 0100 1d00 0200 ac01  .CSewSeg........
00000070: b9fe 0400 51ff 0380 0000 1d00 872c 0400  ....Q........,..
00000080: 51ff 0000 52ff 0400 51ff 0000 52ff 0400  Q...R...Q...R...
00000090: 51ff 0000 52ff 0a00 5cff 1500 67ff 2300  Q...R...\...g.#.
robin-swift commented 2 years ago

Ok, so I think I can offer your workflow a solution quicker than fixing this. Then fix this at a later date.

Can you output from your design software in Tajima .dst? Then do the conversion to .sew.

BartmanEH commented 2 years ago

OK, I'll try that but it will take me some time to wrestle Inkstitch into submission, again. Thanks for your support. I'll post my results here hopefully later tonight.

robin-swift commented 2 years ago

I'll open an new issue... use #191

JoshVarga commented 2 years ago

Based on the output you provided, SEW is really not outputting correctly. those first two bytes couldn't possibly be that large. I made a change to output the header with the correct values. That should get this MUCH closer to working... Maybe give it another shot.

00000000: 6004 0000 0a00 0000 1d00 0000 2900 0000  `...........)...
00000010: 0100 0000 3a00 0000 1d00 0000 2900 0000  ....:.......)...
00000020: 0100 0000 4200 0000 1d00 0000 1e00 0000  ....B...........
00000030: 0100 0000 0c00 0000 1d00 0000 1e00 0000  ................
00000040: 0100 0000 4200 0000 1d00 0000 1e00 0000  ....B...........
00000050: 0100 0000 0100 0000 0100 0000 3200 0000  ............2...
00000060: 0100 0000 0100 0000 0100 0000 3200 0000  ............2...
00000070: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
00000080: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
00000090: 0100 0000 3200 0000 1d00 0000 3200 0000  ....2.......2...
BartmanEH commented 2 years ago

after a git pull and make:

% ./libembroidery/embroider test.pes test.sew
test.pes
Debugging Information
number of colors = 251
number of stitches = 3896

output is 21KB now but still not viable.

% xxd test.sew | head                        
00000000: fb00 0100 0100 0100 0100 0100 0100 0100  ................
00000010: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000020: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000030: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000040: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000050: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000060: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000070: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000080: 0100 0100 0100 0100 0100 0100 0100 0100  ................
00000090: 0100 0100 0100 0100 0100 0100 0100 0100  ................