44 #if defined (HAVE_CONFIG_H)
64 #if defined (HAVE_QHULL)
68 # if defined (NEED_QHULL_VERSION)
69 char qh_version[] =
"__delaunayn__.oct 2007-08-21";
81 qh_freeqhull (! qh_ALL);
84 qh_memfreeshort (&curlong, &totlong);
86 if (curlong || totlong)
87 warning (
"__delaunayn__: did not free %d bytes of long memory (%d pieces)",
98 if (dim > maxval ||
n > maxval)
99 error (
"%s: dimension too large for Qhull", who);
115 #if defined (HAVE_QHULL)
117 int nargin = args.length ();
119 if (nargin < 1 || nargin > 2)
126 Matrix p (args(0).matrix_value ());
136 options =
"Qt Qbb Qc";
138 options =
"Qt Qbb Qc Qx";
142 if (args(1).is_string ())
143 options = args(1).string_value ();
144 else if (args(1).isempty ())
146 else if (args(1).iscellstr ())
152 options += tmp(i) +
' ';
155 error (
"__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty");
162 boolT ismalloc =
false;
167 sprintf (flags,
"qhull d %s", options.c_str ());
172 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
175 FILE *outfile =
std::fopen (
"/dev/null",
"w");
177 FILE *errfile = stderr;
180 error (
"__delaunayn__: unable to create temporary file for output");
184 int exitcode = qh_new_qhull (dim,
n, pt_array,
185 ismalloc, flags, outfile, errfile);
190 error (
"__delaunayn__: qhull failed");
196 vertexT *vertex, **vertexp;
202 if (! facet->upperdelaunay)
206 if (! facet->simplicial)
207 error (
"__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options");
214 if (! facet->upperdelaunay)
218 FOREACHvertex_ (facet->vertices)
220 simpl(i, j++) = 1 + qh_pointid(vertex->point);
228 else if (
n == dim + 1)
243 octave_unused_parameter (args);
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)
#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 * 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