summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-10 10:43:03 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-07-10 10:43:14 +0200
commit5a38774b5f9bfc2d58e8a7a06effb0bbe7d0debd (patch)
tree87bfda5eabc0d7ec8ed63bd564271eb30e094311
parente7974026dd728d2882962de803c0cfbc29057283 (diff)
Try not to go out of bonds
-rw-r--r--src/lib/VSDContentCollector.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 5057370..09fc553 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1392,24 +1392,23 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
* The NURBS Book, 2nd Edition, 1997
*/
- unsigned m = controlPoints.size() + degree + 1;
unsigned a = degree;
unsigned b = degree + 1;
std::vector< std::pair<double, double> > points(degree + 1), nextPoints(degree + 1);
unsigned i = 0;
for (; i <= degree; i++)
points[i] = controlPoints[i];
- while (b < m)
+ while (b < knotVector.size() - 1)
{
i = b;
- while (b < m && knotVector[b+1] == knotVector[b])
+ while (b < knotVector.size() - 1 && knotVector[b+1] == knotVector[b])
b++;
unsigned mult = b - i + 1;
if (mult < degree)
{
double numer = (double)(knotVector[b] - knotVector[a]);
unsigned j = degree;
- std::map<unsigned, double> alphas;
+ std::vector<double> alphas(degree - 1, 0.0);
for (; j >mult; j--)
alphas[j-mult-1] = numer/double(knotVector[a+j]-knotVector[a]);
unsigned r = degree - mult;
@@ -1423,7 +1422,7 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
points[k].first = alpha*points[k].first + (1.0-alpha)*points[k-1].first;
points[k].second = alpha*points[k].second + (1.0-alpha)*points[k-1].second;
}
- if (b < m)
+ if (b < knotVector.size() - 1)
{
nextPoints[save].first = points[degree].first;
nextPoints[save].second = points[degree].second;
@@ -1449,7 +1448,7 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
std::swap(points, nextPoints);
- if (b < m)
+ if (b < knotVector.size() - 1)
{
for (i=degree-mult; i <= degree; i++)
{