# HG changeset patch # User cdf # Date 1429088060 0 # Node ID 4b8c66b9876fd3b871a1e6cc66e04e310610e735 # Parent 1bdb7ad5015b4fff8e7760efe996af66dffe585c display error message and return -1 if point is outside knot span in findspan diff -r 1bdb7ad5015b -r 4b8c66b9876f extra/nurbs/src/low_level_functions.cc --- a/extra/nurbs/src/low_level_functions.cc Wed Apr 15 08:53:35 2015 +0000 +++ b/extra/nurbs/src/low_level_functions.cc Wed Apr 15 08:54:20 2015 +0000 @@ -21,7 +21,8 @@ #include "low_level_functions.h" #include -octave_idx_type findspan(int n, int p, double u, const RowVector& U) +octave_idx_type +findspan (int n, int p, double u, const RowVector& U) // Find the knot span of the parametric point u. // @@ -70,12 +71,17 @@ { // FIXME : this implementation has linear, rather than log complexity int ret = 0; - while ((ret++ < n) && (U(ret) <= u)) { - }; + + if (u > U.xelem (U.numel () - 1) || u < U.xelem (0)) + error ("Value %g is outside the knot span", u); + else + while ((ret++ < n) && (U(ret) <= u)) { }; + return (ret-1); } -void basisfun(int i, double u, int p, const RowVector& U, RowVector& N) +void +basisfun (int i, double u, int p, const RowVector& U, RowVector& N) // Basis Function. //