32 #if defined (HAVE_CONFIG_H)
46 #if defined (HAVE_QHULL)
50 # if defined (NEED_QHULL_VERSION)
51 char qh_version[] =
"convhulln.oct 2007-07-24";
67 if (dim > maxval || n > maxval)
68 error (
"%s: dimension too large for Qhull", who);
111 #if defined (HAVE_QHULL)
115 if (nargin < 1 || nargin > 2)
138 if (
args(1).is_string ())
139 options =
" " +
args(1).string_value ();
140 else if (
args(1).is_empty ())
142 else if (
args(1).is_cellstr ())
149 options +=
" " +
tmp(
i);
152 error (
"convhulln: OPTIONS must be a string, cell array of strings, or empty");
155 boolT ismalloc =
false;
160 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)
161 FILE *outfile = std::fopen (
"NUL",
"w");
163 FILE *outfile = std::fopen (
"/dev/null",
"w");
165 FILE *errfile = stderr;
168 error (
"convhulln: unable to create temporary file for output");
178 strcpy (cmd_str, cmd.c_str ());
180 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
181 ismalloc, cmd_str, outfile, errfile);
183 error (
"convhulln: qhull failed");
185 bool nonsimp_seen =
false;
199 if (! (nonsimp_seen || facet->simplicial || qh hull_dim == 2))
203 if (cmd.find (
"QJ") != std::string::npos)
205 error (
"convhulln: qhull failed: option 'QJ' returned non-simplicial facet");
210 setT *vertices = qh_facet3vertex (facet);
212 vertexT *vertex, **vertexp;
214 FOREACHvertex_ (vertices)
215 idx(i, j++) = 1 + qh_pointid(vertex->point);
217 qh_settempfree (&vertices);
221 if (facet->toporient ^ qh_ORIENTclock)
223 vertexT *vertex, **vertexp;
225 FOREACHvertex_ (facet->vertices)
226 idx(i, j++) = 1 + qh_pointid(vertex->point);
230 vertexT *vertex, **vertexp;
232 FOREACHvertexreverse12_ (facet->vertices)
233 idx(i, j++) = 1 + qh_pointid(vertex->point);
237 warning (
"convhulln: facet %d only has %d vertices", i, j);
245 idx.
resize (nf, dim, 0.0);
259 if (facet->upperdelaunay && qh ATinfinity)
262 facet->f.area = area = qh_facetarea (facet);
263 facet->isarea = True;
267 if (facet->upperdelaunay == qh UPPERdelaunay)
273 qh_distplane (qh interior_point, facet, &dist);
274 qh totvol += -dist * area/ qh hull_dim;
284 qh_freeqhull (! qh_ALL);
286 int curlong, totlong;
287 qh_memfreeshort (&curlong, &totlong);
289 if (curlong || totlong)
290 warning (
"convhulln: did not free %d bytes of long memory (%d pieces)",
297 octave_unused_parameter (
args);
298 octave_unused_parameter (
nargout);
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
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
void error(const char *fmt,...)
static void close_fcn(FILE *f)
octave_idx_type rows(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
void add_fcn(void(*fcn)(void))
Matrix transpose(void) const
void warning(const char *fmt,...)
octave::unwind_protect frame
charNDArray max(char d, const charNDArray &m)
=val(i)}if ode{val(i)}occurs in table i
static bool octave_qhull_dims_ok(octave_idx_type dim, octave_idx_type n, const char *who)
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
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))