36 #if defined (HAVE_CONFIG_H)
59 #if defined (HAVE_QHULL)
61 # if defined (NEED_QHULL_R_VERSION)
62 char qh_version[] =
"__voronoi__.oct 2007-07-24";
68 #if defined (HAVE_QHULL)
73 qh_freeqhull (qh, ! qh_ALL);
76 qh_memfreeshort (qh, &curlong, &totlong);
78 if (curlong || totlong)
79 warning (
"__voronoi__: did not free %d bytes of long memory (%d pieces)",
90 if (dim > maxval ||
n > maxval)
91 error (
"%s: dimension too large for Qhull", who);
107 #if defined (HAVE_QHULL)
109 int nargin = args.length ();
111 if (nargin < 2 || nargin > 3)
114 std::string caller = args(0).xstring_value (
"__voronoi__: CALLER must be a string");
118 Matrix points = args(1).matrix_value ();
149 options +=
' ' + tmp(i);
152 error (
"%s: OPTIONS must be a string, cell array of strings, or empty",
156 boolT ismalloc =
false;
159 FILE *outfile =
nullptr;
160 FILE *errfile = stderr;
165 std::string cmd =
"qhull v" + options;
167 int exitcode = qh_new_qhull (qh, dim, num_points, points.
fortran_vec (),
168 ismalloc, &cmd[0], outfile, errfile);
173 error (
"%s: qhull failed", caller.c_str ());
178 qh_findgood_all (qh, qh->facet_list);
181 = qh->num_vertices - qh_setsize (qh, qh->del_vertices);
187 qh_setvoronoi_all (qh);
210 if (qh->hull_dim == 3)
211 qh_order_vertexneighbors (qh, vertex);
213 bool infinity_seen =
false;
215 facetT *neighbor, * *neighborp;
217 FOREACHneighbor_ (vertex)
219 if (neighbor->upperdelaunay)
223 infinity_seen =
true;
229 neighbor->seen =
true;
245 ? num_points : num_voronoi_regions);
251 Matrix F (num_voronoi_vertices+1, dim);
275 if (qh->hull_dim == 3)
276 qh_order_vertexneighbors (qh, vertex);
278 bool infinity_seen =
false;
288 if (num_vertices == 1)
295 facetT *neighbor, * *neighborp;
297 FOREACHneighbor_(vertex)
299 if (neighbor->upperdelaunay)
303 infinity_seen =
true;
310 if (! neighbor->seen)
314 F(i,
d) = neighbor->center[
d];
316 neighbor->seen =
true;
317 neighbor->visitid = i;
320 facet_list(
m++) = neighbor->visitid + 1;
327 retval =
ovl (F,
C, at_inf);
333 octave_unused_parameter (args);
336 = (args.length () > 0
337 ? args(0).xstring_value (
"__voronoi__: CALLER must be a string")
static bool octave_qhull_dims_ok(octave_idx_type dim, octave_idx_type n, const char *who)
static void free_qhull_memory(qhT *qh)
charNDArray max(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Matrix transpose(void) const
bool iscellstr(void) const
bool is_string(void) const
std::string string_value(bool force=false) const
Array< std::string > cellstr_value(void) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN_DLD(name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin function.
OCTINTERP_API void print_usage(void)
void warning(const char *fmt,...)
void error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.