diff options
author | Marius Kintel <marius@kintel.net> | 2011-06-05 17:41:47 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-06-05 17:41:47 (GMT) |
commit | fe5e199b79dd02e312d8f001d7faf6adb2dc9fe9 (patch) | |
tree | d539c2505a5c5f4af1abbea8b0de1a7827342a40 /src/export.cc | |
parent | fef3210b240369bd0ca20569470fcf56c143434c (diff) |
Revert "Output LWPOLYLINE objects instead of LINE for DXF export. Patch submitted by Lars Kruse"
This reverts commit 060a6c654de5ebd14ccb889881fa6c4d3fb9d763.
The reason is that the output DXF won't import in a number of applications due to a malformed DXF (AutoCAD, Solidworks). The correct fix is probably to use a DXF library to generate a correct DXF. This is only a case for more recent (R14+) versions of DXF, e.g. to be able to use the LWPOLYLINE entity.
Diffstat (limited to 'src/export.cc')
-rw-r--r-- | src/export.cc | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/src/export.cc b/src/export.cc index 884e139..8e0ab16 100644 --- a/src/export.cc +++ b/src/export.cc @@ -167,20 +167,6 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * } setlocale(LC_NUMERIC, "C"); // Ensure radix is . (not ,) in output - - // Some importers (e.g. QCAD) needs a HEADER section specifying AutoCAD 2000 as - // the file format for LWPOLYLINE entities to work - fprintf(f, " 0\n" - "SECTION\n" - " 2\n" - "HEADER\n" - " 9\n" - "$ACADVER\n" - " 1\n" - "AC1015\n" - " 0\n" - "ENDSEC\n"); - // Some importers (e.g. Inkscape) needs a BLOCKS section to be present fprintf(f, " 0\n" "SECTION\n" @@ -197,29 +183,26 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QString filename, QProgressDialog * DxfData dd(*root_N); for (int i=0; i<dd.paths.size(); i++) { - if (dd.paths[i].points.size() < 2) - // not a valid polygon - continue; - // Use the LWPOLYLINE class - this makes it easier to handle complete - // objects (as paths) in Inkscape. - fprintf(f, " 0\n"); - fprintf(f, "LWPOLYLINE\n"); - // Some importers (e.g. Inkscape) need a layer to be specified - fprintf(f, " 8\n"); - fprintf(f, "0\n"); - // number of vertices - fprintf(f, " 90\n"); - fprintf(f, "%d\n", dd.paths[i].points.size()); - // polygon flag (closed, ...) - fprintf(f, " 70\n"); - fprintf(f, "%d\n", dd.paths[i].is_closed ? 1 : 0); - // add all points - for (int j=0; j<dd.paths[i].points.size(); j++) { - DxfData::Point *p = dd.paths[i].points[j]; + for (int j=1; j<dd.paths[i].points.size(); j++) { + DxfData::Point *p1 = dd.paths[i].points[j-1]; + DxfData::Point *p2 = dd.paths[i].points[j]; + double x1 = p1->x; + double y1 = p1->y; + double x2 = p2->x; + double y2 = p2->y; + fprintf(f, " 0\n"); + fprintf(f, "LINE\n"); + // Some importers (e.g. Inkscape) needs a layer to be specified + fprintf(f, " 8\n"); + fprintf(f, "0\n"); fprintf(f, " 10\n"); - fprintf(f, "%f\n", p->x); + fprintf(f, "%f\n", x1); + fprintf(f, " 11\n"); + fprintf(f, "%f\n", x2); fprintf(f, " 20\n"); - fprintf(f, "%f\n", p->y); + fprintf(f, "%f\n", y1); + fprintf(f, " 21\n"); + fprintf(f, "%f\n", y2); } } |