44 #if defined (HAVE_CONFIG_H)
64 #if defined (HAVE_QHULL)
66 # if defined (NEED_QHULL_R_VERSION)
67 char qh_version[] =
"__delaunayn__.oct 2007-08-21";
73 #if defined (HAVE_QHULL)
78 qh_freeqhull (qh, ! qh_ALL);
81 qh_memfreeshort (qh, &curlong, &totlong);
83 if (curlong || totlong)
84 warning (
"__delaunayn__: did not free %d bytes of long memory (%d pieces)",
95 if (dim > maxval ||
n > maxval)
96 error (
"%s: dimension too large for Qhull", who);
112 #if defined (HAVE_QHULL)
114 int nargin = args.length ();
116 if (nargin < 1 || nargin > 2)
123 Matrix p (args(0).matrix_value ());
133 options =
"Qt Qbb Qc";
135 options =
"Qt Qbb Qc Qx";
139 if (args(1).is_string ())
140 options = args(1).string_value ();
141 else if (args(1).isempty ())
143 else if (args(1).iscellstr ())
149 options += tmp(i) +
' ';
152 error (
"__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty");
159 boolT ismalloc =
false;
161 std::string cmd =
"qhull d " + options;
164 FILE *outfile =
nullptr;
168 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
171 FILE *errfile =
std::fopen (
"/dev/null",
"w");
175 error (
"__delaunayn__: unable to redirect Qhull errors to /dev/null");
177 unwind_action close_errfile ([=] () { std::fclose (errfile); });
182 int exitcode = qh_new_qhull (qh, dim,
n, pt_array, ismalloc, &cmd[0],
188 error (
"__delaunayn__: qhull failed");
194 vertexT *vertex, **vertexp;
200 if (! facet->upperdelaunay)
204 if (! facet->simplicial)
205 error (
"__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options");
212 if (! facet->upperdelaunay)
216 FOREACHvertex_ (facet->vertices)
218 simpl(i, j++) = 1 + qh_pointid(qh, vertex->point);
226 else if (
n == dim + 1)
241 octave_unused_parameter (args);
static bool octave_qhull_dims_ok(octave_idx_type dim, octave_idx_type n, const char *who)
static void free_qhull_memory(qhT *qh)
charNDArray max(char d, const charNDArray &m)
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Matrix transpose(void) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#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)
std::FILE * fopen(const std::string &filename, const std::string &mode)