50 #if defined (HAVE_QHULL)
52 # if defined (NEED_QHULL_VERSION)
53 char qh_version[] =
"__voronoi__.oct 2007-07-24";
70 if (dim > maxval || n > maxval)
72 error (
"%s: dimension too large for Qhull", who);
82 @deftypefn {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts})\n\
83 @deftypefnx {Loadable Function} {@var{C}, @var{F} =} __voronoi__ (@var{caller}, @var{pts}, @var{options})\n\
84 @deftypefnx {Loadable Function} {@var{C}, @var{F}, @var{Inf_Pts} =} __voronoi__ (@dots{})\n\
85 Undocumented internal function.\n\
90 std::string caller = args(0).string_value ();
92 #if defined (HAVE_QHULL)
96 int nargin = args.
length ();
97 if (nargin < 2 || nargin > 3)
103 Matrix points = args(1).matrix_value ();
134 options +=
" " + tmp(i);
138 error (
"%s: OPTIONS must be a string, cell array of strings, or empty",
144 boolT ismalloc =
false;
149 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
150 FILE *outfile = gnulib::fopen (
"NUL",
"w");
152 FILE *outfile = gnulib::fopen (
"/dev/null",
"w");
154 FILE *errfile = stderr;
160 error (
"__voronoi__: unable to create temporary file for output");
166 std::string cmd =
"qhull v" + options;
170 strcpy (cmd_str, cmd.c_str ());
172 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
173 ismalloc, cmd_str, outfile, errfile);
179 qh_findgood_all (qh facet_list);
182 = qh num_vertices - qh_setsize (qh del_vertices);
188 qh_setvoronoi_all ();
211 if (qh hull_dim == 3)
212 qh_order_vertexneighbors (vertex);
214 bool infinity_seen =
false;
216 facetT *neighbor, **neighborp;
218 FOREACHneighbor_ (vertex)
220 if (neighbor->upperdelaunay)
224 infinity_seen =
true;
230 neighbor->seen =
true;
246 ? num_points : num_voronoi_regions);
252 Matrix F (num_voronoi_vertices+1, dim);
276 if (qh hull_dim == 3)
277 qh_order_vertexneighbors (vertex);
279 bool infinity_seen =
false;
289 if (num_vertices == 1)
296 facetT *neighbor, **neighborp;
298 FOREACHneighbor_(vertex)
300 if (neighbor->upperdelaunay)
304 infinity_seen =
true;
311 if (! neighbor->seen)
315 F(i,
d) = neighbor->center[
d];
317 neighbor->seen =
true;
318 neighbor->visitid = i;
321 facet_list(m++) = neighbor->visitid + 1;
333 error (
"%s: qhull failed", caller.c_str ());
336 qh_freeqhull (! qh_ALL);
338 int curlong, totlong;
339 qh_memfreeshort (&curlong, &totlong);
341 if (curlong || totlong)
342 warning (
"%s: qhull did not free %d bytes of long memory (%d pieces)",
343 caller.c_str (), totlong, curlong);
346 error (
"%s: not available in this version of Octave", caller.c_str ());
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type length(void) const
static bool octave_qhull_dims_ok(octave_idx_type dim, octave_idx_type n, const char *who)
void error(const char *fmt,...)
octave_idx_type rows(void) const
F77_RET_T const double const double double * d
Array< std::string > cellstr_value(void) const
F77_RET_T const double const double * f
void add_fcn(void(*fcn)(void))
std::string string_value(bool force=false) const
bool is_string(void) const
bool is_cellstr(void) const
Matrix transpose(void) const
void warning(const char *fmt,...)
charNDArray max(char d, const charNDArray &m)
bool is_empty(void) const
static void close_fcn(FILE *f)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFUN_DLD(name, args_name, nargout_name, doc)
const T * fortran_vec(void) const
octave_idx_type columns(void) const
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)