-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
embroidery.h
1205 lines (1069 loc) · 38.4 KB
/
embroidery.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* LIBEMBROIDERY HEADER
* This file is part of libembroidery.
*
* Copyright 2018-2024 The Embroidermodder Team
* Licensed under the terms of the zlib license.
*
* -----------------------------------------------------------------------------
*
* Note that all new defines start with "EMB_", all functions with "emb" and all
* typedefs with "Emb" to protect against namespace pollution. (INCOMPLETE)
*/
#ifndef EMB_LIBRARY_HEADER__
#define EMB_LIBRARY_HEADER__
#ifdef __cplusplus
extern "C" {
#endif
#define EMB_LIB_VERSION_MAJOR 1
#define EMB_LIB_VERSION_MINOR 0
#define EMB_LIB_VERSION_PATCH 0
#define EMB_LIB_VERSION_TAG "alpha"
/* MACROS
*****************************************************************************
*
* Machine codes for stitch flags.
* These all represent distinct bits as some of them can be combined on some
* machines.
*
* Missing change color?
*
* Stitch to (x, y). */
#define NORMAL 0x00
/* Move to (x, y). */
#define JUMP 0x01
/* Trim and move to (x, y). */
#define TRIM 0x02
/* Pause machine for a thread change. */
#define STOP 0x04
/* Add a sequin at the current co-ordinates. */
#define SEQUIN 0x08
/* end of program */
#define END 0x10
/* Format identifiers */
#define EMB_FORMAT_100 0
#define EMB_FORMAT_10O 1
#define EMB_FORMAT_ART 2
#define EMB_FORMAT_BMC 3
#define EMB_FORMAT_BRO 4
#define EMB_FORMAT_CND 5
#define EMB_FORMAT_COL 6
#define EMB_FORMAT_CSD 7
#define EMB_FORMAT_CSV 8
#define EMB_FORMAT_DAT 9
#define EMB_FORMAT_DEM 10
#define EMB_FORMAT_DSB 11
#define EMB_FORMAT_DST 12
#define EMB_FORMAT_DSZ 13
#define EMB_FORMAT_DXF 14
#define EMB_FORMAT_EDR 15
#define EMB_FORMAT_EMD 16
#define EMB_FORMAT_EXP 17
#define EMB_FORMAT_EXY 18
#define EMB_FORMAT_EYS 19
#define EMB_FORMAT_FXY 20
#define EMB_FORMAT_GC 21
#define EMB_FORMAT_GNC 22
#define EMB_FORMAT_GT 23
#define EMB_FORMAT_HUS 24
#define EMB_FORMAT_INB 25
#define EMB_FORMAT_INF 26
#define EMB_FORMAT_JEF 27
#define EMB_FORMAT_KSM 28
#define EMB_FORMAT_MAX 29
#define EMB_FORMAT_MIT 30
#define EMB_FORMAT_NEW 31
#define EMB_FORMAT_OFM 32
#define EMB_FORMAT_PCD 33
#define EMB_FORMAT_PCM 34
#define EMB_FORMAT_PCQ 35
#define EMB_FORMAT_PCS 36
#define EMB_FORMAT_PEC 37
#define EMB_FORMAT_PEL 38
#define EMB_FORMAT_PEM 39
#define EMB_FORMAT_PES 40
#define EMB_FORMAT_PHB 41
#define EMB_FORMAT_PHC 42
#define EMB_FORMAT_PLT 43
#define EMB_FORMAT_RGB 44
#define EMB_FORMAT_SEW 45
#define EMB_FORMAT_SHV 46
#define EMB_FORMAT_SST 47
#define EMB_FORMAT_STX 48
#define EMB_FORMAT_SVG 49
#define EMB_FORMAT_T01 50
#define EMB_FORMAT_T09 51
#define EMB_FORMAT_TAP 52
#define EMB_FORMAT_THR 53
#define EMB_FORMAT_TXT 54
#define EMB_FORMAT_U00 55
#define EMB_FORMAT_U01 56
#define EMB_FORMAT_VIP 57
#define EMB_FORMAT_VP3 58
#define EMB_FORMAT_XXX 59
#define EMB_FORMAT_ZSK 60
/* EmbGeometry types, should include all of the possible rendering types
* for EmbroiderModder and internal types for stitch processing (like
* fills).
*/
#define EMB_ARRAY 0
#define EMB_ARC 1
#define EMB_CIRCLE 2
#define EMB_DIM_DIAMETER 3
#define EMB_DIM_LEADER 4
#define EMB_ELLIPSE 5
#define EMB_FLAG 6
#define EMB_LINE 7
#define EMB_IMAGE 8
#define EMB_PATH 9
#define EMB_POINT 10
#define EMB_POLYGON 11
#define EMB_POLYLINE 12
#define EMB_RECT 13
#define EMB_SPLINE 14
#define EMB_STITCH 15
#define EMB_TEXT_SINGLE 16
#define EMB_TEXT_MULTI 17
#define EMB_VECTOR 18
#define EMB_THREAD 19
#define EMBFORMAT_UNSUPPORTED 0
#define EMBFORMAT_STITCHONLY 1
#define EMBFORMAT_OBJECTONLY 2
#define EMBFORMAT_STCHANDOBJ 3 /* binary operation: 1+2=3 */
#define numberOfFormats 61
#define CHUNK_SIZE 128
#define EMB_MAX_LAYERS 10
#define MAX_THREADS 256
#define MAX_STRING_LENGTH 200
#define EMBFORMAT_MAXEXT 3
/* maximum length of extension without dot */
#define EMBFORMAT_MAXDESC 50
/* the longest possible description string length */
#define MAX_STITCHES 1000000
/* Libembroidery's handling of integer types.
*/
#define EMB_BIG_ENDIAN 0
#define EMB_LITTLE_ENDIAN 1
/* Most machines are little endian (including the developer's), so default to
* that.
*/
#define ENDIAN_HOST EMB_LITTLE_ENDIAN
#define EMB_INT16_BIG 2
#define EMB_INT16_LITTLE 3
#define EMB_INT32_BIG 4
#define EMB_INT32_LITTLE 5
/* Identifiers for different PES versions. */
#define PES0001 0
#define PES0020 1
#define PES0022 2
#define PES0030 3
#define PES0040 4
#define PES0050 5
#define PES0055 6
#define PES0056 7
#define PES0060 8
#define PES0070 9
#define PES0080 10
#define PES0090 11
#define PES0100 12
#define N_PES_VERSIONS 13
/**
* Type of sector
* Compound File Sector (CFS)
*/
#define CompoundFileSector_MaxRegSector 0xFFFFFFFA
#define CompoundFileSector_DIFAT_Sector 0xFFFFFFFC
#define CompoundFileSector_FAT_Sector 0xFFFFFFFD
#define CompoundFileSector_EndOfChain 0xFFFFFFFE
#define CompoundFileSector_FreeSector 0xFFFFFFFF
/**
* Type of directory object
*/
#define ObjectTypeUnknown 0x00 /*!< Probably unallocated */
#define ObjectTypeStorage 0x01 /*!< a directory type object */
#define ObjectTypeStream 0x02 /*!< a file type object */
#define ObjectTypeRootEntry 0x05 /*!< the root entry */
/**
* Special values for Stream Identifiers
*/
#define CompoundFileStreamId_MaxRegularStreamId 0xFFFFFFFA /*!< All real stream Ids are less than this */
#define CompoundFileStreamId_NoStream 0xFFFFFFFF /*!< There is no valid stream Id */
#define ELEMENT_XML 0
#define ELEMENT_A 1
#define ELEMENT_ANIMATE 2
#define ELEMENT_ANIMATECOLOR 3
#define ELEMENT_ANIMATEMOTION 4
#define ELEMENT_ANIMATETRANSFORM 5
#define ELEMENT_ANIMATION 6
#define ELEMENT_AUDIO 7
#define ELEMENT_CIRCLE 8
#define ELEMENT_DEFS 9
#define ELEMENT_DESC 10
#define ELEMENT_DISCARD 11
#define ELEMENT_ELLIPSE 12
#define ELEMENT_FONT 13
#define ELEMENT_FONT_FACE 14
#define ELEMENT_FONT_FACE_SRC 15
#define ELEMENT_FONT_FACE_URI 16
#define ELEMENT_FOREIGN_OBJECT 17
#define ELEMENT_G 18
#define ELEMENT_GLYPH 19
#define ELEMENT_HANDLER 20
#define ELEMENT_HKERN 21
#define ELEMENT_IMAGE 22
#define ELEMENT_LINE 23
#define ELEMENT_LINEAR_GRADIENT 24
#define ELEMENT_LISTENER 25
#define ELEMENT_METADATA 26
#define ELEMENT_MISSING_GLYPH 27
#define ELEMENT_MPATH 28
#define ELEMENT_PATH 29
#define ELEMENT_POLYGON 30
#define ELEMENT_POLYLINE 31
#define ELEMENT_PREFETCH 32
#define ELEMENT_RADIAL_GRADIENT 33
#define ELEMENT_RECT 34
#define ELEMENT_SCRIPT 35
#define ELEMENT_SET 36
#define ELEMENT_SOLID_COLOR 37
#define ELEMENT_STOP 38
#define ELEMENT_SVG 39
#define ELEMENT_SWITCH 40
#define ELEMENT_TBREAK 41
#define ELEMENT_TEXT 42
#define ELEMENT_TEXT_AREA 43
#define ELEMENT_TITLE 44
#define ELEMENT_TSPAN 45
#define ELEMENT_USE 46
#define ELEMENT_VIDEO 47
#define HOOP_126X110 0
#define HOOP_110X110 1
#define HOOP_50X50 2
#define HOOP_140X200 3
#define HOOP_230X200 4
/* DXF Version Identifiers */
#define DXF_VERSION_R10 "AC1006"
#define DXF_VERSION_R11 "AC1009"
#define DXF_VERSION_R12 "AC1009"
#define DXF_VERSION_R13 "AC1012"
#define DXF_VERSION_R14 "AC1014"
#define DXF_VERSION_R15 "AC1015"
#define DXF_VERSION_R18 "AC1018"
#define DXF_VERSION_R21 "AC1021"
#define DXF_VERSION_R24 "AC1024"
#define DXF_VERSION_R27 "AC1027"
#define DXF_VERSION_2000 "AC1015"
#define DXF_VERSION_2002 "AC1015"
#define DXF_VERSION_2004 "AC1018"
#define DXF_VERSION_2006 "AC1018"
#define DXF_VERSION_2007 "AC1021"
#define DXF_VERSION_2009 "AC1021"
#define DXF_VERSION_2010 "AC1024"
#define DXF_VERSION_2013 "AC1027"
#define SVG_CREATOR_NULL 0
#define SVG_CREATOR_EMBROIDERMODDER 1
#define SVG_CREATOR_ILLUSTRATOR 2
#define SVG_CREATOR_INKSCAPE 3
#define SVG_EXPECT_NULL 0
#define SVG_EXPECT_ELEMENT 1
#define SVG_EXPECT_ATTRIBUTE 2
#define SVG_EXPECT_VALUE 3
/* SVG_TYPES
* ---------
*/
#define SVG_NULL 0
#define SVG_ELEMENT 1
#define SVG_PROPERTY 2
#define SVG_MEDIA_PROPERTY 3
#define SVG_ATTRIBUTE 4
#define SVG_CATCH_ALL 5
/* path flag codes */
#define LINETO 0x000
#define MOVETO 0x001
#define BULGETOCONTROL 0x002
#define BULGETOEND 0x004
#define ELLIPSETORAD 0x008
#define ELLIPSETOEND 0x010
#define CUBICTOCONTROL1 0x020
#define CUBICTOCONTROL2 0x040
#define CUBICTOEND 0x080
#define QUADTOCONTROL 0x100
#define QUADTOEND 0x200
/* same order as flag_list, to use in jump table */
#define FLAG_TO 0
#define FLAG_TO_SHORT 1
#define FLAG_HELP 2
#define FLAG_HELP_SHORT 3
#define FLAG_FORMATS 4
#define FLAG_FORMATS_SHORT 5
#define FLAG_QUIET 6
#define FLAG_QUIET_SHORT 7
#define FLAG_VERBOSE 8
#define FLAG_VERBOSE_SHORT 9
#define FLAG_VERSION 10
#define FLAG_VERSION_SHORT 11
#define FLAG_CIRCLE 12
#define FLAG_CIRCLE_SHORT 13
#define FLAG_ELLIPSE 14
#define FLAG_ELLIPSE_SHORT 15
#define FLAG_LINE 16
#define FLAG_LINE_SHORT 17
#define FLAG_POLYGON 18
#define FLAG_POLYGON_SHORT 19
#define FLAG_POLYLINE 20
#define FLAG_POLYLINE_SHORT 21
#define FLAG_RENDER 22
#define FLAG_RENDER_SHORT 23
#define FLAG_SATIN 24
#define FLAG_SATIN_SHORT 25
#define FLAG_STITCH 26
#define FLAG_STITCH_SHORT 27
#define FLAG_TEST 28
#define FLAG_FULL_TEST_SUITE 29
#define FLAG_CONVERT_TEST 30
#define FLAG_HILBERT_CURVE 31
#define FLAG_SIERPINSKI_TRIANGLE 32
#define FLAG_FILL 33
#define FLAG_FILL_SHORT 34
#define FLAG_SIMULATE 35
#define FLAG_COMBINE 36
#define FLAG_CROSS_STITCH 37
#define FLAG_POSTSCRIPT 38
#define NUM_FLAGS 39
/* LANGUAGES */
#define LANG_SVG 0
#define LANG_PS 1
#define LANG_PROMPT 2
/* COMMANDS
*
* These identifiers are subject to change since they are in alphabetical order
* and the numbers are increasing.
*
* Note that GUI-only commands are present here because this is for operations
* available in all frontends.
*
* The actuator uses
*/
#define EMB_CMD_ABOUT 0
#define EMB_CMD_ARC 1
#define EMB_CMD_CIRCLE 2
#define N_COMMANDS 3
/* Brand identifiers. */
#define EMB_BRAND_DXF 0
#define EMB_BRAND_HUS 1
#define EMB_BRAND_JEF 2
#define EMB_BRAND_SHV 3
#define EMB_BRAND_PCM 4
#define EMB_BRAND_PEC 5
#define EMB_BRAND_SVG 6
/* UTILITY MACROS
* --------------
*/
#define EMB_MIN(A, B) (((A) < (B)) ? (A) : (B))
#define EMB_MAX(A, B) (((A) > (B)) ? (A) : (B))
/* COMPILATION SETTINGS
* --------------------
*/
#if defined(_WIN32) && !defined(WIN32)
#define WIN32
#endif
/* When building a shared library,
* use the proper export keyword depending on the compiler */
#define EMB_PUBLIC
#if defined(LIBEMBROIDERY_SHARED)
#undef EMB_PUBLIC
#if defined(__WIN32__) || defined(WIN32)
#define EMB_PUBLIC __declspec(dllexport)
#else
#define EMB_PUBLIC __attribute__ ((visibility("default")))
#endif
#endif
/* TYPEDEFS AND STRUCTS
*******************************************************************/
/* Should some platform need a different precision, this is typedef-ed
* and used in place of all real types where possible.
*/
typedef float EmbReal;
/* EmbColor uses the light primaries: red, green, blue in that order. */
typedef struct EmbColor_
{
unsigned char r;
unsigned char g;
unsigned char b;
} EmbColor;
/* The basic type to represent points absolutely or represent directions.
*
* Positive y is up, units are in mm.
*/
typedef struct EmbVector_
{
EmbReal x;
EmbReal y;
} EmbVector;
/* . */
typedef struct EmbTime_
{
unsigned int year;
unsigned int month;
unsigned int day;
unsigned int hour;
unsigned int minute;
unsigned int second;
} EmbTime;
/* For our internal string library.
*
* Note that we cannot use this for any larger amount of data,
* it's to ensure that the cap on the size is fixed at 200.
*/
typedef char EmbString[200];
/* To help new developers understand why we use "void *",
* when it is widely not recommended within C++.
*
* libembroidery is a low-level library: we need to do bit-level
* and untyped calculations. Thinking "memory location" not
* "untyped pointer" helped me (Robin).
*/
typedef void *EmbMem;
/* The basic array type. */
typedef struct EmbArray_ EmbArray;
/* double-indirection file allocation table references */
typedef struct _bcf_file_difat
{
unsigned int fatSectorCount;
unsigned int fatSectorEntries[109];
unsigned int sectorSize;
} bcf_file_difat;
/* . */
typedef struct _bcf_file_fat
{
int fatEntryCount;
unsigned int fatEntries[255]; /* maybe make this dynamic */
unsigned int numberOfEntriesInFatSector;
} bcf_file_fat;
/* . */
typedef struct _bcf_directory_entry
{
char directoryEntryName[32];
unsigned short directoryEntryNameLength;
unsigned char objectType;
unsigned char colorFlag;
unsigned int leftSiblingId;
unsigned int rightSiblingId;
unsigned int childId;
unsigned char CLSID[16];
unsigned int stateBits;
EmbTime creationTime;
EmbTime modifiedTime;
unsigned int startingSectorLocation;
/* streamSize should be long long but in our case we shouldn't need it,
* and hard to support on c89 cross platform. */
unsigned long streamSize;
/* Store the high int of streamsize. */
unsigned int streamSizeHigh;
struct _bcf_directory_entry* next;
} bcf_directory_entry;
/* TODO: possibly add a directory tree in the future.
*/
typedef struct _bcf_directory
{
bcf_directory_entry* dirEntries;
unsigned int maxNumberOfDirectoryEntries;
} bcf_directory;
/* TODO: CLSID should be a separate type.
*/
typedef struct _bcf_file_header
{
unsigned char signature[8];
unsigned char CLSID[16];
unsigned short minorVersion;
unsigned short majorVersion;
unsigned short byteOrder;
unsigned short sectorShift;
unsigned short miniSectorShift;
unsigned short reserved1;
unsigned int reserved2;
unsigned int numberOfDirectorySectors;
unsigned int numberOfFATSectors;
unsigned int firstDirectorySectorLocation;
unsigned int transactionSignatureNumber;
unsigned int miniStreamCutoffSize;
unsigned int firstMiniFATSectorLocation;
unsigned int numberOfMiniFatSectors;
unsigned int firstDifatSectorLocation;
unsigned int numberOfDifatSectors;
} bcf_file_header;
/* . */
typedef struct _bcf_file
{
bcf_file_header header; /*! The header for the CompoundFile */
bcf_file_difat* difat; /*! The "Double Indirect FAT" for the CompoundFile */
bcf_file_fat* fat; /*! The File Allocation Table for the Compound File */
bcf_directory* directory; /*! The directory for the CompoundFile */
} bcf_file;
/* . */
typedef struct _vp3Hoop
{
int right;
int bottom;
int left;
int top;
int threadLength;
char unknown2;
unsigned char numberOfColors;
unsigned short unknown3;
int unknown4;
int numberOfBytesRemaining;
int xOffset;
int yOffset;
unsigned char byte1;
unsigned char byte2;
unsigned char byte3;
/* Centered hoop dimensions */
int right2;
int left2;
int bottom2;
int top2;
int width;
int height;
} vp3Hoop;
/* . */
typedef struct ThredHeader_ /* thred file header */
{
unsigned int sigVersion; /* signature and version */
unsigned int length; /* length of ThredHeader + length of stitch data */
unsigned short numStiches; /* number of stitches */
unsigned short hoopSize; /* size of hoop */
unsigned short reserved[7]; /* reserved for expansion */
} ThredHeader;
/* . */
typedef struct ThredExtension_ /* thred v1.0 file header extension */
{
float hoopX; /* hoop size x dimension in 1/6 mm units */
float hoopY; /* hoop size y dimension in 1/6 mm units */
float stitchGranularity; /* stitches per millimeter--not implemented */
char creatorName[50]; /* name of the file creator */
char modifierName[50]; /* name of last file modifier */
char auxFormat; /* auxiliary file format, 0=PCS,1=DST,2=PES */
char reserved[31]; /* reserved for expansion */
} ThredExtension;
/* . */
typedef struct SubDescriptor_
{
int someNum; /*! \todo better variable naming */
int someInt; /*! \todo better variable naming */
int someOtherInt; /*! \todo better variable naming */
char* colorCode;
char* colorName;
} SubDescriptor;
/* . */
typedef struct StxThread_
{
char* colorCode;
char* colorName;
char* sectionName;
SubDescriptor* subDescriptors;
EmbColor stxColor;
} StxThread;
/* . */
typedef struct VipHeader_ {
int magicCode;
int numberOfStitches;
int numberOfColors;
short postitiveXHoopSize;
short postitiveYHoopSize;
short negativeXHoopSize;
short negativeYHoopSize;
int attributeOffset;
int xOffset;
int yOffset;
unsigned char stringVal[8];
short unknown;
int colorLength;
} VipHeader;
/* . */
typedef enum
{
CSV_EXPECT_NULL,
CSV_EXPECT_QUOTE1,
CSV_EXPECT_QUOTE2,
CSV_EXPECT_COMMA
} CSV_EXPECT;
/* . */
typedef enum
{
CSV_MODE_NULL,
CSV_MODE_COMMENT,
CSV_MODE_VARIABLE,
CSV_MODE_THREAD,
CSV_MODE_STITCH
} CSV_MODE;
/* . */
typedef struct SvgAttribute_
{
char* name;
char* value;
} SvgAttribute;
/* . */
typedef struct Huffman {
int default_value;
int lengths[1000];
int nlengths;
int table[1000];
int table_width;
int ntable;
} huffman;
/* . */
typedef struct Compress {
int bit_position;
char *input_data;
int input_length;
int bits_total;
int block_elements;
huffman character_length_huffman;
huffman character_huffman;
huffman distance_huffman;
} compress;
/* . */
typedef struct EmbImage_ {
EmbVector position;
EmbVector dimensions;
unsigned char* data;
int width;
int height;
EmbString path;
EmbString name;
} EmbImage;
/* . */
typedef struct EmbBlock_ {
EmbVector position;
} EmbBlock;
/* . */
typedef struct EmbAlignedDim_ {
EmbVector position;
} EmbAlignedDim;
/* . */
typedef struct EmbAngularDim_ {
EmbVector position;
} EmbAngularDim;
/* . */
typedef struct EmbArcLengthDim_ {
EmbVector position;
} EmbArcLengthDim;
/* . */
typedef struct EmbDiameterDim_ {
EmbVector position;
} EmbDiameterDim;
/* . */
typedef struct EmbLeaderDim_ {
EmbVector position;
} EmbLeaderDim;
/* . */
typedef struct EmbLinearDim_ {
EmbVector position;
} EmbLinearDim;
/* . */
typedef struct EmbOrdinateDim_ {
EmbVector position;
} EmbOrdinateDim;
/* . */
typedef struct EmbRadiusDim_ {
EmbVector position;
} EmbRadiusDim;
/* . */
typedef struct EmbInfiniteLine_ {
EmbVector position;
} EmbInfiniteLine;
/* . */
typedef struct EmbRay_ {
EmbVector position;
} EmbRay;
/* . */
typedef struct EmbTextMulti_ {
EmbVector position;
EmbString text;
} EmbTextMulti;
/* . */
typedef struct EmbTextSingle_ {
EmbVector position;
EmbString text;
} EmbTextSingle;
/* . */
typedef struct EmbPoint_
{
EmbVector position;
int lineType;
EmbColor color;
} EmbPoint;
/* . */
typedef struct EmbLine_
{
EmbVector start;
EmbVector end;
int lineType;
EmbColor color;
} EmbLine;
/* . */
typedef struct EmbPath_
{
EmbArray* pointList;
EmbArray* flagList;
int lineType;
EmbColor color;
} EmbPath;
/* . */
typedef struct EmbStitch_
{
int flags; /*! uses codes defined above */
EmbReal x; /*! absolute position (not relative) */
EmbReal y; /*! positive is up, units are in mm */
int color; /*! color number for this stitch */
/*! \todo this should be called colorIndex since it is not an EmbColor */
} EmbStitch;
/* . */
typedef struct EmbThread_
{
EmbColor color;
EmbString description;
EmbString catalogNumber;
} EmbThread;
/* . */
typedef struct thread_color_ {
EmbString name;
unsigned int hex_code;
int manufacturer_code;
} thread_color;
/* absolute position (not relative) */
typedef struct EmbArc_
{
EmbVector start;
EmbVector mid;
EmbVector end;
} EmbArc;
/* . */
typedef struct EmbRect_
{
EmbReal x;
EmbReal y;
EmbReal w;
EmbReal h;
EmbReal rotation;
EmbReal radius;
} EmbRect;
/* . */
typedef struct EmbCircle_
{
EmbVector center;
EmbReal radius;
} EmbCircle;
/* . */
typedef EmbPath EmbPolygon;
/* . */
typedef EmbPath EmbPolyline;
/* . */
typedef int EmbFlag;
/* . */
typedef struct EmbSatinOutline_
{
int length;
EmbArray* side1;
EmbArray* side2;
} EmbSatinOutline;
/* . */
typedef struct EmbEllipse_
{
EmbVector center;
EmbVector radius;
EmbReal rotation;
} EmbEllipse;
/* . */
typedef struct EmbBezier_ {
EmbVector start;
EmbVector control1;
EmbVector control2;
EmbVector end;
} EmbBezier;
/* . */
typedef struct EmbSpline_ {
EmbArray *beziers;
} EmbSpline;
/* . */
typedef struct LSYSTEM {
char axiom;
char *alphabet;
char *constants;
char **rules;
} L_system;
/* . */
typedef struct EmbGeometry_ {
union {
EmbArc arc;
EmbCircle circle;
EmbColor color;
EmbEllipse ellipse;
EmbLine line;
EmbPath path;
EmbPoint point;
EmbPolygon polygon;
EmbPolyline polyline;
EmbRect rect;
EmbSpline spline;
EmbVector vector;
} object;
int flag;
int type;
int lineType;
EmbColor color;
} EmbGeometry;
/* . */
struct EmbArray_ {
EmbGeometry *geometry;
EmbStitch *stitch;
EmbThread *thread;
int count;
int length;
int type;
};
/* . */
typedef struct EmbLayer_
{
char name[100];
EmbArray *geometry;
} EmbLayer;
/* . */
typedef struct EmbPattern_
{
unsigned int dstJumpsPerTrim;
EmbVector home;
EmbReal hoop_width;
EmbReal hoop_height;
EmbArray *thread_list;
EmbArray *stitch_list;
EmbArray *geometry;
EmbLayer layer[EMB_MAX_LAYERS];
int currentColorIndex;
} EmbPattern;
/* . */
typedef struct EmbFormatList_
{
EmbString extension;
EmbString description;
char reader_state;
char writer_state;
int type;
int color_only;
int check_for_color_file;
int write_external_color_file;
} EmbFormatList;
/* Thread colors that are subject to change are loaded at runtime,
* allowing us to update them as they change.
*
* However, in-builts that use indicies like the DXF, SVG or HUS
* tables are compiled in. This should help with embedded compatibility
* in both cases.
*/
typedef struct BRAND {
thread_color *codes;
int length;
EmbString label;
} EmbBrand;
/* Function Declarations
*****************************************************************************/
EMB_PUBLIC int lindenmayer_system(L_system L, char* state, int iteration, int complete);
EMB_PUBLIC int hilbert_curve(EmbPattern *pattern, int iterations);
EMB_PUBLIC int emb_identify_format(const char *ending);
EMB_PUBLIC int convert(const char *inf, const char *outf);
EMB_PUBLIC EmbVector emb_vector(EmbReal x, EmbReal y);
EMB_PUBLIC void emb_processor(char *state, const char *program, int program_length);
EMB_PUBLIC int emb_compiler(const char *program, int language, char *compiled_program);
EMB_PUBLIC void emb_actuator(const char *program, int language);
EMB_PUBLIC EmbColor embColor_make(unsigned char r, unsigned char g, unsigned char b);
EMB_PUBLIC EmbColor embColor_fromHexStr(char* val);
EMB_PUBLIC int embColor_distance(EmbColor a, EmbColor b);
EMB_PUBLIC EmbArray* emb_array_create(int type);
EMB_PUBLIC int emb_array_resize(EmbArray *g);
EMB_PUBLIC void emb_array_copy(EmbArray *dst, EmbArray *src);
EMB_PUBLIC int emb_array_add_geometry(EmbArray *a, EmbGeometry g);
EMB_PUBLIC int emb_array_add_arc(EmbArray* g, EmbArc arc);
EMB_PUBLIC int emb_array_add_circle(EmbArray* g, EmbCircle circle);
EMB_PUBLIC int emb_array_add_ellipse(EmbArray* g, EmbEllipse ellipse);
EMB_PUBLIC int emb_array_add_flag(EmbArray* g, int flag);
EMB_PUBLIC int emb_array_addLine(EmbArray* g, EmbLine line);
EMB_PUBLIC int emb_array_addRect(EmbArray* g, EmbRect rect);
EMB_PUBLIC int emb_array_addPath(EmbArray* g, EmbPath p);
EMB_PUBLIC int emb_array_addPoint(EmbArray* g, EmbPoint p);
EMB_PUBLIC int emb_array_addPolygon(EmbArray* g, EmbPolygon p);
EMB_PUBLIC int emb_array_addPolyline(EmbArray* g, EmbPolyline p);