Mercurial > octave
changeset 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 | 262cdfc6faf9 |
children | 79b583e31590 |
files | libinterp/dldfcn/__delaunayn__.cc scripts/geometry/delaunay.m scripts/geometry/delaunayn.m scripts/geometry/griddata.m scripts/geometry/griddatan.m |
diffstat | 5 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/dldfcn/__delaunayn__.cc Thu Jan 30 15:12:52 2020 -0500 +++ b/libinterp/dldfcn/__delaunayn__.cc Thu Jan 30 17:43:56 2020 -0800 @@ -133,7 +133,7 @@ // Default options std::string options; if (dim <= 3) - options = "Qt Qbb Qc Qz"; + options = "Qt Qbb Qc"; else options = "Qt Qbb Qc Qx";
--- a/scripts/geometry/delaunay.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/delaunay.m Thu Jan 30 17:43:56 2020 -0800 @@ -55,7 +55,10 @@ ## contains options passed to the underlying qhull command. ## See the documentation for the Qhull library for details ## @url{http://www.qhull.org/html/qh-quick.htm#options}. -## The default options are @code{@{"Qt", "Qbb", "Qc", "Qz"@}}. +## The default options are @code{@{"Qt", "Qbb", "Qc"@}}. +## 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.
--- 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");
--- a/scripts/geometry/griddata.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/griddata.m Thu Jan 30 17:43:56 2020 -0800 @@ -86,8 +86,7 @@ z = z(:); ## Triangulate data. - ## Bug #50494 (loss of precision unless non-default Qhull options used) - tri = delaunay (x, y, {"Qt", "Qbb", "Qc"}); + tri = delaunay (x, y); zi = NaN (size (xi)); if (strcmp (method, "cubic"))
--- a/scripts/geometry/griddatan.m Thu Jan 30 15:12:52 2020 -0500 +++ b/scripts/geometry/griddatan.m Thu Jan 30 17:43:56 2020 -0800 @@ -60,11 +60,6 @@ error ("griddatan: dimensional mismatch"); endif - ## Bug #50494 (loss of precision unless non-default Qhull options used) - if (isempty (varargin) && n <= 3) - varargin{1} = {"Qt", "Qbb", "Qc"}; - endif - ## triangulate data tri = delaunayn (x, varargin{:});