32 #if defined (HAVE_CONFIG_H) 50 #if defined (HAVE_QHULL) 54 # if defined (NEED_QHULL_VERSION) 55 char qh_version[] =
"convhulln.oct 2007-07-24";
67 qh_freeqhull (! qh_ALL);
70 qh_memfreeshort (&curlong, &totlong);
72 if (curlong || totlong)
73 warning (
"convhulln: did not free %d bytes of long memory (%d pieces)",
84 if (dim > maxval || n > maxval)
85 error (
"%s: dimension too large for Qhull", who);
128 #if defined (HAVE_QHULL) 130 int nargin = args.length ();
137 Matrix points (args(0).matrix_value ());
155 if (args(1).is_string ())
156 options =
' ' + args(1).string_value ();
157 else if (args(1).isempty ())
169 error (
"convhulln: OPTIONS must be a string, cell array of strings, or empty");
172 boolT ismalloc =
false;
177 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM) 178 FILE *outfile = std::fopen (
"NUL",
"w");
180 FILE *outfile = std::fopen (
"/dev/null",
"w");
182 FILE *errfile = stderr;
185 error (
"convhulln: unable to create temporary file for output");
195 strcpy (cmd_str, cmd.c_str ());
197 int exitcode = qh_new_qhull (dim, num_points, points.
fortran_vec (),
198 ismalloc, cmd_str, outfile, errfile);
203 error (
"convhulln: qhull failed");
205 bool nonsimp_seen =
false;
219 if (! (nonsimp_seen || facet->simplicial || qh hull_dim == 2))
223 if (cmd.find (
"QJ") != std::string::npos)
225 error (
"convhulln: qhull failed: option 'QJ' returned non-simplicial facet");
230 setT *vertices = qh_facet3vertex (facet);
232 vertexT *vertex, **vertexp;
234 FOREACHvertex_ (vertices)
235 idx(
i, j++) = 1 + qh_pointid(vertex->point);
237 qh_settempfree (&vertices);
241 if (facet->toporient ^ qh_ORIENTclock)
243 vertexT *vertex, **vertexp;
245 FOREACHvertex_ (facet->vertices)
246 idx(
i, j++) = 1 + qh_pointid(vertex->point);
250 vertexT *vertex, **vertexp;
252 FOREACHvertexreverse12_ (facet->vertices)
253 idx(
i, j++) = 1 + qh_pointid(vertex->point);
257 warning (
"convhulln: facet %d only has %d vertices",
i, j);
265 idx.
resize (nf, dim, 0.0);
279 if (facet->upperdelaunay && qh ATinfinity)
282 facet->f.area = area = qh_facetarea (facet);
283 facet->isarea = True;
287 if (facet->upperdelaunay == qh UPPERdelaunay)
293 qh_distplane (qh interior_point, facet, &dist);
294 qh totvol += -dist * area/ qh hull_dim;
307 octave_unused_parameter (args);
308 octave_unused_parameter (
nargout);
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
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
const T * fortran_vec(void) const
void add_fcn(void(*fcn)(void))
void error(const char *fmt,...)
octave_idx_type columns(void) const
static void close_fcn(FILE *f)
Matrix transpose(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)
OCTAVE_EXPORT octave_value_list or both For fclose
static void free_qhull_memory()
OCTAVE_EXPORT octave_value_list iscellstr
void warning(const char *fmt,...)
octave::unwind_protect frame
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
charNDArray max(char d, const charNDArray &m)
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)
Macro to define an at run time dynamically loadable builtin function.
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