Code

fix bbox calculation for groups that contain groups with nothing in them (zero bbox...
[inkscape.git] / src / display / bezier-utils.cpp
index 8316c86cc213d64d6db99b7df7cc97abd8baf57a..434e7169e8df1a2e1fb579eb5070eb9fee909bb5 100644 (file)
 #endif
 
 #ifdef HAVE_IEEEFP_H
-# include <ieefp.h>
+# include <ieeefp.h>
 #endif
 
+#include <glib.h> // g_assert()
 #include <glib/gmessages.h>
 #include <glib/gmem.h>
 #include "bezier-utils.h"
 #include <libnr/nr-point-fns.h>
 
-#include "isnan.h"
+#include "2geom/isnan.h"
 
 
 typedef NR::Point BezierCurve[];
@@ -53,7 +54,6 @@ static void estimate_bi(NR::Point b[4], unsigned ei,
                         NR::Point const data[], double const u[], unsigned len);
 static void reparameterize(NR::Point const d[], unsigned len, double u[], BezierCurve const bezCurve);
 static gdouble NewtonRaphsonRootFind(BezierCurve const Q, NR::Point const &P, gdouble u);
-static NR::Point bezier_pt(unsigned degree, NR::Point const V[], gdouble t);
 static NR::Point sp_darray_center_tangent(NR::Point const d[], unsigned center, unsigned length);
 static NR::Point sp_darray_right_tangent(NR::Point const d[], unsigned const len);
 static unsigned copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len, NR::Point dest[]);
@@ -148,19 +148,20 @@ copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len
         if ( si == src_len ) {
             return 0;
         }
-        if (!isNaN(src[si][NR::X]) &&
-            !isNaN(src[si][NR::Y])) {
+        if (!IS_NAN(src[si][NR::X]) &&
+            !IS_NAN(src[si][NR::Y])) {
             dest[0] = NR::Point(src[si]);
             ++si;
             break;
         }
+        si ++;
     }
     unsigned di = 0;
     for (; si < src_len; ++si) {
         NR::Point const src_pt = NR::Point(src[si]);
         if ( src_pt != dest[di]
-             && !isNaN(src_pt[NR::X])
-             && !isNaN(src_pt[NR::Y])) {
+             && !IS_NAN(src_pt[NR::X])
+             && !IS_NAN(src_pt[NR::Y])) {
             dest[++di] = src_pt;
         }
     }
@@ -200,7 +201,7 @@ sp_bezier_fit_cubic_full(NR::Point bezier[], int split_points[],
         double const dist = ( L2( data[len - 1]
                                   - data[0] )
                               / 3.0 );
-        if (isNaN(dist)) {
+        if (IS_NAN(dist)) {
             /* Numerical problem, fall back to straight line segment. */
             bezier[1] = bezier[0];
             bezier[2] = bezier[3];
@@ -603,7 +604,7 @@ NewtonRaphsonRootFind(BezierCurve const Q, NR::Point const &P, gdouble const u)
         }
     }
 
-    if (!isFinite(improved_u)) {
+    if (!IS_FINITE(improved_u)) {
         improved_u = u;
     } else if ( improved_u < 0.0 ) {
         improved_u = 0.0;
@@ -652,7 +653,7 @@ NewtonRaphsonRootFind(BezierCurve const Q, NR::Point const &P, gdouble const u)
  * is i * BezierII(i-1, V'), where for all j, V'[j] =
  * V[j + 1] - V[j].
  */
-static NR::Point
+NR::Point
 bezier_pt(unsigned const degree, NR::Point const V[], gdouble const t)
 {
     /** Pascal's triangle. */
@@ -834,7 +835,7 @@ chord_length_parameterize(NR::Point const d[], gdouble u[], unsigned const len)
     /* Then scale to [0.0 .. 1.0]. */
     gdouble tot_len = u[len - 1];
     g_return_if_fail( tot_len != 0 );
-    if (isFinite(tot_len)) {
+    if (IS_FINITE(tot_len)) {
         for (unsigned i = 1; i < len; ++i) {
             u[i] /= tot_len;
         }
@@ -848,7 +849,7 @@ chord_length_parameterize(NR::Point const d[], gdouble u[], unsigned const len)
     /** \todo
      * It's been reported that u[len - 1] can differ from 1.0 on some 
      * systems (amd64), despite it having been calculated as x / x where x 
-     * is isFinite and non-zero.
+     * is IS_FINITE and non-zero.
      */
     if (u[len - 1] != 1) {
         double const diff = u[len - 1] - 1;