implement finer approximation for circles and arcs on import, implement import of ellipses
Stefan Schuermans

Stefan Schuermans commited on 2013-01-29 23:06:23
Showing 7 changed files, with 2557 additions and 7 deletions.

... ...
@@ -0,0 +1,2214 @@
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
+1
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
+0
925
+390
926
+F
927
+  0
928
+ENDTAB
929
+  0
930
+TABLE
931
+  2
932
+STYLE
933
+  5
934
+3
935
+100
936
+AcDbSymbolTable
937
+ 70
938
+1
939
+  0
940
+STYLE
941
+  5
942
+11
943
+100
944
+AcDbSymbolTableRecord
945
+100
946
+AcDbTextStyleTableRecord
947
+  2
948
+Standard
949
+ 70
950
+0
951
+ 40
952
+0.0
953
+ 41
954
+0.75
955
+ 50
956
+0.0
957
+ 71
958
+0
959
+ 42
960
+2.5
961
+  3
962
+txt
963
+  4
964
+
965
+  0
966
+ENDTAB
967
+  0
968
+TABLE
969
+  2
970
+VIEW
971
+  5
972
+6
973
+100
974
+AcDbSymbolTable
975
+ 70
976
+0
977
+  0
978
+ENDTAB
979
+  0
980
+TABLE
981
+  2
982
+UCS
983
+  5
984
+7
985
+100
986
+AcDbSymbolTable
987
+ 70
988
+0
989
+  0
990
+ENDTAB
991
+  0
992
+TABLE
993
+  2
994
+APPID
995
+  5
996
+9
997
+100
998
+AcDbSymbolTable
999
+ 70
1000
+1
1001
+  0
1002
+APPID
1003
+  5
1004
+12
1005
+100
1006
+AcDbSymbolTableRecord
1007
+100
1008
+AcDbRegAppTableRecord
1009
+  2
1010
+ACAD
1011
+ 70
1012
+0
1013
+  0
1014
+ENDTAB
1015
+  0
1016
+TABLE
1017
+  2
1018
+DIMSTYLE
1019
+  5
1020
+A
1021
+100
1022
+AcDbSymbolTable
1023
+ 70
1024
+1
1025
+100
1026
+AcDbDimStyleTable
1027
+ 71
1028
+0
1029
+  0
1030
+DIMSTYLE
1031
+105
1032
+27
1033
+100
1034
+AcDbSymbolTableRecord
1035
+100
1036
+AcDbDimStyleTableRecord
1037
+  2
1038
+Standard
1039
+ 41
1040
+2.5
1041
+ 42
1042
+0.625
1043
+ 43
1044
+3.75
1045
+ 44
1046
+1.25
1047
+ 70
1048
+0
1049
+ 73
1050
+0
1051
+ 74
1052
+0
1053
+ 77
1054
+1
1055
+ 78
1056
+8
1057
+140
1058
+2.5
1059
+141
1060
+2.5
1061
+143
1062
+0.03937007874016
1063
+147
1064
+0.625
1065
+171
1066
+3
1067
+172
1068
+1
1069
+271
1070
+2
1071
+272
1072
+2
1073
+274
1074
+3
1075
+278
1076
+44
1077
+283
1078
+0
1079
+284
1080
+8
1081
+340
1082
+11
1083
+  0
1084
+ENDTAB
1085
+  0
1086
+TABLE
1087
+  2
1088
+BLOCK_RECORD
1089
+  5
1090
+1
1091
+100
1092
+AcDbSymbolTable
1093
+ 70
1094
+1
1095
+  0
1096
+BLOCK_RECORD
1097
+  5
1098
+1F
1099
+100
1100
+AcDbSymbolTableRecord
1101
+100
1102
+AcDbBlockTableRecord
1103
+  2
1104
+*Model_Space
1105
+340
1106
+22
1107
+  0
1108
+BLOCK_RECORD
1109
+  5
1110
+1B
1111
+100
1112
+AcDbSymbolTableRecord
1113
+100
1114
+AcDbBlockTableRecord
1115
+  2
1116
+*Paper_Space
1117
+340
1118
+1E
1119
+  0
1120
+BLOCK_RECORD
1121
+  5
1122
+23
1123
+100
1124
+AcDbSymbolTableRecord
1125
+100
1126
+AcDbBlockTableRecord
1127
+  2
1128
+*Paper_Space0
1129
+340
1130
+26
1131
+  0
1132
+BLOCK_RECORD
1133
+  5
1134
+43
1135
+100
1136
+AcDbSymbolTableRecord
1137
+100
1138
+AcDbBlockTableRecord
1139
+  2
1140
+blk
1141
+340
1142
+0
1143
+  0
1144
+ENDTAB
1145
+  0
1146
+ENDSEC
1147
+  0
1148
+SECTION
1149
+  2
1150
+BLOCKS
1151
+  0
1152
+BLOCK
1153
+  5
1154
+20
1155
+100
1156
+AcDbEntity
1157
+  8
1158
+0
1159
+100
1160
+AcDbBlockBegin
1161
+  2
1162
+*Model_Space
1163
+ 70
1164
+0
1165
+ 10
1166
+0.0
1167
+ 20
1168
+0.0
1169
+ 30
1170
+0.0
1171
+  3
1172
+*Model_Space
1173
+  1
1174
+
1175
+  0
1176
+ENDBLK
1177
+  5
1178
+21
1179
+100
1180
+AcDbEntity
1181
+  8
1182
+0
1183
+100
1184
+AcDbBlockEnd
1185
+  0
1186
+BLOCK
1187
+  5
1188
+1C
1189
+100
1190
+AcDbEntity
1191
+ 67
1192
+1
1193
+  8
1194
+0
1195
+100
1196
+AcDbBlockBegin
1197
+  2
1198
+*Paper_Space
1199
+ 70
1200
+0
1201
+ 10
1202
+0.0
1203
+ 20
1204
+0.0
1205
+ 30
1206
+0.0
1207
+  3
1208
+*Paper_Space
1209
+  1
1210
+
1211
+  0
1212
+ENDBLK
1213
+  5
1214
+1D
1215
+100
1216
+AcDbEntity
1217
+ 67
1218
+1
1219
+  8
1220
+0
1221
+100
1222
+AcDbBlockEnd
1223
+  0
1224
+BLOCK
1225
+  5
1226
+24
1227
+100
1228
+AcDbEntity
1229
+  8
1230
+0
1231
+100
1232
+AcDbBlockBegin
1233
+  2
1234
+*Paper_Space0
1235
+ 70
1236
+0
1237
+ 10
1238
+0.0
1239
+ 20
1240
+0.0
1241
+ 30
1242
+0.0
1243
+  3
1244
+*Paper_Space0
1245
+  1
1246
+
1247
+  0
1248
+ENDBLK
1249
+  5
1250
+25
1251
+100
1252
+AcDbEntity
1253
+  8
1254
+0
1255
+100
1256
+AcDbBlockEnd
1257
+  0
1258
+BLOCK
1259
+  5
1260
+44
1261
+100
1262
+AcDbEntity
1263
+  8
1264
+0
1265
+100
1266
+AcDbBlockBegin
1267
+  2
1268
+blk
1269
+ 70
1270
+0
1271
+ 10
1272
+0.0
1273
+ 20
1274
+0.0
1275
+ 30
1276
+0.0
1277
+  3
1278
+blk
1279
+  1
1280
+
1281
+  0
1282
+CIRCLE
1283
+  5
1284
+45
1285
+100
1286
+AcDbEntity
1287
+100
1288
+AcDbCircle
1289
+  8
1290
+0
1291
+ 62
1292
+256
1293
+370
1294
+-1
1295
+  6
1296
+ByLayer
1297
+ 10
1298
+10.0
1299
+ 20
1300
+10.0
1301
+ 30
1302
+0.0
1303
+ 40
1304
+30.0
1305
+  0
1306
+ARC
1307
+  5
1308
+46
1309
+100
1310
+AcDbEntity
1311
+  8
1312
+0
1313
+ 62
1314
+256
1315
+370
1316
+-1
1317
+  6
1318
+ByLayer
1319
+100
1320
+AcDbCircle
1321
+ 10
1322
+10.0
1323
+ 20
1324
+10.0
1325
+ 30
1326
+0.0
1327
+ 40
1328
+10.0
1329
+100
1330
+AcDbArc
1331
+ 50
1332
+0.0
1333
+ 51
1334
+135.0
1335
+  0
1336
+ELLIPSE
1337
+  5
1338
+47
1339
+100
1340
+AcDbEntity
1341
+100
1342
+AcDbEllipse
1343
+  8
1344
+0
1345
+ 62
1346
+256
1347
+370
1348
+-1
1349
+  6
1350
+ByLayer
1351
+ 10
1352
+10.0
1353
+ 20
1354
+10.0
1355
+ 30
1356
+0.0
1357
+ 11
1358
+-60.0
1359
+ 21
1360
+0.0
1361
+ 31
1362
+0.0
1363
+ 40
1364
+0.6666666666666666
1365
+ 41
1366
+0.0
1367
+ 42
1368
+6.2831853071795862
1369
+  0
1370
+ELLIPSE
1371
+  5
1372
+48
1373
+100
1374
+AcDbEntity
1375
+100
1376
+AcDbEllipse
1377
+  8
1378
+0
1379
+ 62
1380
+256
1381
+370
1382
+-1
1383
+  6
1384
+ByLayer
1385
+ 10
1386
+10.0
1387
+ 20
1388
+-10.0
1389
+ 30
1390
+0.0
1391
+ 11
1392
+40.0
1393
+ 21
1394
+40.0
1395
+ 31
1396
+0.0
1397
+ 40
1398
+0.4999999999999999
1399
+ 41
1400
+5.1760365893854958
1401
+ 42
1402
+0.0
1403
+  0
1404
+ENDBLK
1405
+  5
1406
+49
1407
+100
1408
+AcDbEntity
1409
+  8
1410
+0
1411
+100
1412
+AcDbBlockEnd
1413
+  0
1414
+ENDSEC
1415
+  0
1416
+SECTION
1417
+  2
1418
+ENTITIES
1419
+  0
1420
+INSERT
1421
+  5
1422
+4A
1423
+100
1424
+AcDbEntity
1425
+100
1426
+AcDbBlockReference
1427
+  8
1428
+0
1429
+ 62
1430
+256
1431
+370
1432
+-1
1433
+  6
1434
+ByLayer
1435
+  2
1436
+blk
1437
+ 10
1438
+20.0
1439
+ 20
1440
+10.0
1441
+ 30
1442
+0.0
1443
+ 41
1444
+2.0
1445
+ 42
1446
+2.0
1447
+ 43
1448
+1.0
1449
+ 50
1450
+45.0
1451
+  0
1452
+LINE
1453
+  5
1454
+4B
1455
+100
1456
+AcDbEntity
1457
+100
1458
+AcDbLine
1459
+  8
1460
+0
1461
+ 62
1462
+256
1463
+370
1464
+-1
1465
+  6
1466
+ByLayer
1467
+ 10
1468
+48.2842712474619091
1469
+ 20
1470
+109.1370849898476081
1471
+ 30
1472
+0.0
1473
+ 11
1474
+48.2842712474619091
1475
+ 21
1476
+137.1370849898476081
1477
+ 31
1478
+0.0
1479
+  0
1480
+LINE
1481
+  5
1482
+4C
1483
+100
1484
+AcDbEntity
1485
+100
1486
+AcDbLine
1487
+  8
1488
+0
1489
+ 62
1490
+256
1491
+370
1492
+-1
1493
+  6
1494
+ByLayer
1495
+ 10
1496
+98.8807138101559815
1497
+ 20
1498
+46.5964425626940439
1499
+ 30
1500
+0.0
1501
+ 11
1502
+98.8807138101559815
1503
+ 21
1504
+74.596442562694051
1505
+ 31
1506
+0.0
1507
+  0
1508
+LINE
1509
+  5
1510
+4D
1511
+100
1512
+AcDbEntity
1513
+100
1514
+AcDbLine
1515
+  8
1516
+0
1517
+ 62
1518
+256
1519
+370
1520
+-1
1521
+  6
1522
+ByLayer
1523
+ 10
1524
+34.2842712474619091
1525
+ 20
1526
+123.1370849898476081
1527
+ 30
1528
+0.0
1529
+ 11
1530
+62.2842712474619091
1531
+ 21
1532
+123.1370849898476081
1533
+ 31
1534
+0.0
1535
+  0
1536
+LINE
1537
+  5
1538
+4E
1539
+100
1540
+AcDbEntity
1541
+100
1542
+AcDbLine
1543
+  8
1544
+0
1545
+ 62
1546
+256
1547
+370
1548
+-1
1549
+  6
1550
+ByLayer
1551
+ 10
1552
+84.8807138101559815
1553
+ 20
1554
+60.5964425626940439
1555
+ 30
1556
+0.0
1557
+ 11
1558
+112.8807138101559815
1559
+ 21
1560
+60.5964425626940439
1561
+ 31
1562
+0.0
1563
+  0
1564
+LINE
1565
+  5
1566
+4F
1567
+100
1568
+AcDbEntity
1569
+100
1570
+AcDbLine
1571
+  8
1572
+0
1573
+ 62
1574
+256
1575
+370
1576
+-1
1577
+  6
1578
+ByLayer
1579
+ 10
1580
+-14.0
1581
+ 20
1582
+38.284271247461902
1583
+ 30
1584
+0.0
1585
+ 11
1586
+14.0
1587
+ 21
1588
+38.284271247461902
1589
+ 31
1590
+0.0
1591
+  0
1592
+LINE
1593
+  5
1594
+50
1595
+100
1596
+AcDbEntity
1597
+100
1598
+AcDbLine
1599
+  8
1600
+0
1601
+ 62
1602
+256
1603
+370
1604
+-1
1605
+  6
1606
+ByLayer
1607
+ 10
1608
+20.142135623730951
1609
+ 20
1610
+52.426406871192853
1611
+ 30
1612
+0.0
1613
+ 11
1614
+48.142135623730951
1615
+ 21
1616
+52.426406871192853
1617
+ 31
1618
+0.0
1619
+  0
1620
+LINE
1621
+  5
1622
+51
1623
+100
1624
+AcDbEntity
1625
+100
1626
+AcDbLine
1627
+  8
1628
+0
1629
+ 62
1630
+256
1631
+370
1632
+-1
1633
+  6
1634
+ByLayer
1635
+ 10
1636
+-0.0000000000000009
1637
+ 20
1638
+24.284271247461902
1639
+ 30
1640
+0.0
1641
+ 11
1642
+0.0000000000000009
1643
+ 21
1644
+52.284271247461902
1645
+ 31
1646
+0.0
1647
+  0
1648
+LINE
1649
+  5
1650
+52
1651
+100
1652
+AcDbEntity
1653
+100
1654
+AcDbLine
1655
+  8
1656
+0
1657
+ 62
1658
+256
1659
+370
1660
+-1
1661
+  6
1662
+ByLayer
1663
+ 10
1664
+34.142135623730951
1665
+ 20
1666
+38.426406871192853
1667
+ 30
1668
+0.0
1669
+ 11
1670
+34.142135623730951
1671
+ 21
1672
+66.426406871192853
1673
+ 31
1674
+0.0
1675
+  0
1676
+ENDSEC
1677
+  0
1678
+SECTION
1679
+  2
1680
+OBJECTS
1681
+  0
1682
+DICTIONARY
1683
+  5
1684
+C
1685
+100
1686
+AcDbDictionary
1687
+280
1688
+0
1689
+281
1690
+1
1691
+  3
1692
+ACAD_GROUP
1693
+350
1694
+D
1695
+  3
1696
+ACAD_LAYOUT
1697
+350
1698
+1A
1699
+  3
1700
+ACAD_MLINESTYLE
1701
+350
1702
+17
1703
+  3
1704
+ACAD_PLOTSETTINGS
1705
+350
1706
+19
1707
+  3
1708
+ACAD_PLOTSTYLENAME
1709
+350
1710
+E
1711
+  3
1712
+AcDbVariableDictionary
1713
+350
1714
+53
1715
+  0
1716
+DICTIONARY
1717
+  5
1718
+D
1719
+100
1720
+AcDbDictionary
1721
+280
1722
+0
1723
+281
1724
+1
1725
+  0
1726
+ACDBDICTIONARYWDFLT
1727
+  5
1728
+E
1729
+100
1730
+AcDbDictionary
1731
+281
1732
+1
1733
+  3
1734
+Normal
1735
+350
1736
+F
1737
+100
1738
+AcDbDictionaryWithDefault
1739
+340
1740
+F
1741
+  0
1742
+ACDBPLACEHOLDER
1743
+  5
1744
+F
1745
+  0
1746
+DICTIONARY
1747
+  5
1748
+17
1749
+100
1750
+AcDbDictionary
1751
+280
1752
+0
1753
+281
1754
+1
1755
+  3
1756
+Standard
1757
+350
1758
+18
1759
+  0
1760
+MLINESTYLE
1761
+  5
1762
+18
1763
+100
1764
+AcDbMlineStyle
1765
+  2
1766
+STANDARD
1767
+ 70
1768
+0
1769
+  3
1770
+
1771
+ 62
1772
+256
1773
+ 51
1774
+90.0
1775
+ 52
1776
+90.0
1777
+ 71
1778
+2
1779
+ 49
1780
+0.5
1781
+ 62
1782
+256
1783
+  6
1784
+BYLAYER
1785
+ 49
1786
+-0.5
1787
+ 62
1788
+256
1789
+  6
1790
+BYLAYER
1791
+  0
1792
+DICTIONARY
1793
+  5
1794
+19
1795
+100
1796
+AcDbDictionary
1797
+280
1798
+0
1799
+281
1800
+1
1801
+  0
1802
+DICTIONARY
1803
+  5
1804
+1A
1805
+100
1806
+AcDbDictionary
1807
+281
1808
+1
1809
+  3
1810
+Layout1
1811
+350
1812
+1E
1813
+  3
1814
+Layout2
1815
+350
1816
+26
1817
+  3
1818
+Model
1819
+350
1820
+22
1821
+  0
1822
+LAYOUT
1823
+  5
1824
+1E
1825
+100
1826
+AcDbPlotSettings
1827
+  1
1828
+
1829
+  2
1830
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
1831
+  4
1832
+
1833
+  6
1834
+
1835
+ 40
1836
+0.0
1837
+ 41
1838
+0.0
1839
+ 42
1840
+0.0
1841
+ 43
1842
+0.0
1843
+ 44
1844
+0.0
1845
+ 45
1846
+0.0
1847
+ 46
1848
+0.0
1849
+ 47
1850
+0.0
1851
+ 48
1852
+0.0
1853
+ 49
1854
+0.0
1855
+140
1856
+0.0
1857
+141
1858
+0.0
1859
+142
1860
+1.0
1861
+143
1862
+1.0
1863
+ 70
1864
+688
1865
+ 72
1866
+0
1867
+ 73
1868
+0
1869
+ 74
1870
+5
1871
+  7
1872
+
1873
+ 75
1874
+16
1875
+147
1876
+1.0
1877
+148
1878
+0.0
1879
+149
1880
+0.0
1881
+100
1882
+AcDbLayout
1883
+  1
1884
+Layout1
1885
+ 70
1886
+1
1887
+ 71
1888
+1
1889
+ 10
1890
+0.0
1891
+ 20
1892
+0.0
1893
+ 11
1894
+420.0
1895
+ 21
1896
+297.0
1897
+ 12
1898
+0.0
1899
+ 22
1900
+0.0
1901
+ 32
1902
+0.0
1903
+ 14
1904
+100000000000000000000.0
1905
+ 24
1906
+100000000000000000000.0
1907
+ 34
1908
+100000000000000000000.0
1909
+ 15
1910
+-100000000000000000000.0
1911
+ 25
1912
+-100000000000000000000.0
1913
+ 35
1914
+-100000000000000000000.0
1915
+146
1916
+0.0
1917
+ 13
1918
+0.0
1919
+ 23
1920
+0.0
1921
+ 33
1922
+0.0
1923
+ 16
1924
+1.0
1925
+ 26
1926
+0.0
1927
+ 36
1928
+0.0
1929
+ 17
1930
+0.0
1931
+ 27
1932
+1.0
1933
+ 37
1934
+0.0
1935
+ 76
1936
+0
1937
+330
1938
+1B
1939
+  0
1940
+LAYOUT
1941
+  5
1942
+22
1943
+100
1944
+AcDbPlotSettings
1945
+  1
1946
+
1947
+  2
1948
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
1949
+  4
1950
+
1951
+  6
1952
+
1953
+ 40
1954
+0.0
1955
+ 41
1956
+0.0
1957
+ 42
1958
+0.0
1959
+ 43
1960
+0.0
1961
+ 44
1962
+0.0
1963
+ 45
1964
+0.0
1965
+ 46
1966
+0.0
1967
+ 47
1968
+0.0
1969
+ 48
1970
+0.0
1971
+ 49
1972
+0.0
1973
+140
1974
+0.0
1975
+141
1976
+0.0
1977
+142
1978
+1.0
1979
+143
1980
+1.0
1981
+ 70
1982
+1712
1983
+ 72
1984
+0
1985
+ 73
1986
+0
1987
+ 74
1988
+0
1989
+  7
1990
+
1991
+ 75
1992
+0
1993
+147
1994
+1.0
1995
+148
1996
+0.0
1997
+149
1998
+0.0
1999
+100
2000
+AcDbLayout
2001
+  1
2002
+Model
2003
+ 70
2004
+1
2005
+ 71
2006
+0
2007
+ 10
2008
+0.0
2009
+ 20
2010
+0.0
2011
+ 11
2012
+12.0
2013
+ 21
2014
+9.0
2015
+ 12
2016
+0.0
2017
+ 22
2018
+0.0
2019
+ 32
2020
+0.0
2021
+ 14
2022
+0.0
2023
+ 24
2024
+0.0
2025
+ 34
2026
+0.0
2027
+ 15
2028
+0.0
2029
+ 25
2030
+0.0
2031
+ 35
2032
+0.0
2033
+146
2034
+0.0
2035
+ 13
2036
+0.0
2037
+ 23
2038
+0.0
2039
+ 33
2040
+0.0
2041
+ 16
2042
+1.0
2043
+ 26
2044
+0.0
2045
+ 36
2046
+0.0
2047
+ 17
2048
+0.0
2049
+ 27
2050
+1.0
2051
+ 37
2052
+0.0
2053
+ 76
2054
+0
2055
+330
2056
+1F
2057
+  0
2058
+LAYOUT
2059
+  5
2060
+26
2061
+100
2062
+AcDbPlotSettings
2063
+  1
2064
+
2065
+  2
2066
+C:\Program Files\AutoCAD 2002\plotters\DWF ePlot (optimized for plotting).pc3
2067
+  4
2068
+
2069
+  6
2070
+
2071
+ 40
2072
+0.0
2073
+ 41
2074
+0.0
2075
+ 42
2076
+0.0
2077
+ 43
2078
+0.0
2079
+ 44
2080
+0.0
2081
+ 45
2082
+0.0
2083
+ 46
2084
+0.0
2085
+ 47
2086
+0.0
2087
+ 48
2088
+0.0
2089
+ 49
2090
+0.0
2091
+140
2092
+0.0
2093
+141
2094
+0.0
2095
+142
2096
+1.0
2097
+143
2098
+1.0
2099
+ 70
2100
+688
2101
+ 72
2102
+0
2103
+ 73
2104
+0
2105
+ 74
2106
+5
2107
+  7
2108
+
2109
+ 75
2110
+16
2111
+147
2112
+1.0
2113
+148
2114
+0.0
2115
+149
2116
+0.0
2117
+100
2118
+AcDbLayout
2119
+  1
2120
+Layout2
2121
+ 70
2122
+1
2123
+ 71
2124
+2
2125
+ 10
2126
+0.0
2127
+ 20
2128
+0.0
2129
+ 11
2130
+12.0
2131
+ 21
2132
+9.0
2133
+ 12
2134
+0.0
2135
+ 22
2136
+0.0
2137
+ 32
2138
+0.0
2139
+ 14
2140
+0.0
2141
+ 24
2142
+0.0
2143
+ 34
2144
+0.0
2145
+ 15
2146
+0.0
2147
+ 25
2148
+0.0
2149
+ 35
2150
+0.0
2151
+146
2152
+0.0
2153
+ 13
2154
+0.0
2155
+ 23
2156
+0.0
2157
+ 33
2158
+0.0
2159
+ 16
2160
+1.0
2161
+ 26
2162
+0.0
2163
+ 36
2164
+0.0
2165
+ 17
2166
+0.0
2167
+ 27
2168
+1.0
2169
+ 37
2170
+0.0
2171
+ 76
2172
+0
2173
+330
2174
+23
2175
+  0
2176
+DICTIONARY
2177
+  5
2178
+53
2179
+100
2180
+AcDbDictionary
2181
+281
2182
+1
2183
+  3
2184
+DIMASSOC
2185
+350
2186
+55
2187
+  3
2188
+HIDETEXT
2189
+350
2190
+54
2191
+  0
2192
+DICTIONARYVAR
2193
+  5
2194
+54
2195
+100
2196
+DictionaryVariables
2197
+280
2198
+0
2199
+  1
2200
+2
2201
+  0
2202
+DICTIONARYVAR
2203
+  5
2204
+55
2205
+100
2206
+DictionaryVariables
2207
+280
2208
+0
2209
+  1
2210
+1
2211
+  0
2212
+ENDSEC
2213
+  0
2214
+EOF
... ...
@@ -0,0 +1,24 @@
1
+cmd G21
2
+cmd G90
3
+cmd G64 P0.01
4
+cmd G17
5
+cmd G40
6
+cmd G49
7
+
8
+set_precision 0.01
9
+set_tool_diameter 3
10
+set_move_z 3
11
+set_base_z 0
12
+set_cut_z_step 1
13
+set_feed_drill 1000
14
+set_feed_mill 2000
15
+
16
+read_dxf circle_ellipse.dxf
17
+
18
+set_cut_z -1
19
+cut 0
20
+
21
+cmd M2
22
+
23
+write_ngc circle_ellipse.ngc
24
+
... ...
@@ -221,7 +221,7 @@ bool CmdParser::procCmd_read_dxf(std::istream &strm)
221 221
   fileName = filename_rebase(fileName, mBaseDir);
222 222
 
223 223
   // read DXF file
224
-  if (!mDrawing.loadDxf(fileName)) {
224
+  if (!mDrawing.loadDxf(fileName, mSettings.precision)) {
225 225
     std::cerr << "could not read DXF file \"" << fileName << "\""
226 226
               << std::endl;
227 227
     return false;
... ...
@@ -24,9 +24,10 @@ void Drawing::clear()
24 24
 /**
25 25
  * @brief add a DXF file to this drawing
26 26
  * @param[in] strFileName name of the DXF file to read
27
+ * @param[in] precision precision for entity to lines conversion
27 28
  * @return if the DXF file could be read
28 29
  */
29
-bool Drawing::addDxf(const std::string &strFileName)
30
+bool Drawing::addDxf(const std::string &strFileName, double precision)
30 31
 {
31 32
   // read DXF file
32 33
   dimeInput in;
... ...
@@ -45,6 +46,7 @@ bool Drawing::addDxf(const std::string &strFileName)
45 46
 
46 47
   // enumerate all entities and add them to drawing
47 48
   struct traverse_ctx ctx;
49
+  ctx.precision = precision;
48 50
   ctx.mpDrawing = this;
49 51
   model.traverseEntities(traverse_entity, &ctx);
50 52
 
... ...
@@ -54,12 +56,13 @@ bool Drawing::addDxf(const std::string &strFileName)
54 56
 /**
55 57
  * @brief load a DXF file to this drawing
56 58
  * @param[in] strFileName name of the DXF file to read
59
+ * @param[in] precision precision for entity to lines conversion
57 60
  * @return if the DXF file could be read
58 61
  */
59
-bool Drawing::loadDxf(const std::string &strFileName)
62
+bool Drawing::loadDxf(const std::string &strFileName, double precision)
60 63
 {
61 64
   clear();
62
-  return addDxf(strFileName);
65
+  return addDxf(strFileName, precision);
63 66
 }
64 67
 
65 68
 /**
... ...
@@ -25,16 +25,18 @@ public:
25 25
   /**
26 26
    * @brief add a DXF file to this drawing
27 27
    * @param[in] strFileName name of the DXF file to read
28
+   * @param[in] precision precision for entity to lines conversion
28 29
    * @return if the DXF file could be read
29 30
    */
30
-  bool addDxf(const std::string &strFileName);
31
+  bool addDxf(const std::string &strFileName, double precision);
31 32
 
32 33
   /**
33 34
    * @brief load a DXF file to this drawing
34 35
    * @param[in] strFileName name of the DXF file to read
36
+   * @param[in] precision precision for entity to lines conversion
35 37
    * @return if the DXF file could be read
36 38
    */
37
-  bool loadDxf(const std::string &strFileName);
39
+  bool loadDxf(const std::string &strFileName, double precision);
38 40
 
39 41
   /**
40 42
    * @brief improve paths in layers
... ...
@@ -3,15 +3,26 @@
3 3
  * Copyleft: CC-BY-SA http://creativecommons.org/licenses/by-sa/3.0/
4 4
  */
5 5
 
6
+#include <dime/entities/Circle.h>
6 7
 #include <dime/entities/Entity.h>
7 8
 #include <dime/State.h>
9
+#include <dime/util/Linear.h>
10
+#include <iostream>
11
+#include <math.h>
8 12
 #include <string>
9 13
 
10 14
 #include "drawing.h"
11 15
 #include "layer.h"
12 16
 #include "path.h"
17
+#include "point.h"
13 18
 #include "traverse.h"
14 19
 
20
+/// minimum number of segments to approximate circle with
21
+#define TRAVERSE_CIRCLE_NUM_SEG_MIN (16)
22
+
23
+/// maximum number of segments to approximate circle with
24
+#define TRAVERSE_CIRCLE_NUM_SEG_MAX (4096)
25
+
15 26
 /**
16 27
  * @brief process an entity during DXF traversal
17 28
  * @param[in] state current state of libdime
... ...
@@ -32,6 +43,32 @@ bool traverse_entity(const class dimeState * const state, dimeEntity *entity,
32 43
   dimeMatrix matrix;
33 44
   state->getMatrix(matrix);
34 45
 
46
+  /* special handling for some entities
47
+     to avoid libdime's inexact conversion to lines */
48
+  dimeArc     *arc;
49
+  dimeCircle  *circle;
50
+  dimeEllipse *ellipse;
51
+  if ((arc = dynamic_cast<dimeArc *>(entity)))
52
+    traverse_arc(arc, matrix, p_ctx->precision, layer);
53
+  else if ((circle = dynamic_cast<dimeCircle *>(entity)))
54
+    traverse_circle(circle, matrix, p_ctx->precision, layer);
55
+  else if ((ellipse = dynamic_cast<dimeEllipse *>(entity)))
56
+    traverse_ellipse(ellipse, matrix, p_ctx->precision, layer);
57
+  else
58
+    traverse_generic(entity, matrix, layer); // default: libdime conversion
59
+
60
+  return true; // continue enumeration
61
+}
62
+
63
+/**
64
+ * @brief process a generic geometric object during DXF traversal
65
+ * @param[in] entity pointer to entity
66
+ * @param[in] matrix current DXF transformation matrix
67
+ * @param[in] layer layer to add the entitiy to
68
+ */
69
+void traverse_generic(dimeEntity *entity, const dimeMatrix &matrix,
70
+                      Layer &layer)
71
+{
35 72
   // get geometry data
36 73
   dimeArray<dimeVec3f> vertices;
37 74
   dimeArray<int> indices;
... ...
@@ -63,7 +100,190 @@ bool traverse_entity(const class dimeState * const state, dimeEntity *entity,
63 100
         path = &layer.addPath();
64 101
     }
65 102
   }
103
+}
66 104
 
67
-  return true; // continue enumeration
105
+/**
106
+ * @brief process an arc during DXF traversal
107
+ * @param[in] circle pointer to arc entity
108
+ * @param[in] matrix current DXF transformation matrix
109
+ * @param[in] precision precision for conversion to lines
110
+ * @param[in] layer layer to add the entitiy to
111
+ */
112
+void traverse_arc(dimeArc *arc, const dimeMatrix &matrix,
113
+                  double precision, Layer &layer)
114
+{
115
+  // get parameters (not yet transformed)
116
+  dimeVec3f center;
117
+  arc->getCenter(center);
118
+  double radius = arc->getRadius();
119
+  double start = arc->getStartAngle() * M_PI / 180.0;
120
+  double end = arc->getEndAngle() * M_PI / 180.0;
121
+
122
+  // add arc to layer
123
+  traverse_add_circle(center, radius, start, end, precision, matrix, layer);
124
+}
125
+
126
+/**
127
+ * @brief process a circle during DXF traversal
128
+ * @param[in] circle pointer to circle entity
129
+ * @param[in] matrix current DXF transformation matrix
130
+ * @param[in] precision precision for conversion to lines
131
+ * @param[in] layer layer to add the entitiy to
132
+ */
133
+void traverse_circle(dimeCircle *circle, const dimeMatrix &matrix,
134
+                     double precision, Layer &layer)
135
+{
136
+  // get parameters and transform vertices
137
+  dimeVec3f center = circle->getCenter();
138
+  double radius = circle->getRadius();
139
+
140
+  // add circle to layer
141
+  traverse_add_circle(center, radius, 0.0, 2.0 * M_PI,
142
+                      precision, matrix, layer);
143
+}
144
+
145
+/**
146
+ * @brief process an ellipse during DXF traversal
147
+ * @param[in] circle pointer to ellipse entity
148
+ * @param[in] matrix current DXF transformation matrix
149
+ * @param[in] precision precision for conversion to lines
150
+ * @param[in] layer layer to add the entitiy to
151
+ */
152
+void traverse_ellipse(dimeEllipse *ellipse, const dimeMatrix &matrix,
153
+                      double precision, Layer &layer)
154
+{
155
+  // get parameters (not yet transformed)
156
+  dimeVec3f center = ellipse->getCenter();
157
+  dimeVec3f majorEnd = ellipse->getMajorAxisEndpoint();
158
+  double ratio = ellipse->getMinorMajorRatio();
159
+  double start = ellipse->getStartParam();
160
+  double end = ellipse->getEndParam();
161
+
162
+  // add circle to layer
163
+  traverse_add_ellipse(center, majorEnd, ratio, start, end,
164
+                       precision, matrix, layer);
165
+}
166
+
167
+/**
168
+ * @brief add a circle to the layer
169
+ * @param[in] center center point
170
+ * @param[in] radius radius
171
+ * @param[in] start start angle in radians
172
+ * @param[in] end end angle in radians
173
+ * @param[in] precision precision for conversion to lines
174
+ * @param[in] matrix current DXF transformation matrix
175
+ * @param[in] layer layer to add the entitiy to
176
+ */
177
+void traverse_add_circle(const dimeVec3f &center,
178
+                         double radius, double start, double end,
179
+                         double precision, const dimeMatrix &matrix,
180
+                         Layer &layer)
181
+{
182
+  // calculate number of segments to approximate part of circle with
183
+  unsigned int num_seg = traverse_calc_num_seg(radius, start, end, precision);
184
+
185
+  // loop over all angles to calculate point for
186
+  if (end <= start)
187
+    end += 2.0 * M_PI;
188
+  unsigned int seg;
189
+  Path &path = layer.addPath();
190
+  for (seg = 0; seg <= num_seg; ++seg) {
191
+    double angle = (start * (num_seg - seg) + end * seg) / num_seg;
192
+
193
+    // get point
194
+    double x = center.x + radius * cos(angle);
195
+    double y = center.y + radius * sin(angle);
196
+
197
+    // transform point via current matrix and add it to path
198
+    dimeVec3f vertex(x, y, 0.0);
199
+    matrix.multMatrixVec(vertex);
200
+    path.addPoint(vertex.x, vertex.y);
201
+
202
+  } // for seg
203
+}
204
+
205
+/**
206
+ * @brief add ellipse to the layer
207
+ * @param[in] center center point
208
+ * @param[in] majorEnd endpoint of major axis
209
+ * @param[in] ratio ratio of minor to major axis
210
+ * @param[in] start start angle in radians
211
+ * @param[in] end end angle in radians
212
+ * @param[in] precision precision for conversion to lines
213
+ * @param[in] matrix current DXF transformation matrix
214
+ * @param[in] layer layer to add the entitiy to
215
+ */
216
+void traverse_add_ellipse(const dimeVec3f &center, const dimeVec3f &majorEnd,
217
+                          double ratio, double start, double end,
218
+                          double precision, const dimeMatrix &matrix,
219
+                          Layer &layer)
220
+{
221
+  // calculate number of segments to approximate part of ellipse with
222
+  double majorRadius = (majorEnd - center).length();
223
+  double maxRadius = ratio <= 1.0 ? majorRadius : majorRadius * ratio;
224
+  unsigned int num_seg = traverse_calc_num_seg(maxRadius, start, end,
225
+                                               precision);
226
+
227
+  // build transformation matrix: union circle -> ellipse
228
+  double maj_x = majorEnd.x;
229
+  double maj_y = majorEnd.y;
230
+  double min_x = -ratio * maj_y;
231
+  double min_y =  ratio * maj_x;
232
+
233
+  // loop over all angles to calculate point for
234
+  if (end <= start)
235
+    end += 2.0 * M_PI;
236
+  unsigned int seg;
237
+  Path &path = layer.addPath();
238
+  for (seg = 0; seg <= num_seg; ++seg) {
239
+    double angle = (start * (num_seg - seg) + end * seg) / num_seg;
240
+
241
+    // get point on union circle
242
+    double uc_x = cos(angle);
243
+    double uc_y = sin(angle);
244
+    // transformation: union circle -> ellipse
245
+    double x = maj_x * uc_x + min_x * uc_y;
246
+    double y = maj_y * uc_x + min_y * uc_y;
247
+    // translate: move to center
248
+    x += center.x;
249
+    y += center.y;
250
+
251
+    // transform point via current matrix and add it to path
252
+    dimeVec3f vertex(x, y, 0.0);
253
+    matrix.multMatrixVec(vertex);
254
+    path.addPoint(vertex.x, vertex.y);
255
+
256
+  } // for seg
257
+}
258
+
259
+/**
260
+ * @brief calculate number of segments to approx. part of circle/ellipse with
261
+ * @param[in] maxRadius radius of circle / maximum radius of ellipse
262
+ * @param[in] start start angle in radians
263
+ * @param[in] end end angle in radians
264
+ * @param[in] precision precision for conversion to lines
265
+ * @return number of segments to approximate circle/ellipse with
266
+ */
267
+unsigned int traverse_calc_num_seg(double maxRadius, double start, double end,
268
+                                   double precision)
269
+{
270
+  // calculate number of segments for full circle/ellipse
271
+  unsigned int num_seg;
272
+  double dist;
273
+  // double number of segments until precision is met (or maximum reached)
274
+  for (num_seg = TRAVERSE_CIRCLE_NUM_SEG_MIN;
275
+       num_seg < TRAVERSE_CIRCLE_NUM_SEG_MAX; num_seg *= 2) {
276
+    // maximum distance of circle and regular polygon with num_seg sides
277
+    dist = maxRadius * (1.0 - cos(M_PI / num_seg));
278
+    // precision met -> done
279
+    if (dist < precision)
280
+      break;
281
+  }
282
+
283
+  // calculate number of segments for part of cirlce/ellipse
284
+  double angle = start < end ? end - start : 2.0 * M_PI + end - start;
285
+  num_seg = (unsigned int)ceil((double)num_seg * angle / (2.0 * M_PI));
286
+
287
+  return num_seg;
68 288
 }
69 289
 
... ...
@@ -6,13 +6,19 @@
6 6
 #ifndef TRAVERSE_H
7 7
 #define TRAVERSE_H
8 8
 
9
+#include <dime/entities/Arc.h>
10
+#include <dime/entities/Circle.h>
11
+#include <dime/entities/Ellipse.h>
9 12
 #include <dime/entities/Entity.h>
10 13
 #include <dime/State.h>
14
+#include <dime/util/Linear.h>
11 15
 
12 16
 #include "drawing.h"
17
+#include "layer.h"
13 18
 
14 19
 /// context structure for traverse entities callback
15 20
 struct traverse_ctx {
21
+  double  precision;  ///< precision for conversion to lines
16 22
   Drawing *mpDrawing; ///< the drawing to add the entities to
17 23
 };
18 24
 
... ...
@@ -26,5 +32,86 @@ struct traverse_ctx {
26 32
 bool traverse_entity(const class dimeState *const state, dimeEntity *entity,
27 33
                      void *vp_ctx);
28 34
 
35
+/**
36
+ * @brief process a generic geometric object during DXF traversal
37
+ * @param[in] entity pointer to entity
38
+ * @param[in] matrix current DXF transformation matrix
39
+ * @param[in] layer layer to add the entitiy to
40
+ */
41
+void traverse_generic(dimeEntity *entity, const dimeMatrix &matrix,
42
+                      Layer &layer);
43
+
44
+/**
45
+ * @brief process an arc during DXF traversal
46
+ * @param[in] circle pointer to arc entity
47
+ * @param[in] matrix current DXF transformation matrix
48
+ * @param[in] precision precision for conversion to lines
49
+ * @param[in] layer layer to add the entitiy to
50
+ */
51
+void traverse_arc(dimeArc *arc, const dimeMatrix &matrix,
52
+                  double precision, Layer &layer);
53
+
54
+/**
55
+ * @brief process a circle during DXF traversal
56
+ * @param[in] circle pointer to circle entity
57
+ * @param[in] matrix current DXF transformation matrix
58
+ * @param[in] precision precision for conversion to lines
59
+ * @param[in] layer layer to add the entitiy to
60
+ */
61
+void traverse_circle(dimeCircle *circle, const dimeMatrix &matrix,
62
+                     double precision, Layer &layer);
63
+
64
+/**
65
+ * @brief process an ellipse during DXF traversal
66
+ * @param[in] circle pointer to ellipse entity
67
+ * @param[in] matrix current DXF transformation matrix
68
+ * @param[in] precision precision for conversion to lines
69
+ * @param[in] layer layer to add the entitiy to
70
+ */
71
+void traverse_ellipse(dimeEllipse *ellipse, const dimeMatrix &matrix,
72
+                      double precision, Layer &layer);
73
+
74
+/**
75
+ * @brief add a circle to the layer
76
+ * @param[in] center center point
77
+ * @param[in] radius radius
78
+ * @param[in] start start angle in radians
79
+ * @param[in] end end angle in radians
80
+ * @param[in] precision precision for conversion to lines
81
+ * @param[in] matrix current DXF transformation matrix
82
+ * @param[in] layer layer to add the entitiy to
83
+ */
84
+void traverse_add_circle(const dimeVec3f &center,
85
+                         double radius, double start, double end,
86
+                         double precision, const dimeMatrix &matrix,
87
+                         Layer &layer);
88
+
89
+/**
90
+ * @brief add an ellipse to the layer
91
+ * @param[in] center center point
92
+ * @param[in] majorEnd endpoint of major axis
93
+ * @param[in] ratio ratio of minor to major axis
94
+ * @param[in] start start angle in radians
95
+ * @param[in] end end angle in radians
96
+ * @param[in] precision precision for conversion to lines
97
+ * @param[in] matrix current DXF transformation matrix
98
+ * @param[in] layer layer to add the entitiy to
99
+ */
100
+void traverse_add_ellipse(const dimeVec3f &center, const dimeVec3f &majorEnd,
101
+                          double ratio, double start, double end,
102
+                          double precision, const dimeMatrix &matrix,
103
+                          Layer &layer);
104
+
105
+/**
106
+ * @brief calculate number of segments to approx. part of circle/ellipse with
107
+ * @param[in] maxRadius radius of circle / maximum radius of ellipse
108
+ * @param[in] start start angle in radians
109
+ * @param[in] end end angle in radians
110
+ * @param[in] precision precision for conversion to lines
111
+ * @return number of segments to approximate circle/ellipse with
112
+ */
113
+unsigned int traverse_calc_num_seg(double maxRadius, double start, double end,
114
+                                   double precision);
115
+
29 116
 #endif // #ifndef TRAVERSE_H
30 117
 
31 118