diff scripts/geometry/delaunayn.m @ 28027:2e6dc7e2b191

Use appropriate Qhull options as necessary to obtain triangulation (bug #50494). * __delaunayn__.cc (F__delaunayn__): Set default options for 2-D & 3-D input to "Qt Qbb Qc" (no "Qz"). * delaunay.m: Document that default options for 2-D,3-D input are "Qt Qbb Qc". * delaunayn.m: Document that default options for 2-D,3-D input are "Qt Qbb Qc". Document that if triangulation fails, "Qz" will be added for 2-D inputs and Qhull called a second time. Add try/catch block that calls internal function __delaunayn__ once with no options, and if an error results, calls with "Qt Qbb Qc Qz" for 2-D inputs. * griddata.m: Remove previous fix for bug #50494 which set Qhull options. * griddatan.m: Remove previous fix for bug #50494 which set Qhull options.
author Rik <rik@octave.org>
date Thu, 30 Jan 2020 17:43:56 -0800
parents bd51beb6205e
children d8dcb36bb904
line wrap: on
line diff
--- a/scripts/geometry/delaunayn.m	Thu Jan 30 15:12:52 2020 -0500
+++ b/scripts/geometry/delaunayn.m	Thu Jan 30 17:43:56 2020 -0800
@@ -45,11 +45,15 @@
 ## The default options depend on the dimension of the input:
 ##
 ## @itemize
-## @item 2-D and 3-D: @var{options} = @code{@{"Qt", "Qbb", "Qc", "Qz"@}}
+## @item 2-D and 3-D: @var{options} = @code{@{"Qt", "Qbb", "Qc"@}}
 ##
 ## @item 4-D and higher: @var{options} = @code{@{"Qt", "Qbb", "Qc", "Qx"@}}
 ## @end itemize
 ##
+## If QHull fails for 2-D input the triangulation is attempted again with
+## the options @code{@{"Qt", "Qbb", "Qc", "Qz"@}} which may result in
+## reduced accuracy.
+##
 ## If @var{options} is not present or @code{[]} then the default arguments are
 ## used.  Otherwise, @var{options} replaces the default argument list.
 ## To append user options to the defaults it is necessary to repeat the
@@ -64,7 +68,17 @@
     print_usage ();
   endif
 
-  T = __delaunayn__ (pts, varargin{:});
+  if (isempty (varargin) || isempty (varargin{1}))
+    try
+      T = __delaunayn__ (pts);
+    catch
+      if (columns (pts) <= 2)
+        T = __delaunayn__ (pts, "Qt Qbb Qc Qz");
+      endif
+    end_try_catch
+  else
+    T = __delaunayn__ (pts, varargin{:});
+  endif
 
   if (isa (pts, "single"))
     tol = 1e3 * eps ("single");