-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathentities2elements.cpp
579 lines (484 loc) · 22.1 KB
/
entities2elements.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
/*
* Code for converting dxf entities to SVG elements
* There are multiple ways for converting different items
* If possible most DXF enetities will be converted to paths because that is the most flexable object
*
* Author:
* Matt Squires <[email protected]>
*
* Copyright (C) 2005 Matt Squires
*
* Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
*/
/*
Matt Squires
SoC 2005
*/
#include "entities2elements.h"
#include "tables2svg_info.h"
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string.h>
// The names indicate the DXF entitiy first and the SVG element last
// Common elements
static char *to_arc(double bulge, double r, double start_ang, double end_ang, int precision, const char * delim, const char * units, double scaling, char *out) {
// This is used for arcs, polylines, and lwpolylines
char temp[50];
// Assume that we are adding to the input and not starting over
strcat(out," A ");
// For arcs there is only one radius
strcat(out,gcvt(scaling*r, precision, temp));
strcat(out,",");
strcat(out,gcvt(scaling*r, precision, temp));
strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only
// Determine if it is a large arc
if ((end_ang > start_ang) && ((end_ang - start_ang) > 180)) {
//strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag
strcat(out," 1, "); // Large arc flag...Always use a zero sweep flag
} else if ((end_ang < start_ang) && ((360 + end_ang - start_ang) >= 180)){
strcat(out, " 1, "); // Large arc flag...Always use a zero sweep flag
} else {
//strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag
strcat(out," 0,");
}
// This may be easier if I allow r to be plus and minus, but for now this works
if (bulge > 0) {
strcat(out,"0 ");
}
else{
strcat(out,"1 ");
}
return out;
}
// Build Coordinate
// Pairs of coords with units will be used so often build a function
static char *coord(const entity &ent, int precision, const char* delim, const char * units, double scaling, char *out) {
// Pairs of coords with units will be used so often build a function build a dedicated function for returning such
char temp[20];
if (units != NULL) scaling = 1; // If units have been defined then ignore the scaling parameter
strcat(out, gcvt(scaling*ent.ret_x(), precision, temp)); // There must be a better function for double to ascii conversion that is defined in most libraries
if (units != NULL) strcat(out, units);
strcat(out, delim);
strcat(out, gcvt(-scaling*ent.ret_y(), precision, temp)); // Because SVG has a the Y-axis pointed down multiply by -1
if (units != NULL) strcat(out, units);
strcat(out, " ");
return out;
}
// DXF Polyline -> SVG
// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported
void pline2svg(const polyline &pline, int type, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// 0 is pline2path
// 1 is pline2pline
// 2 is pline2polygon
double mag_bulge = 0;
double prev_mag_bulge = 0;
std::vector<vertex > points = pline.ret_points();
if (type < 1) {
// Put the first Move To at the first, everything else will be a lineto
const char *delim = " ";
strcat(out, "M ");
coord(points[0], precision, delim, units, scaling, out);
prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude
if (prev_mag_bulge > pow(0.1,precision)) {
to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out);
}
for (size_t i = 1; i < points.size(); i++) {
if ( prev_mag_bulge < pow(0.1,precision) ) {
// If the previous point was a bulge then don't use a line to
strcat(out, "L ");
}
coord(points[i], precision, delim, units, scaling, out);
// If bulge > some precsion then add bulge
mag_bulge = sqrt(pow(points[i].ret_bulge(),2));
if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )) {
to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out);
}
prev_mag_bulge = mag_bulge;
}
if ( pline.is_closed() ) {
strcat(out,"z");
}
strcat(out,"\" ");
}
else{
const char *delim = ",";
for (size_t i = 0; i < points.size(); i++) {
coord(points[i], precision, delim, NULL, scaling, out);
// If bulge > some precsion then add bulge
}
// if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point
if ( (type == 1) && pline.is_closed() ) {
coord(points[0], precision, delim, NULL, scaling, out);
}
}
}
char* pline2path(const polyline &pline, const char * units, double scaling, const tables &plot_info, char * out) {
// Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
strcat(out, "<path d=\"");
int precision = 6;
pline2svg(pline, 0, precision, units, scaling, plot_info, out);
// Add some line information
strcat(out, "fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
pattern2dasharray(plot_info.ret_ltype( pline.ret_ltype_name(), pline.ret_layer_name() ), precision, scaling, out); // Add the linetype information
strcat(out,"/>\n");
return out;
}
char* pline2pline(const polyline &pline, const char * units, double scaling, const tables &plot_info, char * out) {
// Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves
int precision = 6;
strcat(out, "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
ltype linfo = plot_info.ret_ltype(pline.ret_ltype_name(), pline.ret_layer_name());
pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
strcat(out, "points=\"");
//strcat(out,"<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" points=\"");
pline2svg(pline, 1, precision, units, scaling, plot_info, out);
// Add some line information
// if the DXF pline is closed then add an extra point
strcat(out, "\"/>\n");
return out;
}
//char* pline2polygon(polyline pline, const char * units, double scaling, const tables &plot_info) {
// Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed
//return pline2svg(pline, 2, 6, units, double scaling,out);
//}
// DXF LWPolyline -> SVG
// This could be a template with polyline and lwpolyline but right now it is not that important
void lwpline2svg(const lwpolyline &pline, int type, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// 0 is pline2path
// 1 is pline2pline
// 2 is pline2polygon
double mag_bulge = 0;
double prev_mag_bulge = 0;
std::vector<vertex> points = pline.ret_points();
if (type < 1) {
const char *delim = " ";
// Put the first Move To at the first, everything else will be a lineto
strcat(out, "M ");
coord(points[0], precision, delim, NULL, scaling, out);
prev_mag_bulge = sqrt(pow(points[0].ret_bulge(), 2)); // Because the bulge value can be positive or negative calculate the magnitude
if (prev_mag_bulge > pow(0.1,precision)) {
to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out);
}
for (size_t i = 1; i < points.size(); i++) {
if (prev_mag_bulge < pow(0.1, precision)) {
// If the previous point was a bulge then don't use a line to
strcat(out, "L ");
}
coord(points[i], precision, delim, NULL , scaling, out);
// If bulge > some precsion then add bulge
mag_bulge = sqrt(pow(points[i].ret_bulge(), 2));
if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )) { // Make sure the final point doesn't add a bulge on accident
to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out);
}
prev_mag_bulge = mag_bulge;
}
if (pline.is_closed()) {
strcat(out, "z");
}
strcat(out, "\" ");
}
else{
const char *delim = ",";
for (const auto &point : points) {
coord(point, precision, delim, units, scaling, out);
// If bulge > some precsion then add bulge
}
// if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point
if ((type == 1) && pline.is_closed()) {
coord(points[0], precision, delim, units, scaling, out);
}
}
}
char* lwpline2path(const lwpolyline &pline, const char * units, double scaling, const tables &plot_info, char *out) {
// Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
const int precision = 6;
strcat(out, "<path d=\"");
lwpline2svg(pline, 0, precision, units, scaling, plot_info, out);
// Add some line information
strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
pattern2dasharray(plot_info.ret_ltype(pline.ret_ltype_name(), pline.ret_layer_name()), precision, scaling, out); // Add the linetype information
strcat(out,"/>\n");
return out;
}
// DXF ARC -> SVG
char* arc2path(const arc &a, int precision, const char *units, double scaling, const tables &plot_info, char *out) {
// So far this appears to be the only way to convert arcs into something recognized by SVG
char temp[20];
strcat(out, "<path d=\"M");
// Calculate the starting point from the center and the start angle. As far as I can tell the rotation is CCW in the dxf notation and it in degrees
strcat(out, gcvt(scaling*(a.ret_x()+a.ret_radius()*cos( a.ret_srt_ang_rads())), precision, temp));
strcat(out, " ");
strcat(out, gcvt(-1*scaling*(a.ret_y()+a.ret_radius()*sin( a.ret_srt_ang_rads())), precision, temp));
strcat(out, " A ");
// For arcs there is only one radius
strcat(out, gcvt(scaling*a.ret_radius(), precision, temp));
strcat(out, ",");
strcat(out, gcvt(scaling*a.ret_radius(), precision, temp));
strcat(out, " 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only
// Determine if it is a large arc
if ((a.ret_end_ang() > a.ret_srt_ang()) && ((a.ret_end_ang() - a.ret_srt_ang()) > 180)) {
strcat(out, " 1,0 "); // Large arc flag...Always use a zero sweep flag
}
else if ((a.ret_end_ang() < a.ret_srt_ang()) && ((360 + a.ret_end_ang() - a.ret_srt_ang()) >= 180)){
strcat(out, " 1,0 "); // Large arc flag...Always use a zero sweep flag
} else {
strcat(out, " 0,0 "); // Small arc flag...Always use a zero sweep flag
}
//The final point
strcat(out, gcvt(scaling*(a.ret_x()+a.ret_radius()*cos( a.ret_end_ang_rads() )), precision, temp));
strcat(out, ",");
strcat(out, gcvt(-1*scaling*(a.ret_y()+a.ret_radius()*sin( a.ret_end_ang_rads() )), precision, temp));
strcat(out, "\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
ltype linfo = plot_info.ret_ltype(a.ret_ltype_name(), a.ret_layer_name());
pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
strcat(out, "/>\n");
return out;
}
// DXF Circle -> SVG
char* circle2circle(const circle &circ, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// Direct conversion of DXF circle to SVG circle
char temp[1000] = "\" cy=\"";
strcat(out, "<circle cx=\"");
coord(circ, precision, temp, units, scaling, out);
strcat(out, "\" r=\"");
strcat(out, gcvt(circ.ret_radius(), precision, temp));
strcat(out, units);
strcat(out, "\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
ltype linfo = plot_info.ret_ltype(circ.ret_ltype_name(), circ.ret_layer_name());
//plot_info.ret_ltype(ent_ptr->ret_ltype_name(), ent_ptr->ret_layer_name());
pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
//pattern2dasharray(plot_info.ret_ltype(ent_ptr->ret_ltype_name(), ent_ptr->ret_layer_name()), precision, scaling, out); // Add the linetype information
strcat(out, "/>\n");
return out;
}
char* circle2path(const circle &circ, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// Conversion of DXF circle to SVG circle assuming the path will represent the circle
char temp[20];
strcat(out, "<path d=\"M");
// The starting point is x-r,y so subtract off the radius from the x coord
strcat(out, gcvt(circ.ret_x()-circ.ret_radius(), precision, temp));
strcat(out, " ");
strcat(out, gcvt(circ.ret_y(), precision, temp));
strcat(out, " a");
strcat(out, gcvt(circ.ret_radius(), precision, temp));
strcat(out, ",");
strcat(out, gcvt(circ.ret_radius(), precision, temp));
strcat(out, "0 0,0 0,0\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" />\n");
return out;
}
// DXF Line -> SVG
char* line2line(const line &ln, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// Directly convert DXF to SVG because it works
char temp[20];
strcat(out, "<line x1=\"");
strcat(out, gcvt(ln.ret_x(), precision, temp));
strcat(out, units);
strcat(out, "\" y1=\"");
strcat(out, gcvt(-1*ln.ret_y(), precision, temp)); // Put in an extra minus because of the way SVG has defined the axis
strcat(out, units);
strcat(out, "\" x2=\"");
strcat(out, gcvt(ln.ret_xf(), precision, temp));
strcat(out, units);
strcat(out, "\" y2=\"");
strcat(out, gcvt(-1*ln.ret_yf(), precision, temp)); // Put in an extra minus because of the way SVG has defined the axis
strcat(out, units);
strcat(out, "\" stroke-width=\"1\" stroke=\"black\" ");
ltype linfo = plot_info.ret_ltype(ln.ret_ltype_name(), ln.ret_layer_name());
pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
strcat(out, " />");
return out;
}
char* line2path(const line &ln, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// Convert DXF line to SVG path
char temp[20];
strcat(out, "<path d=\"M");
strcat(out, gcvt(scaling*ln.ret_x(), precision, temp));
strcat(out, " ");
strcat(out, gcvt(scaling*ln.ret_y(), precision, temp));
strcat(out, " L");
strcat(out, gcvt(scaling*ln.ret_xf(), precision, temp));
strcat(out, " ");
strcat(out, gcvt(scaling*ln.ret_yf(), precision, temp));
strcat(out, "\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" /");
strcat(out, " />");
return out;
}
// DXF Text -> SVG
char* text2text(const text &txt, int precision, const char * units, double scaling, const tables &plot_info, char *out) {
// Directly convert DXF to SVG because it works
char temp[100];
// If the text is rotated use the transform matrix
if ( txt.ret_txt_rot() > precision ) {
strcat(out, "<g transform=\"matrix(");
strcat(out, gcvt(cos(0.017453*txt.ret_txt_rot()), precision, temp));
strcat(out, " ");
strcat(out, gcvt(sin(0.017453*txt.ret_txt_rot()), precision, temp));
strcat(out, " ");
strcat(out, gcvt(-sin(0.017453*txt.ret_txt_rot()), precision, temp));
strcat(out, " ");
strcat(out, gcvt(cos(0.017453*txt.ret_txt_rot()), precision, temp));
strcat(out, " 0 0)\" >\n");
strcat(out, "<text x=\"");
}
else{
strcat(out, "<text x=\"");
}
strcat(out, gcvt(txt.ret_x(), precision, temp));
strcat(out, units);
strcat(out, "\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis
strcat(out, gcvt(txt.ret_y(), precision, temp));
strcat(out, units);
strcat(out, "\" font-family=\"Verdana\" font-size=\"");
strcat(out, gcvt(scaling*txt.ret_txt_ht(), precision, temp));
strcat(out, "\" Fill=\"black\"");
strcat(out," >");
// Now put in the text
strcat(out,txt.ret_text());
// Now close the text element
strcat(out,"</text>");
// If the text was rotated finish off the tranform group
if ( txt.ret_txt_rot() > precision ) {
strcat(out,"</g>");
}
return out;
}
// DXF Insert -> SVG
char* insert2group(const insert &in, int precision, const char * units, double scaling, const tables &plot_info, const blocks &blks, char *out) {
char tmp_char[400000];
// get the block using the name from the insert information
const block &blk = blks.ret_block(in.name());
// For now just translations MBS 22 Aug 05
strcat(out, "<g transform=\"matrix(1,0,0,1,");
strcat(out, gcvt(scaling*in.ret_x(), precision, tmp_char));
strcat(out, ",");
strcat(out, gcvt(-scaling*in.ret_y(), precision, tmp_char));
strcat(out, ")\" >\n");
tmp_char[0] = 0;
// Now convert the entities in the block
const std::vector<polyline> &plines = blk.ret_plines();
const std::vector<lwpolyline> &lwplines = blk.ret_lwplines();
const std::vector<arc> &arcs = blk.ret_arcs();
const std::vector<circle> &circs = blk.ret_circles();
const std::vector<line> &lns = blk.ret_lines();
const std::vector<text> &txts = blk.ret_texts();
for(const auto &i : plines) {
strcat(out, pline2pline(i, units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
for(const auto &i : lwplines) {
strcat(out, lwpline2path(i, units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
for(const auto &i : arcs) {
strcat(out, arc2path(i, 6,units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
for(const auto &i : circs) {
strcat(out, circle2circle(i, 6, units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
for(const auto &i : lns) {
strcat(out, line2line(i, 6, units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
for(const auto &i : txts) {
strcat(out, text2text(i, 6, units, scaling, plot_info, tmp_char));
strcat(out, "\n");
tmp_char[0] = 0;
}
// End the group
strcat(out,"</g>");
return out;
}
void write_by_layer(const entities &ents, const tables &tbls, const blocks &blks, double scaling, const char * units, const char * layer) {
// output_type = 0 is to std:out
// output_type = 1 is to the input filename but with .dxf on the end
// For now everything will go to stdout later may directed to other places
// Get the various file informations as dependent on the layer type
const std::vector<polyline> &plines = ents.ret_plines(layer);
const std::vector<lwpolyline> &lwplines = ents.ret_lwplines(layer);
const std::vector<arc> &arcs = ents.ret_arcs(layer);
const std::vector<circle> &circs = ents.ret_circles(layer);
const std::vector<line> &lns = ents.ret_lines(layer);
const std::vector<text> &txts = ents.ret_texts(layer);
const std::vector<insert> &ins = ents.ret_inserts(layer);
// It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better
char tmp_char[100000];
for(const auto &i : plines) {
std::cout << "\t" << pline2path(i, NULL, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : lwplines) {
std::cout << "\t" << lwpline2path(i, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : arcs) {
std::cout << "\t" << arc2path(i, 6,units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : circs) {
std::cout << "\t" << circle2circle(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : lns) {
std::cout << "\t" << line2line(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : txts) {
std::cout << "\t" << text2text(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : ins) {
std::cout << "\t" << insert2group(i, 6, units, scaling, tbls, blks, tmp_char) << std::endl;
tmp_char[0] = 0;
}
}
void write_all(const entities &ents, const tables &tbls, const blocks &blks, double scaling, const char * units) {
// output_type = 0 is to std:out
// output_type = 1 is to the input filename but with .dxf on the end
// For now everything will go to stdout later may directed to other places
// Get the various file informations as dependent on the layer type
const std::vector<polyline> &plines = ents.ret_plines();
const std::vector<lwpolyline> &lwplines = ents.ret_lwplines();
const std::vector<arc> &arcs = ents.ret_arcs();
const std::vector<circle> &circs = ents.ret_circles();
const std::vector<line> &lns = ents.ret_lines();
const std::vector<text> &txts = ents.ret_texts();
const std::vector<insert> &ins = ents.ret_inserts();
// It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better
char tmp_char[100000];
for(const auto &i : plines) {
std::cout << "\t" << pline2path(i, NULL, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : lwplines) {
std::cout << "\t" << lwpline2path(i, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : arcs) {
std::cout << "\t" << arc2path(i, 6,units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : circs) {
std::cout << "\t" << circle2circle(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : lns) {
std::cout << "\t" << line2line(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : txts) {
std::cout << "\t" << text2text(i, 6, units, scaling, tbls, tmp_char) << std::endl;
tmp_char[0] = 0;
}
for(const auto &i : ins) {
std::cout << "\t" << insert2group(i, 6, units, scaling, tbls, blks, tmp_char) << std::endl;
tmp_char[0] = 0;
}
}