Update on issue 1422 fix - fixing an array index out of bounds issue; do no use control points for first and last point as splines may not be designed to terminate at those.

This commit is contained in:
Matthias Koefferlein 2023-07-22 18:14:14 +02:00
parent 35e42a8117
commit 99df15a5ff
2 changed files with 18 additions and 6 deletions

View File

@ -817,12 +817,12 @@ static db::DPoint
b_spline_point (double x, const std::vector<std::pair<db::DPoint, double> > &control_points, int p, const std::vector<double> &t, int &k)
{
k = (int) (std::lower_bound (t.begin (), t.end (), x - 1e-6) - t.begin ());
if (k < p) {
return control_points.front ().first;
} else if (k > (int) control_points.size ()) {
return control_points.back ().first;
}
--k;
if (k < p) {
k = p;
} else if (k >= (int) control_points.size ()) {
k = (int) control_points.size () - 1;
}
std::vector<db::DPoint> d;
std::vector<double> dw;

View File

@ -517,10 +517,22 @@ TEST(34)
}
// issue #1422
TEST(35)
TEST(35a)
{
db::DXFReaderOptions opt;
run_test_public (_this, "issue_1422a.dxf", "issue_1422a_au.gds.gz", opt);
}
// issue #1422
TEST(35b)
{
db::DXFReaderOptions opt;
run_test_public (_this, "issue_1422b.dxf", "issue_1422b_au.gds.gz", opt);
}
// issue #1422
TEST(35c)
{
db::DXFReaderOptions opt;
run_test_public (_this, "issue_1422c.dxf", "issue_1422c_au.gds.gz", opt);
}