initial version, DXFs can be read, some G-code can be produced
Stefan Schuermans

Stefan Schuermans commited on 2013-01-20 20:53:53
Showing 36 changed files, with 4447 additions and 0 deletions.

... ...
@@ -0,0 +1,3 @@
1
+dep
2
+dxfngc
3
+obj
... ...
@@ -0,0 +1,52 @@
1
+# drawing (DXF) to gcode (NGC) converter
2
+# Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+# Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+
5
+TARGET=dxfngc
6
+
7
+SRCS=$(wildcard src/*.cpp)
8
+
9
+CFLAGS=-Wall -Wextra -Werror -O3
10
+DEFINES=
11
+INCLUDES=
12
+LDFLAGS=
13
+LIBS=-lm -ldime
14
+
15
+CPP=g++
16
+CPPARGS=$(CFLAGS) $(DEFINES) $(INCLUDES)
17
+
18
+SRCS_BASE=$(patsubst src/%.cpp,%,$(SRCS))
19
+DEPS=$(addprefix dep/,$(addsuffix .d,$(SRCS_BASE)))
20
+OBJS=$(addprefix obj/,$(addsuffix .o,$(SRCS_BASE)))
21
+
22
+.PHONY: all clean
23
+.SECONDARY:
24
+.SUFFIXES:
25
+
26
+all: dep/deps $(TARGET)
27
+
28
+ifneq ($(MAKECMDGOALS),clean)
29
+  include dep/deps
30
+endif
31
+
32
+dep:
33
+	mkdir -p $@
34
+
35
+dep/deps: $(DEPS) | dep
36
+	cat /dev/null $^ >$@
37
+
38
+dep/%.d: src/%.cpp Makefile | dep
39
+	$(CPP) $(CPPARGS) -M -MT$(patsubst src/%.cpp,obj/%.o,$<) -o $@ $<
40
+
41
+obj:
42
+	mkdir -p $@
43
+
44
+obj/%.o: src/%.cpp Makefile | obj
45
+	$(CPP) $(CPPARGS) -c -o $@ $<
46
+
47
+$(TARGET): $(OBJS)
48
+	$(CPP) $(LDFLAGS) -o $@ $^ $(LIBS)
49
+
50
+clean:
51
+	rm -rf dep obj $(TARGET)
52
+
... ...
@@ -0,0 +1 @@
1
+*.ngc
... ...
@@ -0,0 +1,2666 @@
1
+999
2
+dxflib 2.0.4.8
3
+  0
4
+SECTION
5
+  2
6
+HEADER
7
+  9
8
+$ACADVER
9
+  1
10
+AC1015
11
+  9
12
+$HANDSEED
13
+  5
14
+FFFF
15
+  9
16
+$DIMASZ
17
+ 40
18
+2.5
19
+  9
20
+$DIMGAP
21
+ 40
22
+0.625
23
+  9
24
+$INSUNITS
25
+ 70
26
+4
27
+  9
28
+$DIMEXO
29
+ 40
30
+0.625
31
+  9
32
+$DIMTXT
33
+ 40
34
+2.5
35
+  9
36
+$DIMSTYLE
37
+  2
38
+Standard
39
+  9
40
+$PLIMMIN
41
+ 10
42
+0.0
43
+ 20
44
+0.0
45
+  9
46
+$PLIMMAX
47
+ 10
48
+210.0
49
+ 20
50
+297.0
51
+  9
52
+$DIMEXE
53
+ 40
54
+1.25
55
+  0
56
+ENDSEC
57
+  0
58
+SECTION
59
+  2
60
+TABLES
61
+  0
62
+TABLE
63
+  2
64
+VPORT
65
+  5
66
+8
67
+100
68
+AcDbSymbolTable
69
+ 70
70
+1
71
+  0
72
+VPORT
73
+  5
74
+30
75
+100
76
+AcDbSymbolTableRecord
77
+100
78
+AcDbViewportTableRecord
79
+  2
80
+*Active
81
+ 70
82
+0
83
+ 10
84
+0.0
85
+ 20
86
+0.0
87
+ 11
88
+1.0
89
+ 21
90
+1.0
91
+ 12
92
+286.3055555555554861
93
+ 22
94
+148.5
95
+ 13
96
+0.0
97
+ 23
98
+0.0
99
+ 14
100
+10.0
101
+ 24
102
+10.0
103
+ 15
104
+10.0
105
+ 25
106
+10.0
107
+ 16
108
+0.0
109
+ 26
110
+0.0
111
+ 36
112
+1.0
113
+ 17
114
+0.0
115
+ 27
116
+0.0
117
+ 37
118
+0.0
119
+ 40
120
+297.0
121
+ 41
122
+1.92798353909465
123
+ 42
124
+50.0
125
+ 43
126
+0.0
127
+ 44
128
+0.0
129
+ 50
130
+0.0
131
+ 51
132
+0.0
133
+ 71
134
+0
135
+ 72
136
+100
137
+ 73
138
+1
139
+ 74
140
+3
141
+ 75
142
+1
143
+ 76
144
+1
145
+ 77
146
+0
147
+ 78
148
+0
149
+281
150
+0
151
+ 65
152
+1
153
+110
154
+0.0
155
+120
156
+0.0
157
+130
158
+0.0
159
+111
160
+1.0
161
+121
162
+0.0
163
+131
164
+0.0
165
+112
166
+0.0
167
+122
168
+1.0
169
+132
170
+0.0
171
+ 79
172
+0
173
+146
174
+0.0
175
+  0
176
+ENDTAB
177
+  0
178
+TABLE
179
+  2
180
+LTYPE
181
+  5
182
+5
183
+100
184
+AcDbSymbolTable
185
+ 70
186
+21
187
+  0
188
+LTYPE
189
+  5
190
+14
191
+100
192
+AcDbSymbolTableRecord
193
+100
194
+AcDbLinetypeTableRecord
195
+  2
196
+ByBlock
197
+ 70
198
+0
199
+  3
200
+
201
+ 72
202
+65
203
+ 73
204
+0
205
+ 40
206
+0.0
207
+  0
208
+LTYPE
209
+  5
210
+15
211
+100
212
+AcDbSymbolTableRecord
213
+100
214
+AcDbLinetypeTableRecord
215
+  2
216
+ByLayer
217
+ 70
218
+0
219
+  3
220
+
221
+ 72
222
+65
223
+ 73
224
+0
225
+ 40
226
+0.0
227
+  0
228
+LTYPE
229
+  5
230
+16
231
+100
232
+AcDbSymbolTableRecord
233
+100
234
+AcDbLinetypeTableRecord
235
+  2
236
+CONTINUOUS
237
+ 70
238
+0
239
+  3
240
+Solid line
241
+ 72
242
+65
243
+ 73
244
+0
245
+ 40
246
+0.0
247
+  0
248
+LTYPE
249
+  5
250
+31
251
+100
252
+AcDbSymbolTableRecord
253
+100
254
+AcDbLinetypeTableRecord
255
+  2
256
+DOT
257
+ 70
258
+0
259
+  3
260
+Dot . . . . . . . . . . . . . . . . . . . . . .
261
+ 72
262
+65
263
+ 73
264
+2
265
+ 40
266
+6.3499999999999996
267
+ 49
268
+0.0
269
+ 74
270
+0
271
+ 49
272
+-6.3499999999999996
273
+ 74
274
+0
275
+  0
276
+LTYPE
277
+  5
278
+32
279
+100
280
+AcDbSymbolTableRecord
281
+100
282
+AcDbLinetypeTableRecord
283
+  2
284
+DOT2
285
+ 70
286
+0
287
+  3
288
+Dot (.5x) .....................................
289
+ 72
290
+65
291
+ 73
292
+2
293
+ 40
294
+3.1749999999999998
295
+ 49
296
+0.0
297
+ 74
298
+0
299
+ 49
300
+-3.1749999999999998
301
+ 74
302
+0
303
+  0
304
+LTYPE
305
+  5
306
+33
307
+100
308
+AcDbSymbolTableRecord
309
+100
310
+AcDbLinetypeTableRecord
311
+  2
312
+DOTX2
313
+ 70
314
+0
315
+  3
316
+Dot (2x) .  .  .  .  .  .  .  .  .  .  .  .  .
317
+ 72
318
+65
319
+ 73
320
+2
321
+ 40
322
+12.6999999999999993
323
+ 49
324
+0.0
325
+ 74
326
+0
327
+ 49
328
+-12.6999999999999993
329
+ 74
330
+0
331
+  0
332
+LTYPE
333
+  5
334
+34
335
+100
336
+AcDbSymbolTableRecord
337
+100
338
+AcDbLinetypeTableRecord
339
+  2
340
+DASHED
341
+ 70
342
+0
343
+  3
344
+Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _
345
+ 72
346
+65
347
+ 73
348
+2
349
+ 40
350
+19.0500000000000007
351
+ 49
352
+12.6999999999999993
353
+ 74
354
+0
355
+ 49
356
+-6.3499999999999996
357
+ 74
358
+0
359
+  0
360
+LTYPE
361
+  5
362
+35
363
+100
364
+AcDbSymbolTableRecord
365
+100
366
+AcDbLinetypeTableRecord
367
+  2
368
+DASHED2
369
+ 70
370
+0
371
+  3
372
+Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
373
+ 72
374
+65
375
+ 73
376
+2
377
+ 40
378
+9.5250000000000004
379
+ 49
380
+6.3499999999999996
381
+ 74
382
+0
383
+ 49
384
+-3.1749999999999998
385
+ 74
386
+0
387
+  0
388
+LTYPE
389
+  5
390
+36
391
+100
392
+AcDbSymbolTableRecord
393
+100
394
+AcDbLinetypeTableRecord
395
+  2
396
+DASHEDX2
397
+ 70
398
+0
399
+  3
400
+Dashed (2x) ____  ____  ____  ____  ____  ___
401
+ 72
402
+65
403
+ 73
404
+2
405
+ 40
406
+38.1000000000000014
407
+ 49
408
+25.3999999999999986
409
+ 74
410
+0
411
+ 49
412
+-12.6999999999999993
413
+ 74
414
+0
415
+  0
416
+LTYPE
417
+  5
418
+37
419
+100
420
+AcDbSymbolTableRecord
421
+100
422
+AcDbLinetypeTableRecord
423
+  2
424
+DASHDOT
425
+ 70
426
+0
427
+  3
428
+Dash dot __ . __ . __ . __ . __ . __ . __ . __
429
+ 72
430
+65
431
+ 73
432
+4
433
+ 40
434
+25.3999999999999986
435
+ 49
436
+12.6999999999999993
437
+ 74
438
+0
439
+ 49
440
+-6.3499999999999996
441
+ 74
442
+0
443
+ 49
444
+0.0
445
+ 74
446
+0
447
+ 49
448
+-6.3499999999999996
449
+ 74
450
+0
451
+  0
452
+LTYPE
453
+  5
454
+38
455
+100
456
+AcDbSymbolTableRecord
457
+100
458
+AcDbLinetypeTableRecord
459
+  2
460
+DASHDOT2
461
+ 70
462
+0
463
+  3
464
+Dash dot (.5x) _._._._._._._._._._._._._._._.
465
+ 72
466
+65
467
+ 73
468
+4
469
+ 40
470
+12.6999999999999993
471
+ 49
472
+6.3499999999999996
473
+ 74
474
+0
475
+ 49
476
+-3.1749999999999998
477
+ 74
478
+0
479
+ 49
480
+0.0
481
+ 74
482
+0
483
+ 49
484
+-3.1749999999999998
485
+ 74
486
+0
487
+  0
488
+LTYPE
489
+  5
490
+39
491
+100
492
+AcDbSymbolTableRecord
493
+100
494
+AcDbLinetypeTableRecord
495
+  2
496
+DASHDOTX2
497
+ 70
498
+0
499
+  3
500
+Dash dot (2x) ____  .  ____  .  ____  .  ___
501
+ 72
502
+65
503
+ 73
504
+4
505
+ 40
506
+50.7999999999999972
507
+ 49
508
+25.3999999999999986
509
+ 74
510
+0
511
+ 49
512
+-12.6999999999999993
513
+ 74
514
+0
515
+ 49
516
+0.0
517
+ 74
518
+0
519
+ 49
520
+-12.6999999999999993
521
+ 74
522
+0
523
+  0
524
+LTYPE
525
+  5
526
+3A
527
+100
528
+AcDbSymbolTableRecord
529
+100
530
+AcDbLinetypeTableRecord
531
+  2
532
+DIVIDE
533
+ 70
534
+0
535
+  3
536
+Divide ____ . . ____ . . ____ . . ____ . . ____
537
+ 72
538
+65
539
+ 73
540
+6
541
+ 40
542
+31.75
543
+ 49
544
+12.6999999999999993
545
+ 74
546
+0
547
+ 49
548
+-6.3499999999999996
549
+ 74
550
+0
551
+ 49
552
+0.0
553
+ 74
554
+0
555
+ 49
556
+-6.3499999999999996
557
+ 74
558
+0
559
+ 49
560
+0.0
561
+ 74
562
+0
563
+ 49
564
+-6.3499999999999996
565
+ 74
566
+0
567
+  0
568
+LTYPE
569
+  5
570
+3B
571
+100
572
+AcDbSymbolTableRecord
573
+100
574
+AcDbLinetypeTableRecord
575
+  2
576
+DIVIDE2
577
+ 70
578
+0
579
+  3
580
+Divide (.5x) __..__..__..__..__..__..__..__.._
581
+ 72
582
+65
583
+ 73
584
+6
585
+ 40
586
+15.875
587
+ 49
588
+6.3499999999999996
589
+ 74
590
+0
591
+ 49
592
+-3.1749999999999998
593
+ 74
594
+0
595
+ 49
596
+0.0
597
+ 74
598
+0
599
+ 49
600
+-3.1749999999999998
601
+ 74
602
+0
603
+ 49
604
+0.0
605
+ 74
606
+0
607
+ 49
608
+-3.1749999999999998
609
+ 74
610
+0
611
+  0
612
+LTYPE
613
+  5
614
+3C
615
+100
616
+AcDbSymbolTableRecord
617
+100
618
+AcDbLinetypeTableRecord
619
+  2
620
+DIVIDEX2
621
+ 70
622
+0
623
+  3
624
+Divide (2x) ________  .  .  ________  .  .  _
625
+ 72
626
+65
627
+ 73
628
+6
629
+ 40
630
+63.5
631
+ 49
632
+25.3999999999999986
633
+ 74
634
+0
635
+ 49
636
+-12.6999999999999993
637
+ 74
638
+0
639
+ 49
640
+0.0
641
+ 74
642
+0
643
+ 49
644
+-12.6999999999999993
645
+ 74
646
+0
647
+ 49
648
+0.0
649
+ 74
650
+0
651
+ 49
652
+-12.6999999999999993
653
+ 74
654
+0
655
+  0
656
+LTYPE
657
+  5
658
+3D
659
+100
660
+AcDbSymbolTableRecord
661
+100
662
+AcDbLinetypeTableRecord
663
+  2
664
+CENTER
665
+ 70
666
+0
667
+  3
668
+Center ____ _ ____ _ ____ _ ____ _ ____ _ ____
669
+ 72
670
+65
671
+ 73
672
+4
673
+ 40
674
+50.7999999999999972
675
+ 49
676
+31.75
677
+ 74
678
+0
679
+ 49
680
+-6.3499999999999996
681
+ 74
682
+0
683
+ 49
684
+6.3499999999999996
685
+ 74
686
+0
687
+ 49
688
+-6.3499999999999996
689
+ 74
690
+0
691
+  0
692
+LTYPE
693
+  5
694
+3E
695
+100
696
+AcDbSymbolTableRecord
697
+100
698
+AcDbLinetypeTableRecord
699
+  2
700
+CENTER2
701
+ 70
702
+0
703
+  3
704
+Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___
705
+ 72
706
+65
707
+ 73
708
+4
709
+ 40
710
+28.5749999999999993
711
+ 49
712
+19.0500000000000007
713
+ 74
714
+0
715
+ 49
716
+-3.1749999999999998
717
+ 74
718
+0
719
+ 49
720
+3.1749999999999998
721
+ 74
722
+0
723
+ 49
724
+-3.1749999999999998
725
+ 74
726
+0
727
+  0
728
+LTYPE
729
+  5
730
+3F
731
+100
732
+AcDbSymbolTableRecord
733
+100
734
+AcDbLinetypeTableRecord
735
+  2
736
+CENTERX2
737
+ 70
738
+0
739
+  3
740
+Center (2x) ________  __  ________  __  _____
741
+ 72
742
+65
743
+ 73
744
+4
745
+ 40
746
+101.5999999999999943
747
+ 49
748
+63.5
749
+ 74
750
+0
751
+ 49
752
+-12.6999999999999993
753
+ 74
754
+0
755
+ 49
756
+12.6999999999999993
757
+ 74
758
+0
759
+ 49
760
+-12.6999999999999993
761
+ 74
762
+0
763
+  0
764
+LTYPE
765
+  5
766
+40
767
+100
768
+AcDbSymbolTableRecord
769
+100
770
+AcDbLinetypeTableRecord
771
+  2
772
+BORDER
773
+ 70
774
+0
775
+  3
776
+Border __ __ . __ __ . __ __ . __ __ . __ __ .
777
+ 72
778
+65
779
+ 73
780
+6
781
+ 40
782
+44.4500000000000028
783
+ 49
784
+12.6999999999999993
785
+ 74
786
+0
787
+ 49
788
+-6.3499999999999996
789
+ 74
790
+0
791
+ 49
792
+12.6999999999999993
793
+ 74
794
+0
795
+ 49
796
+-6.3499999999999996
797
+ 74
798
+0
799
+ 49
800
+0.0
801
+ 74
802
+0
803
+ 49
804
+-6.3499999999999996
805
+ 74
806
+0
807
+  0
808
+LTYPE
809
+  5
810
+41
811
+100
812
+AcDbSymbolTableRecord
813
+100
814
+AcDbLinetypeTableRecord
815
+  2
816
+BORDER2
817
+ 70
818
+0
819
+  3
820
+Border (.5x) __.__.__.__.__.__.__.__.__.__.__.
821
+ 72
822
+65
823
+ 73
824
+6
825
+ 40
826
+22.2250000000000014
827
+ 49
828
+6.3499999999999996
829
+ 74
830
+0
831
+ 49
832
+-3.1749999999999998
833
+ 74
834
+0
835
+ 49
836
+6.3499999999999996
837
+ 74
838
+0
839
+ 49
840
+-3.1749999999999998
841
+ 74
842
+0
843
+ 49
844
+0.0
845
+ 74
846
+0
847
+ 49
848
+-3.1749999999999998
849
+ 74
850
+0
851
+  0
852
+LTYPE
853
+  5
854
+42
855
+100
856
+AcDbSymbolTableRecord
857
+100
858
+AcDbLinetypeTableRecord
859
+  2
860
+BORDERX2
861
+ 70
862
+0
863
+  3
864
+Border (2x) ____  ____  .  ____  ____  .  ___
865
+ 72
866
+65
867
+ 73
868
+6
869
+ 40
870
+88.9000000000000057
871
+ 49
872
+25.3999999999999986
873
+ 74
874
+0
875
+ 49
876
+-12.6999999999999993
877
+ 74
878
+0
879
+ 49
880
+25.3999999999999986
881
+ 74
882
+0
883
+ 49
884
+-12.6999999999999993
885
+ 74
886
+0
887
+ 49
888
+0.0
889
+ 74
890
+0
891
+ 49
892
+-12.6999999999999993
893
+ 74
894
+0
895
+  0
896
+ENDTAB
897
+  0
898
+TABLE
899
+  2
900
+LAYER
901
+  5
902
+2
903
+100
904
+AcDbSymbolTable
905
+ 70
906
+3
907
+  0
908
+LAYER
909
+  5
910
+10
911
+100
912
+AcDbSymbolTableRecord
913
+100
914
+AcDbLayerTableRecord
915
+  2
916
+0
917
+ 70
918
+0
919
+ 62
920
+7
921
+  6
922
+CONTINUOUS
923
+370
924
+13
925
+390
926
+F
927
+  0
928
+LAYER
929
+  5
930
+43
931
+100
932
+AcDbSymbolTableRecord
933
+100
934
+AcDbLayerTableRecord
935
+  2
936
+pocket
937
+ 70
938
+0
939
+ 62
940
+1
941
+  6
942
+CONTINUOUS
943
+370
944
+13
945
+390
946
+F
947
+  0
948
+LAYER
949
+  5
950
+44
951
+100
952
+AcDbSymbolTableRecord
953
+100
954
+AcDbLayerTableRecord
955
+  2
956
+text
957
+ 70
958
+0
959
+ 62
960
+3
961
+  6
962
+CONTINUOUS
963
+370
964
+13
965
+390
966
+F
967
+  0
968
+ENDTAB
969
+  0
970
+TABLE
971
+  2
972
+STYLE
973
+  5
974
+3
975
+100
976
+AcDbSymbolTable
977
+ 70
978
+1
979
+  0
980
+STYLE
981
+  5
982
+11
983
+100
984
+AcDbSymbolTableRecord
985
+100
986
+AcDbTextStyleTableRecord
987
+  2
988
+Standard
989
+ 70
990
+0
991
+ 40
992
+0.0
993
+ 41
994
+0.75
995
+ 50
996
+0.0
997
+ 71
998
+0
999
+ 42
1000
+2.5
1001
+  3
1002
+txt
1003
+  4
1004
+
1005
+  0
1006
+ENDTAB
1007
+  0
1008
+TABLE
1009
+  2
1010
+VIEW
1011
+  5
1012
+6
1013
+100
1014
+AcDbSymbolTable
1015
+ 70
1016
+0
1017
+  0
1018
+ENDTAB
1019
+  0
1020
+TABLE
1021
+  2
1022
+UCS
1023
+  5
1024
+7
1025
+100
1026
+AcDbSymbolTable
1027
+ 70
1028
+0
1029
+  0
1030
+ENDTAB
1031
+  0
1032
+TABLE
1033
+  2
1034
+APPID
1035
+  5
1036
+9
1037
+100
1038
+AcDbSymbolTable
1039
+ 70
1040
+1
1041
+  0
1042
+APPID
1043
+  5
1044
+12
1045
+100
1046
+AcDbSymbolTableRecord
1047
+100
1048
+AcDbRegAppTableRecord
1049
+  2
1050
+ACAD
1051
+ 70
1052
+0
1053
+  0
1054
+ENDTAB
1055
+  0
1056
+TABLE
1057
+  2
1058
+DIMSTYLE
1059
+  5
1060
+A
1061
+100
1062
+AcDbSymbolTable
1063
+ 70
1064
+1
1065
+100
1066
+AcDbDimStyleTable
1067
+ 71
1068
+0
1069
+  0
1070
+DIMSTYLE
1071
+105
1072
+27
1073
+100
1074
+AcDbSymbolTableRecord
1075
+100
1076
+AcDbDimStyleTableRecord
1077
+  2
1078
+Standard
1079
+ 41
1080
+2.5
1081
+ 42
1082
+0.625
1083
+ 43
1084
+3.75
1085
+ 44
1086
+1.25
1087
+ 70
1088
+0
1089
+ 73
1090
+0
1091
+ 74
1092
+0
1093
+ 77
1094
+1
1095
+ 78
1096
+8
1097
+140
1098
+2.5
1099
+141
1100
+2.5
1101
+143
1102
+0.03937007874016
1103
+147
1104
+0.625
1105
+171
1106
+3
1107
+172
1108
+1
1109
+271
1110
+2
1111
+272
1112
+2
1113
+274
1114
+3
1115
+278
1116
+44
1117
+283
1118
+0
1119
+284
1120
+8
1121
+340
1122
+11
1123
+  0
1124
+ENDTAB
1125
+  0
1126
+TABLE
1127
+  2
1128
+BLOCK_RECORD
1129
+  5
1130
+1
1131
+100
1132
+AcDbSymbolTable
1133
+ 70
1134
+1
1135
+  0
1136
+BLOCK_RECORD
1137
+  5
1138
+1F
1139
+100
1140
+AcDbSymbolTableRecord
1141
+100
1142
+AcDbBlockTableRecord
1143
+  2
1144
+*Model_Space
1145
+340
1146
+22
1147
+  0
1148
+BLOCK_RECORD
1149
+  5
1150
+1B
1151
+100
1152
+AcDbSymbolTableRecord
1153
+100
1154
+AcDbBlockTableRecord
1155
+  2
1156
+*Paper_Space
1157
+340
1158
+1E
1159
+  0
1160
+BLOCK_RECORD
1161
+  5
1162
+23
1163
+100
1164
+AcDbSymbolTableRecord
1165
+100
1166
+AcDbBlockTableRecord
1167
+  2
1168
+*Paper_Space0
1169
+340
1170
+26
1171
+  0
1172
+ENDTAB
1173
+  0
1174
+ENDSEC
1175
+  0
1176
+SECTION
1177
+  2
1178
+BLOCKS
1179
+  0
1180
+BLOCK
1181
+  5
1182
+20
1183
+100
1184
+AcDbEntity
1185
+  8
1186
+0
1187
+100
1188
+AcDbBlockBegin
1189
+  2
1190
+*Model_Space
1191
+ 70
1192
+0
1193
+ 10
1194
+0.0
1195
+ 20
1196
+0.0
1197
+ 30
1198
+0.0
1199
+  3
1200
+*Model_Space
1201
+  1
1202
+
1203
+  0
1204
+ENDBLK
1205
+  5
1206
+21
1207
+100
1208
+AcDbEntity
1209
+  8
1210
+0
1211
+100
1212
+AcDbBlockEnd
1213
+  0
1214
+BLOCK
1215
+  5
1216
+1C
1217
+100
1218
+AcDbEntity
1219
+ 67
1220
+1
1221
+  8
1222
+0
1223
+100
1224
+AcDbBlockBegin
1225
+  2
1226
+*Paper_Space
1227
+ 70
1228
+0
1229
+ 10
1230
+0.0
1231
+ 20
1232
+0.0
1233
+ 30
1234
+0.0
1235
+  3
1236
+*Paper_Space
1237
+  1
1238
+
1239
+  0
1240
+ENDBLK
1241
+  5
1242
+1D
1243
+100
1244
+AcDbEntity
1245
+ 67
1246
+1
1247
+  8
1248
+0
1249
+100
1250
+AcDbBlockEnd
1251
+  0
1252
+BLOCK
1253
+  5
1254
+24
1255
+100
1256
+AcDbEntity
1257
+  8
1258
+0
1259
+100
1260
+AcDbBlockBegin
1261
+  2
1262
+*Paper_Space0
1263
+ 70
1264
+0
1265
+ 10
1266
+0.0
1267
+ 20
1268
+0.0
1269
+ 30
1270
+0.0
1271
+  3
1272
+*Paper_Space0
1273
+  1
1274
+
1275
+  0
1276
+ENDBLK
1277
+  5
1278
+25
1279
+100
1280
+AcDbEntity
1281
+  8
1282
+0
1283
+100
1284
+AcDbBlockEnd
1285
+  0
1286
+ENDSEC
1287
+  0
1288
+SECTION
1289
+  2
1290
+ENTITIES
1291
+  0
1292
+LINE
1293
+  5
1294
+45
1295
+100
1296
+AcDbEntity
1297
+100
1298
+AcDbLine
1299
+  8
1300
+0
1301
+ 62
1302
+256
1303
+370
1304
+-1
1305
+  6
1306
+ByLayer
1307
+ 10
1308
+10.0
1309
+ 20
1310
+70.0
1311
+ 30
1312
+0.0
1313
+ 11
1314
+110.0
1315
+ 21
1316
+70.0
1317
+ 31
1318
+0.0
1319
+  0
1320
+LINE
1321
+  5
1322
+46
1323
+100
1324
+AcDbEntity
1325
+100
1326
+AcDbLine
1327
+  8
1328
+pocket
1329
+ 62
1330
+256
1331
+370
1332
+-1
1333
+  6
1334
+ByLayer
1335
+ 10
1336
+40.0
1337
+ 20
1338
+60.0
1339
+ 30
1340
+0.0
1341
+ 11
1342
+20.0
1343
+ 21
1344
+60.0
1345
+ 31
1346
+0.0
1347
+  0
1348
+LINE
1349
+  5
1350
+47
1351
+100
1352
+AcDbEntity
1353
+100
1354
+AcDbLine
1355
+  8
1356
+pocket
1357
+ 62
1358
+256
1359
+370
1360
+-1
1361
+  6
1362
+ByLayer
1363
+ 10
1364
+20.0
1365
+ 20
1366
+60.0
1367
+ 30
1368
+0.0
1369
+ 11
1370
+20.0
1371
+ 21
1372
+20.0
1373
+ 31
1374
+0.0
1375
+  0
1376
+LINE
1377
+  5
1378
+48
1379
+100
1380
+AcDbEntity
1381
+100
1382
+AcDbLine
1383
+  8
1384
+pocket
1385
+ 62
1386
+256
1387
+370
1388
+-1
1389
+  6
1390
+ByLayer
1391
+ 10
1392
+20.0
1393
+ 20
1394
+20.0
1395
+ 30
1396
+0.0
1397
+ 11
1398
+100.0
1399
+ 21
1400
+20.0
1401
+ 31
1402
+0.0
1403
+  0
1404
+LINE
1405
+  5
1406
+49
1407
+100
1408
+AcDbEntity
1409
+100
1410
+AcDbLine
1411
+  8
1412
+pocket
1413
+ 62
1414
+256
1415
+370
1416
+-1
1417
+  6
1418
+ByLayer
1419
+ 10
1420
+100.0
1421
+ 20
1422
+20.0
1423
+ 30
1424
+0.0
1425
+ 11
1426
+100.0
1427
+ 21
1428
+60.0
1429
+ 31
1430
+0.0
1431
+  0
1432
+LINE
1433
+  5
1434
+4A
1435
+100
1436
+AcDbEntity
1437
+100
1438
+AcDbLine
1439
+  8
1440
+pocket
1441
+ 62
1442
+256
1443
+370
1444
+-1
1445
+  6
1446
+ByLayer
1447
+ 10
1448
+40.0
1449
+ 20
1450
+30.0
1451
+ 30
1452
+0.0
1453
+ 11
1454
+40.0
1455
+ 21
1456
+60.0
1457
+ 31
1458
+0.0
1459
+  0
1460
+LINE
1461
+  5
1462
+4B
1463
+100
1464
+AcDbEntity
1465
+100
1466
+AcDbLine
1467
+  8
1468
+pocket
1469
+ 62
1470
+256
1471
+370
1472
+-1
1473
+  6
1474
+ByLayer
1475
+ 10
1476
+80.0
1477
+ 20
1478
+60.0
1479
+ 30
1480
+0.0
1481
+ 11
1482
+80.0
1483
+ 21
1484
+30.0
1485
+ 31
1486
+0.0
1487
+  0
1488
+LINE
1489
+  5
1490
+4C
1491
+100
1492
+AcDbEntity
1493
+100
1494
+AcDbLine
1495
+  8
1496
+pocket
1497
+ 62
1498
+256
1499
+370
1500
+-1
1501
+  6
1502
+ByLayer
1503
+ 10
1504
+80.0
1505
+ 20
1506
+30.0
1507
+ 30
1508
+0.0
1509
+ 11
1510
+40.0
1511
+ 21
1512
+30.0
1513
+ 31
1514
+0.0
1515
+  0
1516
+LINE
1517
+  5
1518
+4D
1519
+100
1520
+AcDbEntity
1521
+100
1522
+AcDbLine
1523
+  8
1524
+pocket
1525
+ 62
1526
+256
1527
+370
1528
+-1
1529
+  6
1530
+ByLayer
1531
+ 10
1532
+80.0
1533
+ 20
1534
+60.0
1535
+ 30
1536
+0.0
1537
+ 11
1538
+100.0
1539
+ 21
1540
+60.0
1541
+ 31
1542
+0.0
1543
+  0
1544
+LINE
1545
+  5
1546
+4E
1547
+100
1548
+AcDbEntity
1549
+100
1550
+AcDbLine
1551
+  8
1552
+0
1553
+ 62
1554
+256
1555
+370
1556
+-1
1557
+  6
1558
+ByLayer
1559
+ 10
1560
+110.0
1561
+ 20
1562
+10.0
1563
+ 30
1564
+0.0
1565
+ 11
1566
+10.0
1567
+ 21
1568
+10.0
1569
+ 31
1570
+0.0
1571
+  0
1572
+LINE
1573
+  5
1574
+4F
1575
+100
1576
+AcDbEntity
1577
+100
1578
+AcDbLine
1579
+  8
1580
+0
1581
+ 62
1582
+256
1583
+370
1584
+-1
1585
+  6
1586
+ByLayer
1587
+ 10
1588
+10.0
1589
+ 20
1590
+10.0
1591
+ 30
1592
+0.0
1593
+ 11
1594
+10.0
1595
+ 21
1596
+70.0
1597
+ 31
1598
+0.0
1599
+  0
1600
+LINE
1601
+  5
1602
+50
1603
+100
1604
+AcDbEntity
1605
+100
1606
+AcDbLine
1607
+  8
1608
+0
1609
+ 62
1610
+256
1611
+370
1612
+-1
1613
+  6
1614
+ByLayer
1615
+ 10
1616
+110.0
1617
+ 20
1618
+70.0
1619
+ 30
1620
+0.0
1621
+ 11
1622
+110.0
1623
+ 21
1624
+10.0
1625
+ 31
1626
+0.0
1627
+  0
1628
+CIRCLE
1629
+  5
1630
+51
1631
+100
1632
+AcDbEntity
1633
+100
1634
+AcDbCircle
1635
+  8
1636
+pocket
1637
+ 62
1638
+256
1639
+370
1640
+-1
1641
+  6
1642
+ByLayer
1643
+ 10
1644
+60.0
1645
+ 20
1646
+50.0
1647
+ 30
1648
+0.0
1649
+ 40
1650
+10.0
1651
+  0
1652
+LINE
1653
+  5
1654
+52
1655
+100
1656
+AcDbEntity
1657
+100
1658
+AcDbLine
1659
+  8
1660
+text
1661
+ 62
1662
+256
1663
+370
1664
+-1
1665
+  6
1666
+ByLayer
1667
+ 10
1668
+9.1666666666666572
1669
+ 20
1670
+80.0000000000000142
1671
+ 30
1672
+0.0
1673
+ 11
1674
+9.1666666666666572
1675
+ 21
1676
+100.0000000000000142
1677
+ 31
1678
+0.0
1679
+  0
1680
+LINE
1681
+  5
1682
+53
1683
+100
1684
+AcDbEntity
1685
+100
1686
+AcDbLine
1687
+  8
1688
+text
1689
+ 62
1690
+256
1691
+370
1692
+-1
1693
+  6
1694
+ByLayer
1695
+ 10
1696
+9.1666666666666572
1697
+ 20
1698
+100.0000000000000142
1699
+ 30
1700
+0.0
1701
+ 11
1702
+15.8333333333333286
1703
+ 21
1704
+88.8888888888888999
1705
+ 31
1706
+0.0
1707
+  0
1708
+LINE
1709
+  5
1710
+54
1711
+100
1712
+AcDbEntity
1713
+100
1714
+AcDbLine
1715
+  8
1716
+text
1717
+ 62
1718
+256
1719
+370
1720
+-1
1721
+  6
1722
+ByLayer
1723
+ 10
1724
+15.8333333333333286
1725
+ 20
1726
+88.8888888888888999
1727
+ 30
1728
+0.0
1729
+ 11
1730
+22.4999999999999858
1731
+ 21
1732
+100.0000000000000142
1733
+ 31
1734
+0.0
1735
+  0
1736
+LINE
1737
+  5
1738
+55
1739
+100
1740
+AcDbEntity
1741
+100
1742
+AcDbLine
1743
+  8
1744
+text
1745
+ 62
1746
+256
1747
+370
1748
+-1
1749
+  6
1750
+ByLayer
1751
+ 10
1752
+22.4999999999999858
1753
+ 20
1754
+100.0000000000000142
1755
+ 30
1756
+0.0
1757
+ 11
1758
+22.4999999999999858
1759
+ 21
1760
+80.0000000000000142
1761
+ 31
1762
+0.0
1763
+  0
1764
+LINE
1765
+  5
1766
+56
1767
+100
1768
+AcDbEntity
1769
+100
1770
+AcDbLine
1771
+  8
1772
+text
1773
+ 62
1774
+256
1775
+370
1776
+-1
1777
+  6
1778
+ByLayer
1779
+ 10
1780
+29.1666666666666572
1781
+ 20
1782
+100.0000000000000142
1783
+ 30
1784
+0.0
1785
+ 11
1786
+29.1666666666666572
1787
+ 21
1788
+80.0000000000000142
1789
+ 31
1790
+0.0
1791
+  0
1792
+LINE
1793
+  5
1794
+57
1795
+100
1796
+AcDbEntity
1797
+100
1798
+AcDbLine
1799
+  8
1800
+text
1801
+ 62
1802
+256
1803
+370
1804
+-1
1805
+  6
1806
+ByLayer
1807
+ 10
1808
+35.8333333333333286
1809
+ 20
1810
+100.0
1811
+ 30
1812
+0.0
1813
+ 11
1814
+35.8333333333333286
1815
+ 21
1816
+80.0
1817
+ 31
1818
+0.0
1819
+  0
1820
+LINE
1821
+  5
1822
+58
1823
+100
1824
+AcDbEntity
1825
+100
1826
+AcDbLine
1827
+  8
1828
+text
1829
+ 62
1830
+256
1831
+370
1832
+-1
1833
+  6
1834
+ByLayer
1835
+ 10
1836
+35.8333333333333286
1837
+ 20
1838
+80.0
1839
+ 30
1840
+0.0
1841
+ 11
1842
+44.7222222222222143
1843
+ 21
1844
+80.0
1845
+ 31
1846
+0.0
1847
+  0
1848
+LINE
1849
+  5
1850
+59
1851
+100
1852
+AcDbEntity
1853
+100
1854
+AcDbLine
1855
+  8
1856
+text
1857
+ 62
1858
+256
1859
+370
1860
+-1
1861
+  6
1862
+ByLayer
1863
+ 10
1864
+51.3888888888888715
1865
+ 20
1866
+100.0
1867
+ 30
1868
+0.0
1869
+ 11
1870
+51.3888888888888715
1871
+ 21
1872
+80.0
1873
+ 31
1874
+0.0
1875
+  0
1876
+LINE
1877
+  5
1878
+5A
1879
+100
1880
+AcDbEntity
1881
+100
1882
+AcDbLine
1883
+  8
1884
+text
1885
+ 62
1886
+256
1887
+370
1888
+-1
1889
+  6
1890
+ByLayer
1891
+ 10
1892
+51.3888888888888715
1893
+ 20
1894
+80.0
1895
+ 30
1896
+0.0
1897
+ 11
1898
+60.2777777777777573
1899
+ 21
1900
+80.0
1901
+ 31
1902
+0.0
1903
+  0
1904
+LINE
1905
+  5
1906
+5B
1907
+100
1908
+AcDbEntity
1909
+100
1910
+AcDbLine
1911
+  8
1912
+text
1913
+ 62
1914
+256
1915
+370
1916
+-1
1917
+  6
1918
+ByLayer
1919
+ 10
1920
+81.9444444444444571
1921
+ 20
1922
+80.0
1923
+ 30
1924
+0.0
1925
+ 11
1926
+81.9444444444444571
1927
+ 21
1928
+100.0
1929
+ 31
1930
+0.0
1931
+  0
1932
+LINE
1933
+  5
1934
+5C
1935
+100
1936
+AcDbEntity
1937
+100
1938
+AcDbLine
1939
+  8
1940
+text
1941
+ 62
1942
+256
1943
+370
1944
+-1
1945
+  6
1946
+ByLayer
1947
+ 10
1948
+81.9444444444444571
1949
+ 20
1950
+100.0
1951
+ 30
1952
+0.0
1953
+ 11
1954
+88.6111111111111143
1955
+ 21
1956
+88.8888888888888857
1957
+ 31
1958
+0.0
1959
+  0
1960
+LINE
1961
+  5
1962
+5D
1963
+100
1964
+AcDbEntity
1965
+100
1966
+AcDbLine
1967
+  8
1968
+text
1969
+ 62
1970
+256
1971
+370
1972
+-1
1973
+  6
1974
+ByLayer
1975
+ 10
1976
+88.6111111111111143
1977
+ 20
1978
+88.8888888888888857
1979
+ 30
1980
+0.0
1981
+ 11
1982
+95.2777777777777999
1983
+ 21
1984
+100.0
1985
+ 31
1986
+0.0
1987
+  0
1988
+LINE
1989
+  5
1990
+5E
1991
+100
1992
+AcDbEntity
1993
+100
1994
+AcDbLine
1995
+  8
1996
+text
1997
+ 62
1998
+256
1999
+370
2000
+-1
2001
+  6
2002
+ByLayer
2003
+ 10
2004
+95.2777777777777999
2005
+ 20
2006
+100.0
2007
+ 30
2008
+0.0
2009
+ 11
2010
+95.2777777777777999
2011
+ 21
2012
+80.0
2013
+ 31
2014
+0.0
2015
+  0
2016
+LINE
2017
+  5
2018
+5F
2019
+100
2020
+AcDbEntity
2021
+100
2022
+AcDbLine
2023
+  8
2024
+text
2025
+ 62
2026
+256
2027
+370
2028
+-1
2029
+  6
2030
+ByLayer
2031
+ 10
2032
+110.8333333333333428
2033
+ 20
2034
+100.0
2035
+ 30
2036
+0.0
2037
+ 11
2038
+101.9444444444444571
2039
+ 21
2040
+100.0
2041
+ 31
2042
+0.0
2043
+  0
2044
+LINE
2045
+  5
2046
+60
2047
+100
2048
+AcDbEntity
2049
+100
2050
+AcDbLine
2051
+  8
2052
+text
2053
+ 62
2054
+256
2055
+370
2056
+-1
2057
+  6
2058
+ByLayer
2059
+ 10
2060
+101.9444444444444571
2061
+ 20
2062
+100.0
2063
+ 30
2064
+0.0
2065
+ 11
2066
+101.9444444444444571
2067
+ 21
2068
+80.0
2069
+ 31
2070
+0.0
2071
+  0
2072
+LINE
2073
+  5
2074
+61
2075
+100
2076
+AcDbEntity
2077
+100
2078
+AcDbLine
2079
+  8
2080
+text
2081
+ 62
2082
+256
2083
+370
2084
+-1
2085
+  6
2086
+ByLayer
2087
+ 10
2088
+101.9444444444444571
2089
+ 20
2090
+80.0
2091
+ 30
2092
+0.0
2093
+ 11
2094
+110.8333333333333428
2095
+ 21
2096
+80.0
2097
+ 31
2098
+0.0
2099
+  0
2100
+LINE
2101
+  5
2102
+62
2103
+100
2104
+AcDbEntity
2105
+100
2106
+AcDbLine
2107
+  8
2108
+text
2109
+ 62
2110
+256
2111
+370
2112
+-1
2113
+  6
2114
+ByLayer
2115
+ 10
2116
+101.9444444444444571
2117
+ 20
2118
+91.1111111111111143
2119
+ 30
2120
+0.0
2121
+ 11
2122
+108.6111111111111143
2123
+ 21
2124
+91.1111111111111143
2125
+ 31
2126
+0.0
2127
+  0
2128
+ENDSEC
2129
+  0
2130
+SECTION
2131
+  2
2132
+OBJECTS
2133
+  0
2134
+DICTIONARY
2135
+  5
2136
+C
2137
+100
2138
+AcDbDictionary
2139
+280
2140
+0
2141
+281
2142
+1
2143
+  3
2144
+ACAD_GROUP
2145
+350
2146
+D
2147
+  3
2148
+ACAD_LAYOUT
2149
+350
2150
+1A
2151
+  3
2152
+ACAD_MLINESTYLE
2153
+350
2154
+17
2155
+  3
2156
+ACAD_PLOTSETTINGS
2157
+350
2158
+19
2159
+  3
2160
+ACAD_PLOTSTYLENAME
2161
+350
2162
+E
2163
+  3
2164
+AcDbVariableDictionary
2165
+350
2166
+63
2167
+  0
2168
+DICTIONARY
2169
+  5
2170
+D
2171
+100
2172
+AcDbDictionary
2173
+280
2174
+0
2175
+281
2176
+1
2177
+  0
2178
+ACDBDICTIONARYWDFLT
2179
+  5
2180
+E
2181
+100
2182
+AcDbDictionary
2183
+281
2184
+1
2185
+  3
2186
+Normal
2187
+350
2188
+F
2189
+100
2190
+AcDbDictionaryWithDefault
2191
+340
2192
+F
2193
+  0
2194
+ACDBPLACEHOLDER
2195
+  5
2196
+F
2197
+  0
2198
+DICTIONARY
2199
+  5
2200
+17
2201
+100
2202
+AcDbDictionary
2203
+280
2204
+0
2205
+281
2206
+1
2207
+  3
2208
+Standard
2209
+350
2210
+18
2211
+  0
2212
+MLINESTYLE
2213
+  5
2214
+18
2215
+100
2216
+AcDbMlineStyle
2217
+  2
2218
+STANDARD
2219
+ 70
2220
+0
2221
+  3
2222
+
2223
+ 62
2224
+256
2225
+ 51
2226
+90.0
2227
+ 52
2228
+90.0
2229
+ 71
2230
+2
2231
+ 49
2232
+0.5
2233
+ 62
2234
+256
2235
+  6
2236
+BYLAYER
2237
+ 49
2238
+-0.5
2239
+ 62
2240
+256
2241
+  6
2242
+BYLAYER
2243
+  0
2244
+DICTIONARY
2245
+  5
2246
+19
2247
+100
2248
+AcDbDictionary
2249
+280
2250
+0
2251
+281
2252
+1
2253
+  0
2254
+DICTIONARY
2255
+  5
2256
+1A
2257
+100
2258
+AcDbDictionary
2259
+281
2260
+1
2261
+  3
2262
+Layout1
2263
+350
2264
+1E
2265
+  3
2266
+Layout2
2267
+350
2268
+26
2269
+  3
2270
+Model
2271
+350
2272
+22
2273
+  0
2274
+LAYOUT
2275
+  5
2276
+1E
2277
+100
2278
+AcDbPlotSettings
2279
+  1
2280
+
2281
+  2
2282
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
2283
+  4
2284
+
2285
+  6
2286
+
2287
+ 40
2288
+0.0
2289
+ 41
2290
+0.0
2291
+ 42
2292
+0.0
2293
+ 43
2294
+0.0
2295
+ 44
2296
+0.0
2297
+ 45
2298
+0.0
2299
+ 46
2300
+0.0
2301
+ 47
2302
+0.0
2303
+ 48
2304
+0.0
2305
+ 49
2306
+0.0
2307
+140
2308
+0.0
2309
+141
2310
+0.0
2311
+142
2312
+1.0
2313
+143
2314
+1.0
2315
+ 70
2316
+688
2317
+ 72
2318
+0
2319
+ 73
2320
+0
2321
+ 74
2322
+5
2323
+  7
2324
+
2325
+ 75
2326
+16
2327
+147
2328
+1.0
2329
+148
2330
+0.0
2331
+149
2332
+0.0
2333
+100
2334
+AcDbLayout
2335
+  1
2336
+Layout1
2337
+ 70
2338
+1
2339
+ 71
2340
+1
2341
+ 10
2342
+0.0
2343
+ 20
2344
+0.0
2345
+ 11
2346
+420.0
2347
+ 21
2348
+297.0
2349
+ 12
2350
+0.0
2351
+ 22
2352
+0.0
2353
+ 32
2354
+0.0
2355
+ 14
2356
+100000000000000000000.0
2357
+ 24
2358
+100000000000000000000.0
2359
+ 34
2360
+100000000000000000000.0
2361
+ 15
2362
+-100000000000000000000.0
2363
+ 25
2364
+-100000000000000000000.0
2365
+ 35
2366
+-100000000000000000000.0
2367
+146
2368
+0.0
2369
+ 13
2370
+0.0
2371
+ 23
2372
+0.0
2373
+ 33
2374
+0.0
2375
+ 16
2376
+1.0
2377
+ 26
2378
+0.0
2379
+ 36
2380
+0.0
2381
+ 17
2382
+0.0
2383
+ 27
2384
+1.0
2385
+ 37
2386
+0.0
2387
+ 76
2388
+0
2389
+330
2390
+1B
2391
+  0
2392
+LAYOUT
2393
+  5
2394
+22
2395
+100
2396
+AcDbPlotSettings
2397
+  1
2398
+
2399
+  2
2400
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
2401
+  4
2402
+
2403
+  6
2404
+
2405
+ 40
2406
+0.0
2407
+ 41
2408
+0.0
2409
+ 42
2410
+0.0
2411
+ 43
2412
+0.0
2413
+ 44
2414
+0.0
2415
+ 45
2416
+0.0
2417
+ 46
2418
+0.0
2419
+ 47
2420
+0.0
2421
+ 48
2422
+0.0
2423
+ 49
2424
+0.0
2425
+140
2426
+0.0
2427
+141
2428
+0.0
2429
+142
2430
+1.0
2431
+143
2432
+1.0
2433
+ 70
2434
+1712
2435
+ 72
2436
+0
2437
+ 73
2438
+0
2439
+ 74
2440
+0
2441
+  7
2442
+
2443
+ 75
2444
+0
2445
+147
2446
+1.0
2447
+148
2448
+0.0
2449
+149
2450
+0.0
2451
+100
2452
+AcDbLayout
2453
+  1
2454
+Model
2455
+ 70
2456
+1
2457
+ 71
2458
+0
2459
+ 10
2460
+0.0
2461
+ 20
2462
+0.0
2463
+ 11
2464
+12.0
2465
+ 21
2466
+9.0
2467
+ 12
2468
+0.0
2469
+ 22
2470
+0.0
2471
+ 32
2472
+0.0
2473
+ 14
2474
+0.0
2475
+ 24
2476
+0.0
2477
+ 34
2478
+0.0
2479
+ 15
2480
+0.0
2481
+ 25
2482
+0.0
2483
+ 35
2484
+0.0
2485
+146
2486
+0.0
2487
+ 13
2488
+0.0
2489
+ 23
2490
+0.0
2491
+ 33
2492
+0.0
2493
+ 16
2494
+1.0
2495
+ 26
2496
+0.0
2497
+ 36
2498
+0.0
2499
+ 17
2500
+0.0
2501
+ 27
2502
+1.0
2503
+ 37
2504
+0.0
2505
+ 76
2506
+0
2507
+330
2508
+1F
2509
+  0
2510
+LAYOUT
2511
+  5
2512
+26
2513
+100
2514
+AcDbPlotSettings
2515
+  1
2516
+
2517
+  2
2518
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
2519
+  4
2520
+
2521
+  6
2522
+
2523
+ 40
2524
+0.0
2525
+ 41
2526
+0.0
2527
+ 42
2528
+0.0
2529
+ 43
2530
+0.0
2531
+ 44
2532
+0.0
2533
+ 45
2534
+0.0
2535
+ 46
2536
+0.0
2537
+ 47
2538
+0.0
2539
+ 48
2540
+0.0
2541
+ 49
2542
+0.0
2543
+140
2544
+0.0
2545
+141
2546
+0.0
2547
+142
2548
+1.0
2549
+143
2550
+1.0
2551
+ 70
2552
+688
2553
+ 72
2554
+0
2555
+ 73
2556
+0
2557
+ 74
2558
+5
2559
+  7
2560
+
2561
+ 75
2562
+16
2563
+147
2564
+1.0
2565
+148
2566
+0.0
2567
+149
2568
+0.0
2569
+100
2570
+AcDbLayout
2571
+  1
2572
+Layout2
2573
+ 70
2574
+1
2575
+ 71
2576
+2
2577
+ 10
2578
+0.0
2579
+ 20
2580
+0.0
2581
+ 11
2582
+12.0
2583
+ 21
2584
+9.0
2585
+ 12
2586
+0.0
2587
+ 22
2588
+0.0
2589
+ 32
2590
+0.0
2591
+ 14
2592
+0.0
2593
+ 24
2594
+0.0
2595
+ 34
2596
+0.0
2597
+ 15
2598
+0.0
2599
+ 25
2600
+0.0
2601
+ 35
2602
+0.0
2603
+146
2604
+0.0
2605
+ 13
2606
+0.0
2607
+ 23
2608
+0.0
2609
+ 33
2610
+0.0
2611
+ 16
2612
+1.0
2613
+ 26
2614
+0.0
2615
+ 36
2616
+0.0
2617
+ 17
2618
+0.0
2619
+ 27
2620
+1.0
2621
+ 37
2622
+0.0
2623
+ 76
2624
+0
2625
+330
2626
+23
2627
+  0
2628
+DICTIONARY
2629
+  5
2630
+63
2631
+100
2632
+AcDbDictionary
2633
+281
2634
+1
2635
+  3
2636
+DIMASSOC
2637
+350
2638
+65
2639
+  3
2640
+HIDETEXT
2641
+350
2642
+64
2643
+  0
2644
+DICTIONARYVAR
2645
+  5
2646
+64
2647
+100
2648
+DictionaryVariables
2649
+280
2650
+0
2651
+  1
2652
+2
2653
+  0
2654
+DICTIONARYVAR
2655
+  5
2656
+65
2657
+100
2658
+DictionaryVariables
2659
+280
2660
+0
2661
+  1
2662
+1
2663
+  0
2664
+ENDSEC
2665
+  0
2666
+EOF
... ...
@@ -0,0 +1,25 @@
1
+cmd G21
2
+cmd G90
3
+cmd G64 P0.01
4
+cmd G17
5
+cmd G40
6
+cmd G49
7
+
8
+set_tool_diameter 3
9
+set_move_z 3
10
+set_base_z 0
11
+set_cut_z -2
12
+set_cut_z_step 1
13
+set_feed_drill 100
14
+set_feed_mill 200
15
+
16
+read_dxf millme.dxf
17
+
18
+cut 0
19
+#cut_pocket pocket
20
+cut text
21
+
22
+cmd M2
23
+
24
+write_ngc millme.ngc
25
+
... ...
@@ -0,0 +1,368 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <fstream>
7
+#include <iostream>
8
+#include <sstream>
9
+#include <string>
10
+
11
+#include "cmdparser.h"
12
+#include "drawing.h"
13
+#include "filename.h"
14
+#include "gcode.h"
15
+#include "settings.h"
16
+
17
+/**
18
+ * @brief process cmd command
19
+ * @param[in] strm stream to read command arguments from
20
+ * @return if processing command was successful
21
+ */
22
+bool CmdParser::procCmd_cmd(std::istream &strm)
23
+{
24
+  // skip whitespace and use rest of line as custom command
25
+  strm >> std::ws;
26
+  std::string cmd;
27
+  getline(strm, cmd);
28
+
29
+  // add custom command to G-code
30
+  mGCode.appendCustom(cmd);
31
+
32
+  return true;
33
+}
34
+
35
+/**
36
+ * @brief process cut command
37
+ * @param[in] strm stream to read command arguments from
38
+ * @return if processing command was successful
39
+ */
40
+bool CmdParser::procCmd_cut(std::istream &strm)
41
+{
42
+  // get arguments
43
+  std::string layerName;
44
+  strm >> layerName;
45
+  if (strm.fail()) {
46
+    std::cerr << "missing layer name" << std::endl;
47
+    return false;
48
+  }
49
+
50
+  // get layer
51
+  Drawing::Layers::const_iterator layer = mDrawing.mLayers.find(layerName);
52
+  if (layer == mDrawing.mLayers.end()) {
53
+    std::cerr << "layer \"" << layerName << "\" not found" << std::endl;
54
+    return false;
55
+  }
56
+
57
+  // convert layer to G-code
58
+  layer->second.toGCode(mSettings, mGCode);
59
+
60
+  return true;
61
+}
62
+
63
+/**
64
+ * @brief process read_dxf command
65
+ * @param[in] strm stream to read command arguments from
66
+ * @return if processing command was successful
67
+ */
68
+bool CmdParser::procCmd_read_dxf(std::istream &strm)
69
+{
70
+  // get arguments
71
+  std::string fileName;
72
+  strm >> fileName;
73
+  if (strm.fail()) {
74
+    std::cerr << "missing DXF file name" << std::endl;
75
+    return false;
76
+  }
77
+
78
+  // re-base DXF file name
79
+  fileName = filename_rebase(fileName, mBaseDir);
80
+
81
+  // read DXF file
82
+  if (!mDrawing.loadDxf(fileName)) {
83
+    std::cerr << "could not read DXF file \"" << fileName << "\""
84
+              << std::endl;
85
+    return false;
86
+  }
87
+
88
+  return true;
89
+}
90
+
91
+/**
92
+ * @brief process set_base_z command
93
+ * @param[in] strm stream to read command arguments from
94
+ * @return if processing command was successful
95
+ */
96
+bool CmdParser::procCmd_set_base_z(std::istream &strm)
97
+{
98
+  // get arguments
99
+  double z;
100
+  strm >> z;
101
+  if (strm.fail()) {
102
+    std::cerr << "missing z coordinate" << std::endl;
103
+    return false;
104
+  }
105
+
106
+  // update settings
107
+  mSettings.base_z = z;
108
+  return true;
109
+}
110
+
111
+/**
112
+ * @brief process set_cut_z command
113
+ * @param[in] strm stream to read command arguments from
114
+ * @return if processing command was successful
115
+ */
116
+bool CmdParser::procCmd_set_cut_z(std::istream &strm)
117
+{
118
+  // get arguments
119
+  double z;
120
+  strm >> z;
121
+  if (strm.fail()) {
122
+    std::cerr << "missing z coordinate" << std::endl;
123
+    return false;
124
+  }
125
+
126
+  // update settings
127
+  mSettings.cut_z = z;
128
+  return true;
129
+}
130
+
131
+/**
132
+ * @brief process set_cut_z_step command
133
+ * @param[in] strm stream to read command arguments from
134
+ * @return if processing command was successful
135
+ */
136
+bool CmdParser::procCmd_set_cut_z_step(std::istream &strm)
137
+{
138
+  // get arguments and check them
139
+  double z;
140
+  strm >> z;
141
+  if (strm.fail()) {
142
+    std::cerr << "missing z value" << std::endl;
143
+    return false;
144
+  }
145
+  if (z <= 0.0) {
146
+    std::cerr << "invalid z cut step value (" << z << ")" << std::endl;
147
+    return false;
148
+  }
149
+
150
+  // update settings
151
+  mSettings.cut_z_step = z;
152
+  return true;
153
+}
154
+
155
+/**
156
+ * @brief process set_feed_drill command
157
+ * @param[in] strm stream to read command arguments from
158
+ * @return if processing command was successful
159
+ */
160
+bool CmdParser::procCmd_set_feed_drill(std::istream &strm)
161
+{
162
+  // get arguments and check them
163
+  double feed;
164
+  strm >> feed;
165
+  if (strm.fail()) {
166
+    std::cerr << "missing feed rate" << std::endl;
167
+    return false;
168
+  }
169
+  if (feed <= 0.0) {
170
+    std::cerr << "invalid feed rate (" << feed << ")" << std::endl;
171
+    return false;
172
+  }
173
+
174
+  // update settings
175
+  mSettings.feed_drill = feed;
176
+  return true;
177
+}
178
+
179
+/**
180
+ * @brief process set_feed_mill command
181
+ * @param[in] strm stream to read command arguments from
182
+ * @return if processing command was successful
183
+ */
184
+bool CmdParser::procCmd_set_feed_mill(std::istream &strm)
185
+{
186
+  // get arguments and check them
187
+  double feed;
188
+  strm >> feed;
189
+  if (strm.fail()) {
190
+    std::cerr << "missing feed rate" << std::endl;
191
+    return false;
192
+  }
193
+  if (feed <= 0.0) {
194
+    std::cerr << "invalid feed rate (" << feed << ")" << std::endl;
195
+    return false;
196
+  }
197
+
198
+  // update settings
199
+  mSettings.feed_mill = feed;
200
+  return true;
201
+}
202
+
203
+/**
204
+ * @brief process set_move_z command
205
+ * @param[in] strm stream to read command arguments from
206
+ * @return if processing command was successful
207
+ */
208
+bool CmdParser::procCmd_set_move_z(std::istream &strm)
209
+{
210
+  // get arguments
211
+  double z;
212
+  strm >> z;
213
+  if (strm.fail()) {
214
+    std::cerr << "missing z coordinate" << std::endl;
215
+    return false;
216
+  }
217
+
218
+  // update settings
219
+  mSettings.move_z = z;
220
+  return true;
221
+}
222
+
223
+/**
224
+ * @brief process set_tool_diameter command
225
+ * @param[in] strm stream to read command arguments from
226
+ * @return if processing command was successful
227
+ */
228
+bool CmdParser::procCmd_set_tool_diameter(std::istream &strm)
229
+{
230
+  // get arguments and check them
231
+  double diameter;
232
+  strm >> diameter;
233
+  if (strm.fail()) {
234
+    std::cerr << "missing tool diameter" << std::endl;
235
+    return false;
236
+  }
237
+  if (diameter < 0.0) {
238
+    std::cerr << "invalid tool diameter (" << diameter << ")" << std::endl;
239
+    return false;
240
+  }
241
+
242
+  // update settings
243
+  mSettings.tool_diameter = diameter;
244
+  return true;
245
+}
246
+
247
+/**
248
+ * @brief process write_ngc command
249
+ * @param[in] strm stream to read command arguments from
250
+ * @return if processing command was successful
251
+ */
252
+bool CmdParser::procCmd_write_ngc(std::istream &strm)
253
+{
254
+  // get arguments
255
+  std::string fileName;
256
+  strm >> fileName;
257
+  if (strm.fail()) {
258
+    std::cerr << "missing NGC file name" << std::endl;
259
+    return false;
260
+  }
261
+
262
+  // re-base NGC file name
263
+  fileName = filename_rebase(fileName, mBaseDir);
264
+
265
+  // write NGC file
266
+  if (!mGCode.toFile(fileName)) {
267
+    std::cerr << "could not write NGC file \"" << fileName << "\""
268
+              << std::endl;
269
+    return false;
270
+  }
271
+
272
+  return true;
273
+}
274
+
275
+/**
276
+ * @brief process command from line of text
277
+ * @param[in] strLine line containing command to process
278
+ * @return if processing command was successful
279
+ */
280
+bool CmdParser::procLine(const std::string &strLine)
281
+{
282
+  std::stringstream strm(strLine);
283
+
284
+  // read command
285
+  std::string cmd;
286
+  strm >> cmd;
287
+  if (strm.fail())
288
+    return true; // ignore empty lines
289
+
290
+  // commands
291
+  if (cmd == "cmd")
292
+    return procCmd_cmd(strm);
293
+  else if (cmd == "cut")
294
+    return procCmd_cut(strm);
295
+  else if (cmd == "read_dxf")
296
+    return procCmd_read_dxf(strm);
297
+  else if (cmd == "set_base_z")
298
+    return procCmd_set_base_z(strm);
299
+  else if (cmd == "set_cut_z")
300
+    return procCmd_set_cut_z(strm);
301
+  else if (cmd == "set_cut_z_step")
302
+    return procCmd_set_cut_z_step(strm);
303
+  else if (cmd == "set_feed_drill")
304
+    return procCmd_set_feed_drill(strm);
305
+  else if (cmd == "set_feed_mill")
306
+    return procCmd_set_feed_mill(strm);
307
+  else if (cmd == "set_move_z")
308
+    return procCmd_set_move_z(strm);
309
+  else if (cmd == "set_tool_diameter")
310
+    return procCmd_set_tool_diameter(strm);
311
+  else if (cmd == "write_ngc")
312
+    return procCmd_write_ngc(strm);
313
+  else {
314
+    std::cerr << "unknown command \"" << cmd << "\"" << std::endl;
315
+    return false;
316
+  }
317
+}
318
+
319
+/**
320
+ * @brief process commands from a stream
321
+ * @param[in] strm stream to process
322
+ * @param[in] if processing stream was successful
323
+ * @return if processing commands was successful
324
+ */
325
+bool CmdParser::procStream(std::istream &strm)
326
+{
327
+  unsigned int lineNo = 0;
328
+  while (strm.good()) {
329
+
330
+    // read line, remove comment
331
+    std::string line;
332
+    std::getline(strm, line);
333
+    std::string::size_type pos = line.find_first_of("#;");
334
+    if (pos != std::string::npos)
335
+      line.erase(pos);
336
+    lineNo++;
337
+
338
+    // process line
339
+    if (!procLine(line)) {
340
+      std::cerr << "error processing command in line " << lineNo << std::endl;
341
+      return false;
342
+    }
343
+
344
+  }
345
+  return true;
346
+}
347
+
348
+/**
349
+ * @brief process commands from a file
350
+ * @param[in] strFileName name of file to process
351
+ * @param[in] if processing the file was successful
352
+ * @return if processing commands was successful
353
+ */
354
+bool CmdParser::procFile(const std::string &strFileName)
355
+{
356
+  std::ifstream ifstrm(strFileName.c_str(), std::ios::in);
357
+  if (!ifstrm.is_open()) {
358
+    std::cerr << "could not open \"" << strFileName << "\" for reading"
359
+              << std::endl;
360
+    return false;
361
+  }
362
+
363
+  mBaseDir = filename_get_dir(strFileName);
364
+  bool ret = procStream(ifstrm);
365
+  mBaseDir.clear();
366
+  return ret;
367
+}
368
+
... ...
@@ -0,0 +1,127 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef CMDPARSER_H
7
+#define CMDPARSER_H
8
+
9
+#include <iostream>
10
+#include <string>
11
+
12
+#include "gcode.h"
13
+#include "drawing.h"
14
+#include "settings.h"
15
+
16
+/// command parser
17
+class CmdParser {
18
+public:
19
+  /**
20
+   * @brief process cmd command
21
+   * @param[in] strm stream to read command arguments from
22
+   * @return if processing command was successful
23
+   */
24
+  bool procCmd_cmd(std::istream &strm);
25
+
26
+  /**
27
+   * @brief process cut command
28
+   * @param[in] strm stream to read command arguments from
29
+   * @return if processing command was successful
30
+   */
31
+  bool procCmd_cut(std::istream &strm);
32
+
33
+  /**
34
+   * @brief process read_dxf command
35
+   * @param[in] strm stream to read command arguments from
36
+   * @return if processing command was successful
37
+   */
38
+  bool procCmd_read_dxf(std::istream &strm);
39
+
40
+  /**
41
+   * @brief process set_base_z command
42
+   * @param[in] strm stream to read command arguments from
43
+   * @return if processing command was successful
44
+   */
45
+  bool procCmd_set_base_z(std::istream &strm);
46
+
47
+  /**
48
+   * @brief process set_cut_z command
49
+   * @param[in] strm stream to read command arguments from
50
+   * @return if processing command was successful
51
+   */
52
+  bool procCmd_set_cut_z(std::istream &strm);
53
+
54
+  /**
55
+   * @brief process set_cut_z_step command
56
+   * @param[in] strm stream to read command arguments from
57
+   * @return if processing command was successful
58
+   */
59
+  bool procCmd_set_cut_z_step(std::istream &strm);
60
+
61
+  /**
62
+   * @brief process set_feed_drill command
63
+   * @param[in] strm stream to read command arguments from
64
+   * @return if processing command was successful
65
+   */
66
+  bool procCmd_set_feed_drill(std::istream &strm);
67
+
68
+  /**
69
+   * @brief process set_feed_mill command
70
+   * @param[in] strm stream to read command arguments from
71
+   * @return if processing command was successful
72
+   */
73
+  bool procCmd_set_feed_mill(std::istream &strm);
74
+
75
+  /**
76
+   * @brief process set_move_z command
77
+   * @param[in] strm stream to read command arguments from
78
+   * @return if processing command was successful
79
+   */
80
+  bool procCmd_set_move_z(std::istream &strm);
81
+
82
+  /**
83
+   * @brief process set_tool_diameter command
84
+   * @param[in] strm stream to read command arguments from
85
+   * @return if processing command was successful
86
+   */
87
+  bool procCmd_set_tool_diameter(std::istream &strm);
88
+
89
+  /**
90
+   * @brief process write_ngc command
91
+   * @param[in] strm stream to read command arguments from
92
+   * @return if processing command was successful
93
+   */
94
+  bool procCmd_write_ngc(std::istream &strm);
95
+
96
+  /**
97
+   * @brief process command from line of text
98
+   * @param[in] strLine line containing command to process
99
+   * @return if processing command was successful
100
+   */
101
+  bool procLine(const std::string &strLine);
102
+
103
+  /**
104
+   * @brief process commands from a stream
105
+   * @param[in] strm stream to process
106
+   * @param[in] if processing stream was successful
107
+   * @return if processing commands was successful
108
+   */
109
+  bool procStream(std::istream &strm);
110
+
111
+  /**
112
+   * @brief process commands from a file
113
+   * @param[in] strFileName name of file to process
114
+   * @param[in] if processing the file was successful
115
+   * @return if processing commands was successful
116
+   */
117
+  bool procFile(const std::string &strFileName);
118
+
119
+  std::string mBaseDir; ///< base directory taken from name of file
120
+
121
+  Settings mSettings; ///< settings for G-code generation
122
+  Drawing  mDrawing;  ///< current drawing
123
+  GCode    mGCode;    ///< G-code created so far
124
+};
125
+
126
+#endif // #ifndef CMDPARSER_H
127
+
... ...
@@ -0,0 +1,64 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <dime/Input.h>
7
+#include <dime/Model.h>
8
+#include <iostream>
9
+#include <map>
10
+#include <string>
11
+
12
+#include "drawing.h"
13
+#include "layer.h"
14
+#include "traverse.h"
15
+
16
+/**
17
+ * @brief clear all contents of drawing
18
+ */
19
+void Drawing::clear()
20
+{
21
+  mLayers.clear();
22
+}
23
+
24
+/**
25
+ * @brief add a DXF file to this drawing
26
+ * @param[in] strFileName name of the DXF file to read
27
+ * @return if the DXF file could be read
28
+ */
29
+bool Drawing::addDxf(const std::string &strFileName)
30
+{
31
+  // read DXF file
32
+  dimeInput in;
33
+  if (!in.setFile(strFileName.c_str())) {
34
+    std::cerr << "error opening file \"" << strFileName
35
+              << "\" for reading" << std::endl;
36
+    return false;
37
+  }
38
+  dimeModel model;
39
+  if (!model.read(&in)) {
40
+    std::cerr << "DXF read error in line " << in.getFilePosition()
41
+              << " of file \"" << strFileName << "\""
42
+              << std::endl;
43
+    return false;
44
+  }
45
+
46
+  // enumerate all entities and add them to drawing
47
+  struct traverse_ctx ctx;
48
+  ctx.mpDrawing = this;
49
+  model.traverseEntities(traverse_entity, &ctx);
50
+
51
+  return true;
52
+}
53
+
54
+/**
55
+ * @brief load a DXF file to this drawing
56
+ * @param[in] strFileName name of the DXF file to read
57
+ * @return if the DXF file could be read
58
+ */
59
+bool Drawing::loadDxf(const std::string &strFileName)
60
+{
61
+  clear();
62
+  return addDxf(strFileName);
63
+}
64
+
... ...
@@ -0,0 +1,43 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef DRAWING_H
7
+#define DRAWING_H
8
+
9
+#include <map>
10
+#include <string>
11
+
12
+#include "layer.h"
13
+
14
+/// drawing, e.g. a loaded DXF file
15
+class Drawing {
16
+public:
17
+  /// type for layers in drawing (key: layer name, value: layer)
18
+  typedef std::map<std::string, Layer> Layers;
19
+
20
+  /**
21
+   * @brief clear all contents of drawing
22
+   */
23
+  void clear();
24
+
25
+  /**
26
+   * @brief add a DXF file to this drawing
27
+   * @param[in] strFileName name of the DXF file to read
28
+   * @return if the DXF file could be read
29
+   */
30
+  bool addDxf(const std::string &strFileName);
31
+
32
+  /**
33
+   * @brief load a DXF file to this drawing
34
+   * @param[in] strFileName name of the DXF file to read
35
+   * @return if the DXF file could be read
36
+   */
37
+  bool loadDxf(const std::string &strFileName);
38
+
39
+  Layers mLayers; ///< layers in drawing
40
+};
41
+
42
+#endif // #ifndef DRAWING_H
43
+
... ...
@@ -0,0 +1,44 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+
7
+#include <string>
8
+
9
+#include "filename.h"
10
+
11
+/**
12
+ * @brief get directory part of path
13
+ * @param[in] path full absolute or relative path
14
+ * @return directory part of file name, ending with a slash or empty
15
+ */
16
+std::string filename_get_dir(const std::string &path)
17
+{
18
+  // search last slash
19
+  std::string::size_type ls = path.rfind('/');
20
+
21
+  // no slash -> empty directory part
22
+  if (ls == std::string::npos)
23
+    return "";
24
+
25
+  // return everything including the slash
26
+  return path.substr(0, ls + 1);
27
+}
28
+
29
+/**
30
+ * @brief re-base path
31
+ * @param[in] path full absolute or relative path to re-base
32
+ * @param[in] base base dir to re-base path to, ending with a slash or empty
33
+ * @return re-based path
34
+ */
35
+std::string filename_rebase(const std::string &path, const std::string &base)
36
+{
37
+  // path is absolute -> do not change it
38
+  if (path.length() >= 1 && path.at(0) == '/')
39
+    return path;
40
+
41
+  // prepend base directory to path
42
+  return base + path;
43
+}
44
+
... ...
@@ -0,0 +1,27 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef FILENAME_H
7
+#define FILENAME_H
8
+
9
+#include <string>
10
+
11
+/**
12
+ * @brief get directory part of path
13
+ * @param[in] path full absolute or relative path
14
+ * @return directory part of file name, ending with a slash or empty
15
+ */
16
+std::string filename_get_dir(const std::string &path);
17
+
18
+/**
19
+ * @brief re-base path
20
+ * @param[in] path full absolute or relative path to re-base
21
+ * @param[in] base base dir to re-base path to, ending with a slash or empty
22
+ * @return re-based path
23
+ */
24
+std::string filename_rebase(const std::string &path, const std::string &base);
25
+
26
+#endif // #ifndef FILENAME_H
27
+
... ...
@@ -0,0 +1,14 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+
8
+#include "gcmd.h"
9
+
10
+/// virtual destructor
11
+GCmd::~GCmd()
12
+{
13
+}
14
+
... ...
@@ -0,0 +1,22 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GCMD_H
7
+#define GCMD_H
8
+
9
+#include <iostream>
10
+
11
+/// G-code command
12
+class GCmd {
13
+public:
14
+  /// virtual destructor
15
+  virtual ~GCmd();
16
+
17
+  /// output G-code command to stream
18
+  virtual void toStrm(std::ostream &strm) const = 0;
19
+};
20
+
21
+#endif // #ifndef GCMD_H
22
+
... ...
@@ -0,0 +1,128 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <fstream>
7
+#include <iostream>
8
+#include <string>
9
+#include <vector>
10
+
11
+#include "gcmd.h"
12
+#include "gcode.h"
13
+#include "gcustom.h"
14
+#include "gfast.h"
15
+#include "gfeed.h"
16
+#include "glinear.h"
17
+#include "point.h"
18
+
19
+/// consturctor
20
+GCode::GCode()
21
+{
22
+}
23
+
24
+/// destructor
25
+GCode::~GCode()
26
+{
27
+  GCmds::const_iterator gcmd;
28
+  for (gcmd = mGCmds.begin(); gcmd != mGCmds.end(); ++gcmd)
29
+    delete *gcmd;
30
+}
31
+
32
+/**
33
+ * @brief append fast move up command
34
+ * @param[in] z z coordinate to move up to
35
+ */
36
+void GCode::appendUp(double z)
37
+{
38
+  GFast *up = new GFast;
39
+  up->mZ.set(z);
40
+  mGCmds.push_back(up);
41
+}
42
+
43
+/**
44
+ * @brief append fast move command
45
+ * @param[in] pt point to move to
46
+ */
47
+void GCode::appendFast(const Point &pt)
48
+{
49
+  GFast *fast = new GFast;
50
+  fast->mX.set(pt.mX);
51
+  fast->mY.set(pt.mY);
52
+  mGCmds.push_back(fast);
53
+}
54
+
55
+/**
56
+ * @brief append set feed rate command
57
+ * @param[in] feed feed rate
58
+ */
59
+void GCode::appendFeed(double feed)
60
+{
61
+  GFeed *gfeed = new GFeed;
62
+  gfeed->mFeed = feed;
63
+  mGCmds.push_back(gfeed);
64
+}
65
+
66
+/**
67
+ * @brief append linear cut down command
68
+ * @param[in] z z coordinate to cut down to
69
+ */
70
+void GCode::appendDown(double z)
71
+{
72
+  GLinear *down = new GLinear;
73
+  down->mZ.set(z);
74
+  mGCmds.push_back(down);
75
+}
76
+
77
+/**
78
+ * @brief append linear cut command
79
+ * @param[in] pt point to cut to
80
+ */
81
+void GCode::appendLinear(const Point &pt)
82
+{
83
+  GLinear *linear = new GLinear;
84
+  linear->mX.set(pt.mX);
85
+  linear->mY.set(pt.mY);
86
+  mGCmds.push_back(linear);
87
+}
88
+
89
+/**
90
+ * @brief append custom command
91
+ * @param[in] cmd custom command to append
92
+ */
93
+void GCode::appendCustom(const std::string &cmd)
94
+{
95
+  GCustom *custom = new GCustom;
96
+  custom->mCmd = cmd;
97
+  mGCmds.push_back(custom);
98
+}
99
+
100
+/**
101
+ * @brief output G-code to stream
102
+ * @param[in] strm stream to write G-code to
103
+ */
104
+void GCode::toStrm(std::ostream &strm) const
105
+{
106
+  GCmds::const_iterator gcmd;
107
+  for (gcmd = mGCmds.begin(); gcmd != mGCmds.end(); ++gcmd)
108
+    (*gcmd)->toStrm(strm);
109
+}
110
+
111
+/**
112
+ * @brief output G-code to file
113
+ * @param[in] strFileName name of file to write G-code to
114
+ * @return if writing G-code was successful
115
+ */
116
+bool GCode::toFile(const std::string &strFileName) const
117
+{
118
+  std::ofstream ofstrm(strFileName.c_str(), std::ios::out);
119
+  if (!ofstrm.is_open()) {
120
+    std::cerr << "could not open \"" << strFileName << "\" for writing"
121
+              << std::endl;
122
+    return false;
123
+  }
124
+
125
+  toStrm(ofstrm);
126
+  return true;
127
+}
128
+
... ...
@@ -0,0 +1,90 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GCODE_H
7
+#define GCODE_H
8
+
9
+#include <iostream>
10
+#include <string>
11
+#include <vector>
12
+
13
+#include "gcmd.h"
14
+#include "point.h"
15
+
16
+/// G-code
17
+class GCode {
18
+public:
19
+  /// type for G-code commands
20
+  typedef std::vector<GCmd *> GCmds;
21
+
22
+  /// consturctor
23
+  GCode();
24
+
25
+  /// destructor
26
+  ~GCode();
27
+
28
+private:
29
+  /// copy constructor disabled
30
+  GCode(const GCode &);
31
+
32
+  /// assignment operator disabled
33
+  GCode & operator=(const GCode &);
34
+
35
+public:
36
+  /**
37
+   * @brief append fast move up command
38
+   * @param[in] z z coordinate to move up to
39
+   */
40
+  void appendUp(double z);
41
+
42
+  /**
43
+   * @brief append fast move command
44
+   * @param[in] pt point to move to
45
+   */
46
+  void appendFast(const Point &pt);
47
+
48
+  /**
49
+   * @brief append set feed rate command
50
+   * @param[in] feed feed rate
51
+   */
52
+  void appendFeed(double feed);
53
+
54
+  /**
55
+   * @brief append linear cut down command
56
+   * @param[in] z z coordinate to cut down to
57
+   */
58
+  void appendDown(double z);
59
+
60
+  /**
61
+   * @brief append linear cut command
62
+   * @param[in] pt point to cut to
63
+   */
64
+  void appendLinear(const Point &pt);
65
+
66
+  /**
67
+   * @brief append custom command
68
+   * @param[in] cmd custom command to append
69
+   */
70
+  void appendCustom(const std::string &cmd);
71
+
72
+  /**
73
+   * @brief output G-code to stream
74
+   * @param[in] strm stream to write G-code to
75
+   */
76
+  void toStrm(std::ostream &strm) const;
77
+
78
+  /**
79
+   * @brief output G-code to file
80
+   * @param[in] strFileName name of file to write G-code to
81
+   * @return if writing G-code was successful
82
+   */
83
+  bool toFile(const std::string &strFileName) const;
84
+
85
+  /// G-code commands
86
+  GCmds mGCmds;
87
+};
88
+
89
+#endif // #ifndef GCODE_H
90
+
... ...
@@ -0,0 +1,22 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+#include <string>
8
+
9
+#include "gcmd.h"
10
+#include "gcustom.h"
11
+
12
+/// virtual destructor
13
+GCustom::~GCustom()
14
+{
15
+}
16
+
17
+/// output G-code command to stream
18
+void GCustom::toStrm(std::ostream &strm) const
19
+{
20
+  strm << mCmd << std::endl;
21
+}
22
+
... ...
@@ -0,0 +1,27 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GCUSTOM_H
7
+#define GCUSTOM_H
8
+
9
+#include <iostream>
10
+#include <string>
11
+
12
+#include "gcmd.h"
13
+
14
+/// custom G-code command
15
+class GCustom: public GCmd {
16
+public:
17
+  /// virtual destructor
18
+  virtual ~GCustom();
19
+
20
+  /// output G-code command to stream
21
+  virtual void toStrm(std::ostream &strm) const;
22
+
23
+  std::string mCmd; ///< custom command
24
+};
25
+
26
+#endif // #ifndef GCUSTOM_H
27
+
... ...
@@ -0,0 +1,26 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+
8
+#include "gcmd.h"
9
+#include "gfast.h"
10
+#include "optdbl.h"
11
+
12
+/// virtual destructor
13
+GFast::~GFast()
14
+{
15
+}
16
+
17
+/// output G-code command to stream
18
+void GFast::toStrm(std::ostream &strm) const
19
+{
20
+  strm << "G0";
21
+  mX.toStrm(strm, " X");
22
+  mY.toStrm(strm, " Y");
23
+  mZ.toStrm(strm, " Z");
24
+  strm << std::endl;
25
+}
26
+
... ...
@@ -0,0 +1,29 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GFAST_H
7
+#define GFAST_H
8
+
9
+#include <iostream>
10
+
11
+#include "gcmd.h"
12
+#include "optdbl.h"
13
+
14
+/// G-code command fast move (G0)
15
+class GFast: public GCmd {
16
+public:
17
+  /// virtual destructor
18
+  virtual ~GFast();
19
+
20
+  /// output G-code command to stream
21
+  virtual void toStrm(std::ostream &strm) const;
22
+
23
+  OptDbl mX; ///< x coordinate
24
+  OptDbl mY; ///< y coordinate
25
+  OptDbl mZ; ///< z coordinate
26
+};
27
+
28
+#endif // #ifndef GFAST_H
29
+
... ...
@@ -0,0 +1,27 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+
8
+#include "gcmd.h"
9
+#include "gfeed.h"
10
+
11
+/// constructor
12
+GFeed::GFeed():
13
+  mFeed(10.0)
14
+{
15
+}
16
+
17
+/// virtual destructor
18
+GFeed::~GFeed()
19
+{
20
+}
21
+
22
+/// output G-code command to stream
23
+void GFeed::toStrm(std::ostream &strm) const
24
+{
25
+  strm << "F" << mFeed << std::endl;
26
+}
27
+
... ...
@@ -0,0 +1,29 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GFEED_H
7
+#define GFEED_H
8
+
9
+#include <iostream>
10
+
11
+#include "gcmd.h"
12
+
13
+/// G-code command set feed rate (F)
14
+class GFeed: public GCmd {
15
+public:
16
+  /// constructor
17
+  GFeed();
18
+
19
+  /// virtual destructor
20
+  virtual ~GFeed();
21
+
22
+  /// output G-code command to stream
23
+  virtual void toStrm(std::ostream &strm) const;
24
+
25
+  double mFeed; ///< feed rate
26
+};
27
+
28
+#endif // #ifndef GFEED_H
29
+
... ...
@@ -0,0 +1,26 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+
8
+#include "gcmd.h"
9
+#include "glinear.h"
10
+#include "optdbl.h"
11
+
12
+/// virtual destructor
13
+GLinear::~GLinear()
14
+{
15
+}
16
+
17
+/// output G-code command to stream
18
+void GLinear::toStrm(std::ostream &strm) const
19
+{
20
+  strm << "G1";
21
+  mX.toStrm(strm, " X");
22
+  mY.toStrm(strm, " Y");
23
+  mZ.toStrm(strm, " Z");
24
+  strm << std::endl;
25
+}
26
+
... ...
@@ -0,0 +1,29 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef GLINEAR_H
7
+#define GLINEAR_H
8
+
9
+#include <iostream>
10
+
11
+#include "gcmd.h"
12
+#include "optdbl.h"
13
+
14
+/// G-code command linear move (G1)
15
+class GLinear: public GCmd {
16
+public:
17
+  /// virtual destructor
18
+  virtual ~GLinear();
19
+
20
+  /// output G-code command to stream
21
+  virtual void toStrm(std::ostream &strm) const;
22
+
23
+  OptDbl mX; ///< x coordinate
24
+  OptDbl mY; ///< y coordinate
25
+  OptDbl mZ; ///< z coordinate
26
+};
27
+
28
+#endif // #ifndef GLINEAR_H
29
+
... ...
@@ -0,0 +1,34 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <vector>
7
+
8
+#include "gcode.h"
9
+#include "layer.h"
10
+#include "path.h"
11
+#include "settings.h"
12
+
13
+/**
14
+ * @brief add a new empty path to the layer
15
+ * @return reference to new empty path
16
+ */
17
+Path & Layer::addPath()
18
+{
19
+  mPaths.push_back(Path());
20
+  return mPaths.back();
21
+}
22
+
23
+/**
24
+ * @brief convert layer to G-code
25
+ * @param[in] settings G-code creation settings
26
+ * @param[in,out] gcode new G-code is appended to existing G-code
27
+ */
28
+void Layer::toGCode(const Settings &settings, GCode &gcode) const
29
+{
30
+  Paths::const_iterator path;
31
+  for (path = mPaths.begin(); path != mPaths.end(); ++path)
32
+    path->toGCode(settings, gcode);
33
+}
34
+
... ...
@@ -0,0 +1,37 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef LAYER_H
7
+#define LAYER_H
8
+
9
+#include <vector>
10
+
11
+#include "gcode.h"
12
+#include "path.h"
13
+#include "settings.h"
14
+
15
+/// layer of drawing
16
+class Layer {
17
+public:
18
+  typedef std::vector<Path> Paths; ///< type for paths in layer
19
+
20
+  /**
21
+   * @brief add a new empty path to the layer
22
+   * @return reference to new empty path
23
+   */
24
+  Path & addPath();
25
+
26
+  /**
27
+   * @brief convert layer to G-code
28
+   * @param[in] settings G-code creation settings
29
+   * @param[in,out] gcode new G-code is appended to existing G-code
30
+   */
31
+  void toGCode(const Settings &settings, GCode &gcode) const;
32
+
33
+  Paths mPaths; ///< paths in layer
34
+};
35
+
36
+#endif // #ifndef LAYER_H
37
+
... ...
@@ -0,0 +1,37 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+
8
+#include "cmdparser.h"
9
+
10
+/**
11
+ * @brief main programm
12
+ * @param[in] argc number of arguments
13
+ * @param[in] argv argument values
14
+ * @return exit code
15
+ */
16
+int main(int argc, char *argv[])
17
+{
18
+  // get parameters
19
+  if (argc < 2) {
20
+    std::cerr << "drawing (DXF) to G-code (NGC) converter" << std::endl
21
+              << "usage: " << argv[0] << " <commands.txt>"
22
+              << std::endl;
23
+    return 2;
24
+  }
25
+  std::string strCmdFileName = argv[1];
26
+
27
+  // process commands from file
28
+  CmdParser cmdParser;
29
+  if (!cmdParser.procFile(strCmdFileName)) {
30
+    std::cerr << "error processing command file \"" << strCmdFileName
31
+              << "\"" << std::endl;
32
+    return 3;
33
+  }
34
+
35
+  return 0;
36
+}
37
+
... ...
@@ -0,0 +1,42 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <iostream>
7
+#include <string>
8
+
9
+#include "optdbl.h"
10
+
11
+/// constructor
12
+OptDbl:: OptDbl():
13
+  mUse(false),
14
+  mVal(0.0)
15
+{
16
+}
17
+
18
+/// unset double value
19
+void OptDbl::unset()
20
+{
21
+  mUse = false;
22
+  mVal = 0.0;
23
+}
24
+
25
+/// set double value
26
+void OptDbl::set(double val)
27
+{
28
+  mUse = true;
29
+  mVal = val;
30
+}
31
+
32
+/**
33
+ * @brief output G-code command to stream
34
+ * @param[in] stream to write to
35
+ * @param[in] prefix to output
36
+ */
37
+void OptDbl::toStrm(std::ostream &strm, const std::string &prefix) const
38
+{
39
+  if (mUse)
40
+    strm << prefix << mVal;
41
+}
42
+
... ...
@@ -0,0 +1,36 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef OPTDBL_H
7
+#define OPTDBL_H
8
+
9
+#include <iostream>
10
+#include <string>
11
+
12
+/// optional double
13
+class OptDbl {
14
+public:
15
+  /// constructor
16
+  OptDbl();
17
+
18
+  /// unset double value
19
+  void unset();
20
+
21
+  /// set double value
22
+  void set(double val);
23
+
24
+  /**
25
+   * @brief output G-code command to stream
26
+   * @param[in] stream to write to
27
+   * @param[in] prefix to output
28
+   */
29
+  void toStrm(std::ostream &strm, const std::string &prefix) const;
30
+
31
+  bool   mUse; ///< if the optional double is in use
32
+  double mVal; ///< value of the optional double
33
+};
34
+
35
+#endif // #ifndef OPTDBL_H
36
+
... ...
@@ -0,0 +1,71 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <vector>
7
+
8
+#include "gcode.h"
9
+#include "path.h"
10
+#include "point.h"
11
+#include "settings.h"
12
+
13
+/**
14
+ * @brief add a new point to the end of the path
15
+ * @param[in] point point to add
16
+ */
17
+void Path::addPoint(const Point &point)
18
+{
19
+  mPoints.push_back(point);
20
+}
21
+
22
+/**
23
+ * @brief add a new point to the end of the path
24
+ * @param[in] x x coordinate of point to add
25
+ * @param[in] y y coordinate of point to add
26
+ */
27
+void Path::addPoint(double x, double y)
28
+{
29
+  addPoint(Point(x, y));
30
+}
31
+
32
+/**
33
+ * @brief convert path to G-code
34
+ * @param[in] settings G-code creation settings
35
+ * @param[in,out] gcode new G-code is appended to existing G-code
36
+ */
37
+void Path::toGCode(const Settings &settings, GCode &gcode) const
38
+{
39
+  // leave if no points
40
+  if (mPoints.empty())
41
+    return;
42
+
43
+  // move up
44
+  gcode.appendUp(settings.move_z);
45
+
46
+  // cut step-wise
47
+  double z = settings.base_z;
48
+  do {
49
+    z -= settings.cut_z_step;
50
+    if (z < settings.cut_z)
51
+      z = settings.cut_z;
52
+
53
+    // move to start
54
+    gcode.appendFast(mPoints.front());
55
+
56
+    // cut down
57
+    gcode.appendFeed(settings.feed_drill);
58
+    gcode.appendDown(z);
59
+
60
+    // cut along all points
61
+    gcode.appendFeed(settings.feed_mill);
62
+    Points::const_iterator pt = mPoints.begin();
63
+    for (++pt; pt != mPoints.end(); ++pt)
64
+      gcode.appendLinear(*pt);
65
+
66
+    // move up
67
+    gcode.appendUp(settings.move_z);
68
+
69
+  } while (z > settings.cut_z);
70
+}
71
+
... ...
@@ -0,0 +1,44 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef PATH_H
7
+#define PATH_H
8
+
9
+#include <vector>
10
+
11
+#include "gcode.h"
12
+#include "point.h"
13
+#include "settings.h"
14
+
15
+/// a 2D path, i.e. a number of connected lines in 2D space
16
+class Path {
17
+public:
18
+  typedef std::vector<Point> Points; ///< type for points of path
19
+
20
+  /**
21
+   * @brief add a new point to the end of the path
22
+   * @param[in] point point to add
23
+   */
24
+  void addPoint(const Point &point);
25
+
26
+  /**
27
+   * @brief add a new point to the end of the path
28
+   * @param[in] x x coordinate of point to add
29
+   * @param[in] y y coordinate of point to add
30
+   */
31
+  void addPoint(double x, double y);
32
+
33
+  /**
34
+   * @brief convert path to G-code
35
+   * @param[in] settings G-code creation settings
36
+   * @param[in,out] gcode new G-code is appended to existing G-code
37
+   */
38
+  void toGCode(const Settings &settings, GCode &gcode) const;
39
+
40
+  Points mPoints; ///< points of path
41
+};
42
+
43
+#endif // #ifndef PATH_H
44
+
... ...
@@ -0,0 +1,84 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <math.h>
7
+
8
+#include "point.h"
9
+
10
+Point::Point():
11
+  mX(0.0),
12
+  mY(0.0)
13
+{
14
+}
15
+
16
+Point::Point(double x, double y):
17
+  mX(x),
18
+  mY(y)
19
+{
20
+}
21
+
22
+double Point::abs_sq() const
23
+{
24
+  return mX * mX + mY * mY;
25
+}
26
+
27
+double Point::abs() const
28
+{
29
+  return sqrt(mX * mX + mY * mY);
30
+}
31
+
32
+Point Point::operator-() const
33
+{
34
+  return Point(-mX, -mY);
35
+}
36
+
37
+Point Point::operator+(const Point &that) const
38
+{
39
+  return Point(mX + that.mX, mY + that.mY);
40
+}
41
+
42
+Point Point::operator-(const Point &that) const
43
+{
44
+  return Point(mX - that.mX, mY - that.mY);
45
+}
46
+
47
+Point Point::operator*(double factor) const
48
+{
49
+  return Point(mX * factor, mY * factor);
50
+}
51
+
52
+Point Point::operator/(double factor) const
53
+{
54
+  return Point(mX / factor, mY / factor);
55
+}
56
+
57
+Point &Point::operator+=(const Point &that)
58
+{
59
+  mX += that.mX;
60
+  mY += that.mY;
61
+  return *this;
62
+}
63
+
64
+Point &Point::operator-=(const Point &that)
65
+{
66
+  mX -= that.mX;
67
+  mY -= that.mY;
68
+  return *this;
69
+}
70
+
71
+Point &Point::operator*=(double factor)
72
+{
73
+  mX *= factor;
74
+  mY *= factor;
75
+  return *this;
76
+}
77
+
78
+Point &Point::operator/=(double factor)
79
+{
80
+  mX /= factor;
81
+  mY /= factor;
82
+  return *this;
83
+}
84
+
... ...
@@ -0,0 +1,30 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef POINT_H
7
+#define POINT_H
8
+
9
+/// point in 2D space
10
+class Point {
11
+public:
12
+  Point();
13
+  Point(double x, double y);
14
+  double abs_sq() const;
15
+  double abs() const;
16
+  Point operator-() const;
17
+  Point operator+(const Point &that) const;
18
+  Point operator-(const Point &that) const;
19
+  Point operator*(double factor) const;
20
+  Point operator/(double factor) const;
21
+  Point &operator+=(const Point &that);
22
+  Point &operator-=(const Point &that);
23
+  Point &operator*=(double factor);
24
+  Point &operator/=(double factor);
25
+  double mX; ///< x coordinate
26
+  double mY; ///< y coordinate
27
+};
28
+
29
+#endif // #ifndef POINT_H
30
+
... ...
@@ -0,0 +1,19 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include "settings.h"
7
+
8
+/// set some reasonable/safe default settings
9
+Settings::Settings():
10
+  base_z(0.0),
11
+  cut_z(0.0),
12
+  cut_z_step(0.1),
13
+  feed_drill(10.0),
14
+  feed_mill(10.0),
15
+  move_z(10.0),
16
+  tool_diameter(0.0)
17
+{
18
+}
19
+
... ...
@@ -0,0 +1,25 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef SETTINGS_H
7
+#define SETTINGS_H
8
+
9
+/// settings for creation of G-code
10
+class Settings {
11
+public:
12
+  /// set some reasonable/safe default settings
13
+  Settings();
14
+
15
+  double base_z;        ///< z coordinate of workpiece surface
16
+  double cut_z;         ///< z coordinate of maximum cutting
17
+  double cut_z_step;    ///< z coordinate difference to cut in one step, > 0.0
18
+  double feed_drill;    ///< feed rate for drilling
19
+  double feed_mill;     ///< feed rate for milling
20
+  double move_z;        ///< z coordinate for moving
21
+  double tool_diameter; ///< diameter of cutting tool, >= 0.0
22
+};
23
+
24
+#endif // #ifndef SETTINGS_H
25
+
... ...
@@ -0,0 +1,69 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#include <dime/entities/Entity.h>
7
+#include <dime/State.h>
8
+#include <string>
9
+
10
+#include "drawing.h"
11
+#include "layer.h"
12
+#include "path.h"
13
+#include "traverse.h"
14
+
15
+/**
16
+ * @brief process an entity during DXF traversal
17
+ * @param[in] state current state of libdime
18
+ * @param[in] entity pointer to entity
19
+ * @param[in] vp_ctx context pointer, must point to traverse_ctx structure
20
+ * @return if to continue enumeration
21
+ */
22
+bool traverse_entity(const class dimeState * const state, dimeEntity *entity,
23
+                     void *vp_ctx)
24
+{
25
+  struct traverse_ctx *p_ctx = (struct traverse_ctx *)vp_ctx;
26
+
27
+  // get layer
28
+  std::string strLayerName = entity->getLayerName();
29
+  Layer &layer = p_ctx->mpDrawing->mLayers[strLayerName];
30
+
31
+  // get transformation matrix
32
+  dimeMatrix matrix;
33
+  state->getMatrix(matrix);
34
+
35
+  // get geometry data
36
+  dimeArray<dimeVec3f> vertices;
37
+  dimeArray<int> indices;
38
+  dimeVec3f extrusionDir;
39
+  dxfdouble thickness;
40
+  entity->extractGeometry(vertices, indices, extrusionDir, thickness);
41
+
42
+  // transform geometry data
43
+  for (int v = 0; v < vertices.count(); ++v)
44
+    matrix.multMatrixVec(vertices[v]);
45
+
46
+  // no indices -> entire vertices array forms a path
47
+  if (indices.count() == 0) {
48
+    Path &path = layer.addPath();
49
+    for (int v = 0; v < vertices.count(); ++v)
50
+      path.addPoint(vertices[v].x, vertices[v].y);
51
+  }
52
+
53
+  // indices available: paths given by indices
54
+  else {
55
+    Path *path = &layer.addPath();
56
+    for (int i = 0; i < indices.count(); ++i) {
57
+      int v = indices[i];
58
+      // valid index: add to path
59
+      if (v >= 0 || v < vertices.count())
60
+        path->addPoint(vertices[v].x, vertices[v].y);
61
+      // invalid index: start new path
62
+      else
63
+        path = &layer.addPath();
64
+    }
65
+  }
66
+
67
+  return true; // continue enumeration
68
+}
69
+
... ...
@@ -0,0 +1,30 @@
1
+/* drawing (DXF) to G-code (NGC) converter
2
+ * Copyright 2013 Stefan Schuermans <stefan@schuermans.info>
3
+ * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4
+ */
5
+
6
+#ifndef TRAVERSE_H
7
+#define TRAVERSE_H
8
+
9
+#include <dime/entities/Entity.h>
10
+#include <dime/State.h>
11
+
12
+#include "drawing.h"
13
+
14
+/// context structure for traverse entities callback
15
+struct traverse_ctx {
16
+  Drawing *mpDrawing; ///< the drawing to add the entities to
17
+};
18
+
19
+/**
20
+ * @brief process an entity during DXF traversal
21
+ * @param[in] state current state of libdime
22
+ * @param[in] entity pointer to entity
23
+ * @param[in] vp_ctx context pointer, must point to traverse_ctx structure
24
+ * @return if to continue enumeration
25
+ */
26
+bool traverse_entity(const class dimeState * const state, dimeEntity *entity,
27
+                     void *vp_ctx);
28
+
29
+#endif // #ifndef TRAVERSE_H
30
+
0 31