diff options
author | David Tardon <dtardon@redhat.com> | 2017-07-04 10:29:31 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2017-07-04 10:36:22 +0200 |
commit | 4207a1089a13726cbcf1b6e74d80f146544b7b8c (patch) | |
tree | 4a3cd6f7fd7a53191184c46fbea99d998e8efd7a | |
parent | 246155061002dc7e373f9cad435ff4382f4ff000 (diff) |
ofz#1431 reject NURBS that do not have enough control points
Change-Id: I1ea6345ecb5b3f4f2d0979149dad103829c81bfa
-rw-r--r-- | src/lib/VSDContentCollector.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp index f43ac24..08e88e1 100644 --- a/src/lib/VSDContentCollector.cpp +++ b/src/lib/VSDContentCollector.cpp @@ -1958,7 +1958,7 @@ void libvisio::VSDContentCollector::_outputLinearBezierSegment(const std::vector void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned degree, const std::vector<std::pair<double, double> > &controlPoints, const std::vector<double> &knotVector) { - if (controlPoints.empty() || knotVector.empty() || degree == 0 || degree > 3) + if (controlPoints.size() <= degree || knotVector.empty() || degree == 0 || degree > 3) return; /* Decomposition of a uniform spline of a given degree into Bezier segments @@ -1973,10 +1973,8 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de m = knotVector.size() - 1; std::vector< std::pair<double, double> > points(degree + 1), nextPoints(degree + 1); unsigned i = 0; - for (; i <= degree && i < controlPoints.size(); i++) + for (; i <= degree; i++) points[i] = controlPoints[i]; - if (degree >= controlPoints.size()) - fill(points.begin() + controlPoints.size(), points.end(), controlPoints.back()); while (b < m) { i = b; @@ -2031,18 +2029,6 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de { for (i=degree-mult; i <= degree; i++) { - // TODO: this seems to be an inherent problem... Possibly our - // impl. doesn't match the algorithm's prerequisities correctly? - // Def. of NURBS curve is (using symbolic from The NURBS Book): - // # of control points... n+1 - // # of knots... m+1 - // degree... p - // relation between these values... m == n + p + 1 - // The max. possible value of b-degree+i is (m-1)-p+p == m-1 == n+p. - // But n+p >= n+1, which means that there would be at least one - // access past the controlPoints array... - if (b-degree+i >= controlPoints.size()) - break; points[i].first = controlPoints[b-degree+i].first; points[i].second = controlPoints[b-degree+i].second; } |