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.
This commit is contained in:
whitequark 2016-11-26 08:17:20 +00:00
parent aaab8a09d4
commit 41365c5f9f
2 changed files with 14 additions and 11 deletions

View File

@ -44,6 +44,7 @@ Bug fixes:
* Do not crash when applying a symmetry constraint to two points. * Do not crash when applying a symmetry constraint to two points.
* Fix TTF font metrics again (properly this time). * Fix TTF font metrics again (properly this time).
* Fix the "draw back faces in red" option. * Fix the "draw back faces in red" option.
* Fix export of wireframe as 3D DXF.
* Various minor crashes. * Various minor crashes.
2.2 2.2

View File

@ -121,7 +121,7 @@ public:
} }
} }
DRW_LWPolyline polyline; DRW_Polyline polyline;
auto startFunc = [&](PolylineBuilder::Vertex *start, auto startFunc = [&](PolylineBuilder::Vertex *start,
PolylineBuilder::Vertex *next, PolylineBuilder::Vertex *next,
@ -129,16 +129,19 @@ public:
hStyle hs = { e->kind }; hStyle hs = { e->kind };
polyline = {}; polyline = {};
assignEntityDefaults(&polyline, hs); assignEntityDefaults(&polyline, hs);
polyline.vertlist.push_back(new DRW_Vertex2D(start->pos.x, start->pos.y, 0.0)); polyline.vertlist.push_back(
polyline.vertlist.push_back(new DRW_Vertex2D(next->pos.x, next->pos.y, 0.0)); 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));
}; };
auto nextFunc = [&](PolylineBuilder::Vertex *next, PolylineBuilder::Edge *e) { auto nextFunc = [&](PolylineBuilder::Vertex *next, PolylineBuilder::Edge *e) {
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));
}; };
auto endFunc = [&]() { auto endFunc = [&]() {
dxf->writeLWPolyline(&polyline); dxf->writePolyline(&polyline);
}; };
auto aloneFunc = [&](PolylineBuilder::Edge *e) { auto aloneFunc = [&](PolylineBuilder::Edge *e) {
@ -357,16 +360,14 @@ public:
List<Vector> lv = {}; List<Vector> lv = {};
sb->MakePwlInto(&lv, SS.ExportChordTolMm()); sb->MakePwlInto(&lv, SS.ExportChordTolMm());
hStyle hs = { (uint32_t)sb->auxA }; hStyle hs = { (uint32_t)sb->auxA };
DRW_LWPolyline polyline; DRW_Polyline polyline;
assignEntityDefaults(&polyline, hs); assignEntityDefaults(&polyline, hs);
for(int i = 0; i < lv.n; i++) { for(int i = 0; i < lv.n; i++) {
Vector *v = &lv.elem[i]; Vector *v = &lv.elem[i];
DRW_Vertex2D *vertex = new DRW_Vertex2D(); DRW_Vertex *vertex = new DRW_Vertex(v->x, v->y, v->z, 0.0);
vertex->x = v->x;
vertex->y = v->y;
polyline.vertlist.push_back(vertex); polyline.vertlist.push_back(vertex);
} }
dxf->writeLWPolyline(&polyline); dxf->writePolyline(&polyline);
lv.Clear(); lv.Clear();
} }
@ -403,7 +404,8 @@ public:
spline.ncontrol = sb->deg + 1; spline.ncontrol = sb->deg + 1;
makeKnotsFor(&spline); makeKnotsFor(&spline);
for(int i = 0; i <= sb->deg; i++) { 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]); if(isRational) spline.weightlist.push_back(sb->weight[i]);
} }
dxf->writeSpline(&spline); dxf->writeSpline(&spline);