From 99d6f1f5b5e7cbe7bbd7aa7478e6e57ba660d7c9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 26 Nov 2016 08:17:20 +0000 Subject: [PATCH] DXF: Fix export of wireframe as 3D DXF. Before this commit, polylines got flattened but all other entities got exported with the proper Z coordinate. After this commit, all entities are exported with proper Z coordinate. Also, instead of exporting LWPOLYLINE (2d only), POLYLINE (2d/3d) is exported; as a bonus it is more compatible with 3rd party software, since it is older. --- CHANGELOG.md | 1 + src/exportvector.cpp | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64e1429..095eee6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Bug fixes: * Do not crash when applying a symmetry constraint to two points. * Fix TTF font metrics again (properly this time). * Fix the "draw back faces in red" option. + * Fix export of wireframe as 3D DXF. * Various minor crashes. 2.2 diff --git a/src/exportvector.cpp b/src/exportvector.cpp index c4f70bd..ca625ec 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -259,14 +259,17 @@ public: found = true; e->tag = 1; - DRW_LWPolyline polyline; + DRW_Polyline polyline; assignEntityDefaults(&polyline, e->style); - polyline.vertlist.push_back(new DRW_Vertex2D(start->pos.x, start->pos.y, 0.0)); - polyline.vertlist.push_back(new DRW_Vertex2D(next->pos.x, next->pos.y, 0.0)); + polyline.vertlist.push_back( + new DRW_Vertex(start->pos.x, start->pos.y, start->pos.z, 0.0)); + polyline.vertlist.push_back( + new DRW_Vertex(next->pos.x, next->pos.y, next->pos.z, 0.0)); while(next->getNext(e->style, &next)) { - polyline.vertlist.push_back(new DRW_Vertex2D(next->pos.x, next->pos.y, 0.0)); + polyline.vertlist.push_back( + new DRW_Vertex(next->pos.x, next->pos.y, next->pos.z, 0.0)); } - dxf->writeLWPolyline(&polyline); + dxf->writePolyline(&polyline); } if(!found && !loop) { @@ -479,16 +482,14 @@ public: List lv = {}; sb->MakePwlInto(&lv, SS.ExportChordTolMm()); hStyle hs = { (uint32_t)sb->auxA }; - DRW_LWPolyline polyline; + DRW_Polyline polyline; assignEntityDefaults(&polyline, hs); for(int i = 0; i < lv.n; i++) { Vector *v = &lv.elem[i]; - DRW_Vertex2D *vertex = new DRW_Vertex2D(); - vertex->x = v->x; - vertex->y = v->y; + DRW_Vertex *vertex = new DRW_Vertex(v->x, v->y, v->z, 0.0); polyline.vertlist.push_back(vertex); } - dxf->writeLWPolyline(&polyline); + dxf->writePolyline(&polyline); lv.Clear(); } @@ -527,7 +528,8 @@ public: spline.ncontrol = sb->deg + 1; makeKnotsFor(&spline); for(int i = 0; i <= sb->deg; i++) { - spline.controllist.push_back(new DRW_Coord(sb->ctrl[i].x, sb->ctrl[i].y, 0.0)); + spline.controllist.push_back( + new DRW_Coord(sb->ctrl[i].x, sb->ctrl[i].y, sb->ctrl[i].z)); if(isRational) spline.weightlist.push_back(sb->weight[i]); } dxf->writeSpline(&spline);