Fix issue 0004791: DXF import fails for trivial circle

This commit is contained in:
wmayer
2022-01-05 01:05:51 +01:00
committed by Uwe
parent 1caea909b5
commit 1ffd8d553b
2 changed files with 8 additions and 2 deletions
+4 -1
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);
+4 -1
View File
@@ -313,6 +313,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) {
@@ -328,7 +331,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);