From 325c5ec887d838ba1124ab2a8ae2a47eb0b8a30a Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 24 Nov 2021 18:27:21 +0100 Subject: [PATCH] Fix issue 0004791: DXF import fails for trivial circle --- src/Mod/Draft/App/DraftDxf.cpp | 5 ++++- src/Mod/Import/App/ImpExpDxf.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/App/DraftDxf.cpp b/src/Mod/Draft/App/DraftDxf.cpp index 230fe392fb..88a585ee17 100644 --- a/src/Mod/Draft/App/DraftDxf.cpp +++ b/src/Mod/Draft/App/DraftDxf.cpp @@ -163,6 +163,9 @@ void DraftDxfRead::OnReadInsert(const double* point, const double* scale, const std::string prefix = "BLOCKS "; prefix += name; prefix += " "; + auto checkScale = [=](double v) { + return v != 0.0 ? v : 1.0; + }; for(std::map > ::const_iterator i = layers.begin(); i != layers.end(); ++i) { std::string k = i->first; if(k.substr(0, prefix.size()) == prefix) { @@ -178,7 +181,7 @@ void DraftDxfRead::OnReadInsert(const double* point, const double* scale, const if (!comp.IsNull()) { Part::TopoShape* pcomp = new Part::TopoShape(comp); Base::Matrix4D mat; - mat.scale(scale[0],scale[1],scale[2]); + mat.scale(checkScale(scale[0]),checkScale(scale[1]),checkScale(scale[2])); mat.rotZ(rotation); mat.move(point[0]*optionScaling,point[1]*optionScaling,point[2]*optionScaling); pcomp->transformShape(mat,true); diff --git a/src/Mod/Import/App/ImpExpDxf.cpp b/src/Mod/Import/App/ImpExpDxf.cpp index dcd88ef138..e5cc1b632d 100644 --- a/src/Mod/Import/App/ImpExpDxf.cpp +++ b/src/Mod/Import/App/ImpExpDxf.cpp @@ -320,6 +320,9 @@ void ImpExpDxfRead::OnReadInsert(const double* point, const double* scale, const std::string prefix = "BLOCKS "; prefix += name; prefix += " "; + auto checkScale = [=](double v) { + return v != 0.0 ? v : 1.0; + }; for(std::map > ::const_iterator i = layers.begin(); i != layers.end(); ++i) { std::string k = i->first; if(k.substr(0, prefix.size()) == prefix) { @@ -335,7 +338,7 @@ void ImpExpDxfRead::OnReadInsert(const double* point, const double* scale, const if (!comp.IsNull()) { Part::TopoShape* pcomp = new Part::TopoShape(comp); Base::Matrix4D mat; - mat.scale(scale[0],scale[1],scale[2]); + mat.scale(checkScale(scale[0]),checkScale(scale[1]),checkScale(scale[2])); mat.rotZ(rotation); mat.move(point[0]*optionScaling,point[1]*optionScaling,point[2]*optionScaling); pcomp->transformShape(mat,true);