Fix issue 0004791: DXF import fails for trivial circle

This commit is contained in:
wmayer
2021-11-24 18:27:21 +01:00
parent c9a74d40d2
commit 325c5ec887
2 changed files with 8 additions and 2 deletions

View File

@@ -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<std::string,std::vector<Part::TopoShape*> > ::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);

View File

@@ -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<std::string,std::vector<Part::TopoShape*> > ::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);