[Libreoffice-commits] libvisio.git: 3 commits - src/lib

David Tardon dtardon at redhat.com
Sun Apr 30 14:08:58 UTC 2017


 src/lib/VSDContentCollector.cpp |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit c420a080601063b2ad1b5473b4912fd0ad2b99d3
Author: David Tardon <dtardon at redhat.com>
Date:   Sun Apr 30 15:26:58 2017 +0200

    add additional sanity check
    
    Change-Id: I49a521d994b21e6eb35ac111eeb8f7d7b282d8df

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index f49001d..516ff3f 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1959,16 +1959,19 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
 
   unsigned a = degree;
   unsigned b = degree + 1;
+  unsigned m = (controlPoints.size() - 1) + degree + 1;
+  if (m > knotVector.size() - 1)
+    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++)
     points[i] = controlPoints[i];
   if (degree >= controlPoints.size())
     fill(points.begin() + controlPoints.size(), points.end(), controlPoints.back());
-  while (b < knotVector.size() - 1)
+  while (b < m)
   {
     i = b;
-    while (b < knotVector.size() - 1 && knotVector[b+1] == knotVector[b])
+    while (b < m && knotVector[b+1] == knotVector[b])
       b++;
     unsigned mult = b - i + 1;
     if (mult > degree) // it doesn't make sense to have knot multiplicity greater than the curve degree
@@ -2015,7 +2018,7 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
 
     std::swap(points, nextPoints);
 
-    if (b < knotVector.size() - 1)
+    if (b < m)
     {
       for (i=degree-mult; i <= degree; i++)
       {
commit ee0b00cf94fe9bd3c05d63f6ec91a692c5fee7b3
Author: David Tardon <dtardon at redhat.com>
Date:   Sun Apr 30 15:28:39 2017 +0200

    add additional sanity check
    
    Change-Id: I35caa3cd2a5a0434095258a5fcb967d025123cf7

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 922b9de..f49001d 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1949,7 +1949,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)
+  if (controlPoints.empty() || knotVector.empty() || degree == 0 || degree > 3)
     return;
 
   /* Decomposition of a uniform spline of a given degree into Bezier segments
@@ -2011,8 +2011,6 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
     case 3:
       _outputCubicBezierSegment(points);
       break;
-    default:
-      break;
     }
 
     std::swap(points, nextPoints);
commit 6d7de66c8c48d56e0c4c9a84e6c1c2860b8b8508
Author: David Tardon <dtardon at redhat.com>
Date:   Fri Apr 28 15:42:08 2017 +0200

    add additional sanity check
    
    Change-Id: I3be2260c01e07a5c0e6337f6f9b1866990ac35df

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 2e5cc4a..922b9de 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -1971,6 +1971,8 @@ void libvisio::VSDContentCollector::_generateBezierSegmentsFromNURBS(unsigned de
     while (b < knotVector.size() - 1 && knotVector[b+1] == knotVector[b])
       b++;
     unsigned mult = b - i + 1;
+    if (mult > degree) // it doesn't make sense to have knot multiplicity greater than the curve degree
+      mult = degree;
     if (mult < degree)
     {
       double numer = (double)(knotVector[b] - knotVector[a]);


More information about the Libreoffice-commits mailing list