summaryrefslogtreecommitdiff
path: root/src/export.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2010-12-25 23:12:34 (GMT)
committerMarius Kintel <marius@kintel.net>2010-12-25 23:12:34 (GMT)
commitd0d266b83e777006a7badfd5cccb3980a3c31dd1 (patch)
treeda0728902ed0be74c2328872fca74311734a9095 /src/export.cc
parent1bc4fe5d4d7d12e9d1777221780c2ad6551aa9b0 (diff)
parent592ca6abadcb6443629be4407b973279a891278c (diff)
merged with master
Diffstat (limited to 'src/export.cc')
-rw-r--r--src/export.cc53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/export.cc b/src/export.cc
index 71ebe8f..215f936 100644
--- a/src/export.cc
+++ b/src/export.cc
@@ -154,6 +154,20 @@ void export_off(CGAL_Nef_polyhedron*, QTextStream&, QProgressDialog*)
void export_dxf(CGAL_Nef_polyhedron *root_N, QTextStream &output, 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
+ output << " 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
output << " 0\n"
<< "SECTION\n"
@@ -169,26 +183,27 @@ void export_dxf(CGAL_Nef_polyhedron *root_N, QTextStream &output, QProgressDialo
DxfData dd(*root_N);
for (int i=0; i<dd.paths.size(); i++)
{
- 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;
- output << " 0\n"
- << "LINE\n";
- // Some importers (e.g. Inkscape) needs a layer to be specified
- output <<" 8\n"
- << "0\n"
- << " 10\n"
- << x1 << "\n"
- << " 11\n"
- << x2 << "\n"
+ 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.
+ output << " 0\n"
+ << "LWPOLYLINE\n"
+ << " 8\n" // Some importers (e.g. Inkscape) need a layer to be specified
+ << "0\n"
+ << " 90\n" // number of vertices
+ << dd.paths[i].points.size() << "\n"
+ << " 70\n" // polygon flag (closed, ...)
+ << (dd.paths[i].is_closed ? 1 : 0) << "\n";
+ // add all points
+ for (int j=0; j<dd.paths[i].points.size(); j++) {
+ DxfData::Point *p = dd.paths[i].points[j];
+ output <<" 10\n"
+ << p->x << "\n"
<< " 20\n"
- << y1 << "\n"
- << " 21\n"
- << y2 << "\n";
+ << p->y << "\n";
}
}
contact: Jan Huwald // Impressum