54 #if defined (HAVE_QHULL)
56 # if defined (NEED_QHULL_VERSION)
57 char qh_version[] =
"__delaunayn__.oct 2007-08-21";
74 if (dim > maxval || n > maxval)
76 error (
"%s: dimension too large for Qhull", who);
86 @deftypefn {Loadable Function} {@var{T} =} __delaunayn__ (@var{pts})\n\
87 @deftypefnx {Loadable Function} {@var{T} =} __delaunayn__ (@var{pts}, @var{options})\n\
88 Undocumented internal function.\n\
94 #if defined (HAVE_QHULL)
98 int nargin = args.
length ();
99 if (nargin < 1 || nargin > 2)
105 Matrix p (args(0).matrix_value ());
115 options =
"Qt Qbb Qc Qz";
117 options =
"Qt Qbb Qc Qx";
121 if (args(1).is_string ())
122 options = args(1).string_value ();
123 else if (args(1).is_empty ())
125 else if (args(1).is_cellstr ())
131 options += tmp(i) +
" ";
135 error (
"__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty");
144 boolT ismalloc =
false;
149 sprintf (flags,
"qhull d %s", options.c_str ());
154 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
155 FILE *outfile = gnulib::fopen (
"NUL",
"w");
157 FILE *outfile = gnulib::fopen (
"/dev/null",
"w");
159 FILE *errfile = stderr;
165 error (
"__delaunayn__: unable to create temporary file for output");
169 int exitcode = qh_new_qhull (dim, n, pt_array,
170 ismalloc, flags, outfile, errfile);
177 vertexT *vertex, **vertexp;
182 if (! facet->upperdelaunay)
186 if (! facet->simplicial)
188 error (
"__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options");
200 if (! facet->upperdelaunay)
204 FOREACHvertex_ (facet->vertices)
206 simpl(i, j++) = 1 + qh_pointid(vertex->point);
216 error (
"__delaunayn__: qhull failed");
219 qh_freeqhull (! qh_ALL);
221 int curlong, totlong;
222 qh_memfreeshort (&curlong, &totlong);
224 if (curlong || totlong)
225 warning (
"__delaunay__: did not free %d bytes of long memory (%d pieces)",
228 else if (n == dim + 1)
240 error (
"__delaunayn__: not available in this version of Octave");