From b3a946bd929658aed58ee861f8bc6aaf6db19a1f Mon Sep 17 00:00:00 2001 From: "Tim V. Shaporev" Date: Sat, 25 Jan 2014 18:43:33 +0400 Subject: [PATCH] fixup issue 593 --- src/dxfdata.cc | 23 +-- .../dxf/nothing-decimal-comma-separated.dxf | 140 ++++++++++++++++++ .../dxf/nothing-decimal-comma-separated.scad | 2 + ...thing-decimal-comma-separated-expected.png | Bin 0 -> 1947 bytes ...thing-decimal-comma-separated-expected.png | Bin 0 -> 1947 bytes ...thing-decimal-comma-separated-expected.png | Bin 0 -> 1947 bytes 6 files changed, 155 insertions(+), 10 deletions(-) create mode 100644 testdata/dxf/nothing-decimal-comma-separated.dxf create mode 100644 testdata/scad/dxf/nothing-decimal-comma-separated.scad create mode 100644 tests/regression/cgalpngtest/nothing-decimal-comma-separated-expected.png create mode 100644 tests/regression/opencsgtest/nothing-decimal-comma-separated-expected.png create mode 100644 tests/regression/throwntogethertest/nothing-decimal-comma-separated-expected.png diff --git a/src/dxfdata.cc b/src/dxfdata.cc index 9b61b939..4afe512f 100644 --- a/src/dxfdata.cc +++ b/src/dxfdata.cc @@ -175,7 +175,7 @@ DxfData::DxfData(double fn, double fs, double fa, in_blocks_section = iddata == "BLOCKS"; } else if (mode == "LINE") { - ADD_LINE(xverts[0], yverts[0], xverts[1], yverts[1]); + ADD_LINE(xverts.at(0), yverts.at(0), xverts.at(1), yverts.at(1)); } else if (mode == "LWPOLYLINE") { assert(xverts.size() == yverts.size()); @@ -185,12 +185,12 @@ DxfData::DxfData(double fn, double fs, double fa, ADD_LINE(xverts[i-1], yverts[i-1], xverts[i%numverts], yverts[i%numverts]); } if (dimtype & 0x01) { // closed polyline - ADD_LINE(xverts[numverts-1], yverts[numverts-1], xverts[0], yverts[0]); + ADD_LINE(xverts.at(numverts-1), yverts.at(numverts-1), xverts.at(0), yverts.at(0)); } } else if (mode == "CIRCLE") { int n = Calc::get_fragments_from_r(radius, fn, fs, fa); - Vector2d center(xverts[0], yverts[0]); + Vector2d center(xverts.at(0), yverts.at(0)); for (int i = 0; i < n; i++) { double a1 = (2*M_PI*i)/n; double a2 = (2*M_PI*(i+1))/n; @@ -199,7 +199,7 @@ DxfData::DxfData(double fn, double fs, double fa, } } else if (mode == "ARC") { - Vector2d center(xverts[0], yverts[0]); + Vector2d center(xverts.at(0), yverts.at(0)); int n = Calc::get_fragments_from_r(radius, fn, fs, fa); while (arc_start_angle > arc_stop_angle) arc_stop_angle += 360.0; @@ -217,9 +217,9 @@ DxfData::DxfData(double fn, double fs, double fa, // Commented code is meant as documentation of vector math while (ellipse_start_angle > ellipse_stop_angle) ellipse_stop_angle += 2 * M_PI; // Vector2d center(xverts[0], yverts[0]); - Vector2d center(xverts[0], yverts[0]); + Vector2d center(xverts.at(0), yverts.at(0)); // Vector2d ce(xverts[1], yverts[1]); - Vector2d ce(xverts[1], yverts[1]); + Vector2d ce(xverts.at(1), yverts.at(1)); // double r_major = ce.length(); double r_major = sqrt(ce[0]*ce[0] + ce[1]*ce[1]); // double rot_angle = ce.angle(); @@ -270,10 +270,10 @@ DxfData::DxfData(double fn, double fs, double fa, double ly1 = this->points[blockdata[iddata][i].idx[0]][1] * ellipse_stop_angle; double lx2 = this->points[blockdata[iddata][i].idx[1]][0] * ellipse_start_angle; double ly2 = this->points[blockdata[iddata][i].idx[1]][1] * ellipse_stop_angle; - double px1 = (cos(a)*lx1 - sin(a)*ly1) * scale + xverts[0]; - double py1 = (sin(a)*lx1 + cos(a)*ly1) * scale + yverts[0]; - double px2 = (cos(a)*lx2 - sin(a)*ly2) * scale + xverts[0]; - double py2 = (sin(a)*lx2 + cos(a)*ly2) * scale + yverts[0]; + double px1 = (cos(a)*lx1 - sin(a)*ly1) * scale + xverts.at(0); + double py1 = (sin(a)*lx1 + cos(a)*ly1) * scale + yverts.at(0); + double px2 = (cos(a)*lx2 - sin(a)*ly2) * scale + xverts.at(0); + double py2 = (sin(a)*lx2 + cos(a)*ly2) * scale + yverts.at(0); ADD_LINE(px1, py1, px2, py2); } } @@ -385,6 +385,9 @@ DxfData::DxfData(double fn, double fs, double fa, catch (boost::bad_lexical_cast &blc) { PRINTB("WARNING: Illegal value %s in '%s'", data % filename); } + catch (const std::out_of_range& oor) { + PRINTB("WARNING: not enough input values for %s in '%s'", data % filename); + } } BOOST_FOREACH(const EntityList::value_type &i, unsupported_entities_list) { diff --git a/testdata/dxf/nothing-decimal-comma-separated.dxf b/testdata/dxf/nothing-decimal-comma-separated.dxf new file mode 100644 index 00000000..d7ef27ea --- /dev/null +++ b/testdata/dxf/nothing-decimal-comma-separated.dxf @@ -0,0 +1,140 @@ +999 +This tests should not crash but produce no visible result, see former issue 593. +0 +SECTION +2 +HEADER +9 +$EXTMIN +10 +-6,63671875 +20 +-0,0244140625 +30 +0,5 +9 +$EXTMAX +10 +7,1357421875 +20 +0,921875 +30 +0,5 +0 +ENDSEC +0 +SECTION +2 +TABLES +0 +TABLE +2 +VPORT +0 +VPORT +2 +*ACTIVE +41 + 1.000000 +0 +ENDTAB +0 +TABLE +2 +LAYER +0 +LAYER +2 +0 +62 +0 +0 +ENDTAB +0 +ENDSEC +0 +SECTION +2 +BLOCKS +0 +ENDSEC +0 +SECTION +2 +ENTITIES +0 +LINE +8 +0 +62 +0 +10 +0,1 +20 +0,1 +30 +0 +11 +2,5 +21 +0 +31 +0 +0 +LINE +8 +0 +62 +0 +10 +2,5 +20 +0 +30 +0 +11 +2,5 +21 +2,5 +31 +0 +0 +LINE +8 +0 +62 +0 +10 +2,5 +20 +2,5 +30 +0 +11 +0 +21 +2,5 +31 +0 +0 +LINE +8 +0 +62 +0 +10 +0 +20 +2,5 +30 +0 +11 +0,1 +21 +0,1 +31 +0 +0 +ENDSEC +0 +EOF diff --git a/testdata/scad/dxf/nothing-decimal-comma-separated.scad b/testdata/scad/dxf/nothing-decimal-comma-separated.scad new file mode 100644 index 00000000..204ce08f --- /dev/null +++ b/testdata/scad/dxf/nothing-decimal-comma-separated.scad @@ -0,0 +1,2 @@ +// This tests should not crash but produce no visible result, see former issue 593. +import("../../nothing-decimal-comma-separated.dxf"); diff --git a/tests/regression/cgalpngtest/nothing-decimal-comma-separated-expected.png b/tests/regression/cgalpngtest/nothing-decimal-comma-separated-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..5c4279ed5a958baa6103e44d9f4497f657bb3f89 GIT binary patch literal 1947 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&t&wwUqN(1_t&dPZ!6K3dT2A4H*w82pn*T z`tK*mC@fWXVs2B;&vQ4q8|KwpF*HcBF$knGFa!=iDxYEcUMmS;cqAx1$=~~5WSt6= zf*a7MObi`D3=UHm7#6WG2&ghNXfQIka55-(4OyvLhUE2pEI^M+u>Fjl|A0lilc7Uk zSoshdJ^BqB!;b?!YQWR{XZO06zuYqz8lDf6NJL42S40ooSe*>a%Mxvl|6;EnddKR+ za3FZtC0wANUr8bRH2m;AkWY<=zfZ3pJ_qut@G$l1t<}tmzygWQ>EE@-H)=gu4p+rboFyt=akR{0Np-G6aWAK literal 0 HcmV?d00001 diff --git a/tests/regression/opencsgtest/nothing-decimal-comma-separated-expected.png b/tests/regression/opencsgtest/nothing-decimal-comma-separated-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..5c4279ed5a958baa6103e44d9f4497f657bb3f89 GIT binary patch literal 1947 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&t&wwUqN(1_t&dPZ!6K3dT2A4H*w82pn*T z`tK*mC@fWXVs2B;&vQ4q8|KwpF*HcBF$knGFa!=iDxYEcUMmS;cqAx1$=~~5WSt6= zf*a7MObi`D3=UHm7#6WG2&ghNXfQIka55-(4OyvLhUE2pEI^M+u>Fjl|A0lilc7Uk zSoshdJ^BqB!;b?!YQWR{XZO06zuYqz8lDf6NJL42S40ooSe*>a%Mxvl|6;EnddKR+ za3FZtC0wANUr8bRH2m;AkWY<=zfZ3pJ_qut@G$l1t<}tmzygWQ>EE@-H)=gu4p+rboFyt=akR{0Np-G6aWAK literal 0 HcmV?d00001 diff --git a/tests/regression/throwntogethertest/nothing-decimal-comma-separated-expected.png b/tests/regression/throwntogethertest/nothing-decimal-comma-separated-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..5c4279ed5a958baa6103e44d9f4497f657bb3f89 GIT binary patch literal 1947 zcmeAS@N?(olHy`uVBq!ia0y~yU;;9k7&t&wwUqN(1_t&dPZ!6K3dT2A4H*w82pn*T z`tK*mC@fWXVs2B;&vQ4q8|KwpF*HcBF$knGFa!=iDxYEcUMmS;cqAx1$=~~5WSt6= zf*a7MObi`D3=UHm7#6WG2&ghNXfQIka55-(4OyvLhUE2pEI^M+u>Fjl|A0lilc7Uk zSoshdJ^BqB!;b?!YQWR{XZO06zuYqz8lDf6NJL42S40ooSe*>a%Mxvl|6;EnddKR+ za3FZtC0wANUr8bRH2m;AkWY<=zfZ3pJ_qut@G$l1t<}tmzygWQ>EE@-H)=gu4p+rboFyt=akR{0Np-G6aWAK literal 0 HcmV?d00001