36 #if defined (HAVE_CONFIG_H)
59 #if defined (HAVE_QHULL)
63 # if defined (NEED_QHULL_VERSION)
64 char qh_version[] =
"__voronoi__.oct 2007-07-24";
76 qh_freeqhull (! qh_ALL);
79 qh_memfreeshort (&curlong, &totlong);
81 if (curlong || totlong)
82 warning (
"__voronoi__: did not free %d bytes of long memory (%d pieces)",
93 if (dim > maxval ||
n > maxval)
94 error (
"%s: dimension too large for Qhull", who);
110 #if defined (HAVE_QHULL)
112 int nargin = args.length ();
114 if (nargin < 2 || nargin > 3)
117 std::string caller = args(0).xstring_value (
"__voronoi__: CALLER must be a string");
121 Matrix points = args(1).matrix_value ();
152 options +=
' ' + tmp(i);
155 error (
"%s: OPTIONS must be a string, cell array of strings, or empty",
159 boolT ismalloc =
false;
164 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
167 FILE *outfile =
std::fopen (
"/dev/null",
"w");
169 FILE *errfile = stderr;
172 error (
"__voronoi__: unable to create temporary file for output");
178 std::string cmd =
"qhull v" + options;
182 strcpy (cmd_str, cmd.c_str ());
184 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
185 ismalloc, cmd_str, outfile, errfile);
190 error (
"%s: qhull failed", caller.c_str ());
195 qh_findgood_all (qh facet_list);
198 = qh num_vertices - qh_setsize (qh del_vertices);
204 qh_setvoronoi_all ();
227 if (qh hull_dim == 3)
228 qh_order_vertexneighbors (vertex);
230 bool infinity_seen =
false;
232 facetT *neighbor, **neighborp;
234 FOREACHneighbor_ (vertex)
236 if (neighbor->upperdelaunay)
240 infinity_seen =
true;
246 neighbor->seen =
true;
262 ? num_points : num_voronoi_regions);
268 Matrix F (num_voronoi_vertices+1, dim);
292 if (qh hull_dim == 3)
293 qh_order_vertexneighbors (vertex);
295 bool infinity_seen =
false;
305 if (num_vertices == 1)
312 facetT *neighbor, **neighborp;
314 FOREACHneighbor_(vertex)
316 if (neighbor->upperdelaunay)
320 infinity_seen =
true;
327 if (! neighbor->seen)
331 F(i,
d) = neighbor->center[
d];
333 neighbor->seen =
true;
334 neighbor->visitid = i;
337 facet_list(
m++) = neighbor->visitid + 1;
350 octave_unused_parameter (args);
353 = (args.length () > 0
354 ? args(0).xstring_value (
"__voronoi__: CALLER must be a string")
static void close_fcn(FILE *f)
static bool octave_qhull_dims_ok(octave_idx_type dim, octave_idx_type n, const char *who)
static void free_qhull_memory()
charNDArray max(char d, const charNDArray &m)
octave_idx_type columns(void) const
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type rows(void) const
const T * fortran_vec(void) const
Size of the specified dimension.
Matrix transpose(void) const
void add_fcn(void(*fcn)(Params...), Args &&... args)
bool iscellstr(void) const
bool is_string(void) const
std::string string_value(bool force=false) const
Array< std::string > cellstr_value(void) const
#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
F77_RET_T const F77_DBLE const F77_DBLE * f
std::FILE * fopen(const std::string &filename, const std::string &mode)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.