33 #if defined (HAVE_CONFIG_H) 56 #if defined (HAVE_QHULL) 60 # if defined (NEED_QHULL_VERSION) 61 char qh_version[] =
"__voronoi__.oct 2007-07-24";
73 qh_freeqhull (! qh_ALL);
76 qh_memfreeshort (&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 ();
114 std::string caller = args(0).xstring_value (
"__voronoi__: CALLER must be a string");
118 Matrix points = args(1).matrix_value ();
152 error (
"%s: OPTIONS must be a string, cell array of strings, or empty",
156 boolT ismalloc =
false;
161 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) 162 FILE *outfile = std::fopen (
"NUL",
"w");
164 FILE *outfile = std::fopen (
"/dev/null",
"w");
166 FILE *errfile = stderr;
169 error (
"__voronoi__: unable to create temporary file for output");
179 strcpy (cmd_str, cmd.c_str ());
181 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
182 ismalloc, cmd_str, outfile, errfile);
187 error (
"%s: qhull failed", caller.c_str ());
192 qh_findgood_all (qh facet_list);
195 = qh num_vertices - qh_setsize (qh del_vertices);
201 qh_setvoronoi_all ();
224 if (qh hull_dim == 3)
225 qh_order_vertexneighbors (vertex);
227 bool infinity_seen =
false;
229 facetT *neighbor, **neighborp;
231 FOREACHneighbor_ (vertex)
233 if (neighbor->upperdelaunay)
237 infinity_seen =
true;
243 neighbor->seen =
true;
259 ? num_points : num_voronoi_regions);
265 Matrix F (num_voronoi_vertices+1, dim);
289 if (qh hull_dim == 3)
290 qh_order_vertexneighbors (vertex);
292 bool infinity_seen =
false;
302 if (num_vertices == 1)
309 facetT *neighbor, **neighborp;
311 FOREACHneighbor_(vertex)
313 if (neighbor->upperdelaunay)
317 infinity_seen =
true;
324 if (! neighbor->seen)
328 F(
i,
d) = neighbor->center[
d];
330 neighbor->seen =
true;
331 neighbor->visitid =
i;
334 facet_list(m++) = neighbor->visitid + 1;
347 octave_unused_parameter (args);
350 = (args.length () > 0
351 ? args(0).xstring_value (
"__voronoi__: CALLER must be a string")
octave_idx_type rows(void) const
std::string string_value(bool force=false) const
OCTINTERP_API void print_usage(void)
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 const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &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)
const T * fortran_vec(void) const
void add_fcn(void(*fcn)(void))
void error(const char *fmt,...)
octave_idx_type columns(void) const
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 const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
bool iscellstr(void) const
Matrix transpose(void) const
OCTAVE_EXPORT octave_value_list or both For fclose
void warning(const char *fmt,...)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
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
static void free_qhull_memory()
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool is_string(void) const
#define DEFUN_DLD(name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin function.
Array< std::string > cellstr_value(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
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)