33 #if defined (HAVE_CONFIG_H)
51 #if defined (HAVE_QHULL)
55 # if defined (NEED_QHULL_VERSION)
56 char qh_version[] =
"__voronoi__.oct 2007-07-24";
72 if (dim > maxval || n > maxval)
73 error (
"%s: dimension too large for Qhull", who);
89 #if defined (HAVE_QHULL)
93 if (nargin < 2 || nargin > 3)
96 std::string caller =
args(0).xstring_value (
"__voronoi__: CALLER must be a string");
131 options +=
" " +
tmp(
i);
134 error (
"%s: OPTIONS must be a string, cell array of strings, or empty",
138 boolT ismalloc =
false;
143 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
144 FILE *outfile = std::fopen (
"NUL",
"w");
146 FILE *outfile = std::fopen (
"/dev/null",
"w");
148 FILE *errfile = stderr;
151 error (
"__voronoi__: unable to create temporary file for output");
161 strcpy (cmd_str, cmd.c_str ());
163 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
164 ismalloc, cmd_str, outfile, errfile);
166 error (
"%s: qhull failed", caller.c_str ());
171 qh_findgood_all (qh facet_list);
174 = qh num_vertices - qh_setsize (qh del_vertices);
180 qh_setvoronoi_all ();
203 if (qh hull_dim == 3)
204 qh_order_vertexneighbors (vertex);
206 bool infinity_seen =
false;
208 facetT *neighbor, **neighborp;
210 FOREACHneighbor_ (vertex)
212 if (neighbor->upperdelaunay)
216 infinity_seen =
true;
222 neighbor->seen =
true;
238 ? num_points : num_voronoi_regions);
244 Matrix F (num_voronoi_vertices+1, dim);
268 if (qh hull_dim == 3)
269 qh_order_vertexneighbors (vertex);
271 bool infinity_seen =
false;
281 if (num_vertices == 1)
288 facetT *neighbor, **neighborp;
290 FOREACHneighbor_(vertex)
292 if (neighbor->upperdelaunay)
296 infinity_seen =
true;
303 if (! neighbor->seen)
307 F(i,
d) = neighbor->center[
d];
309 neighbor->seen =
true;
310 neighbor->visitid =
i;
313 facet_list(m++) = neighbor->visitid + 1;
320 retval =
ovl (F, C, at_inf);
323 qh_freeqhull (! qh_ALL);
325 int curlong, totlong;
326 qh_memfreeshort (&curlong, &totlong);
328 if (curlong || totlong)
329 warning (
"%s: qhull did not free %d bytes of long memory (%d pieces)",
330 caller.c_str (), totlong, curlong);
336 octave_unused_parameter (
args);
339 = (
args.length () > 0
340 ?
args(0).xstring_value (
"__voronoi__: CALLER must be a string")
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
Array< std::string > cellstr_value(void) const
void add_fcn(void(*fcn)(void))
std::string string_value(bool force=false) const
nd deftypefn *octave_map m
bool is_string(void) const
bool is_cellstr(void) const
Matrix transpose(void) const
void warning(const char *fmt,...)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
bool is_empty(void) const
=val(i)}if ode{val(i)}occurs in table i
static void close_fcn(FILE *f)
OCTAVE_EXPORT octave_value_list only variables visible in the local scope are displayed The following are valid options
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFUN_DLD(name, args_name, nargout_name, doc)
const T * fortran_vec(void) const
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
octave_idx_type columns(void) const
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)