67 printf(
"\n%d vertices and %d facets with normals:\n",
71 printf(
"%6.2g ", facet->
normal[k]);
84 for (j=0; j<numpoints; j++) {
85 point= points + j*dim;
105 printf(
"seed: %d\n", seed);
107 for (j=0; j<numpoints; j++) {
108 point= points + j*dim;
109 for (k= 0; k < dim; k++) {
133 for (k= 0; k < dim; k++)
138 fprintf(stderr,
"findDelaunay: not implemented for triangulated, non-simplicial Delaunay regions (tricoplanar facet, f%d).\n",
143 for (k=0; k < dim; k++)
144 printf(
"%5.2f ", vertex->
point[k]);
159 for (j=0; j<numpoints; j++) {
160 point= points + j*(dim+1);
172 #define SIZEcube (1<<DIM) 173 #define SIZEdiamond (2*DIM) 174 #define TOTpoints (SIZEcube + SIZEdiamond) 185 int main(
int argc,
char *argv[]) {
192 FILE *outfile= stdout;
194 FILE *errfile= stderr;
197 int curlong, totlong;
207 printf(
"This is the output from user_eg_r.c\n\n\ 208 It shows how qhull() may be called from an application using the qhull\n\ 209 reentrant library. user_eg is not part of qhull itself. If it appears\n\ 210 accidently, please remove user_eg_r.c from your project. If it fails\n\ 211 immediately, user_eg_r.c was incorrectly linked to the non-reentrant library.\n\ 212 Also try 'user_eg T1 2>&1'\n\n");
217 printf(
"\ncompute convex hull of cube after rotating input\n");
218 sprintf(flags,
"qhull s Tcv %s", argc >= 2 ? argv[1] :
"");
221 for (i=numpoints; i--; )
222 rows[i]= points+dim*i;
224 exitcode=
qh_new_qhull(qh, dim, numpoints, points, ismalloc,
225 flags, outfile, errfile);
235 if (curlong || totlong)
236 fprintf(errfile,
"qhull internal warning (user_eg, #1): did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
242 printf(
"\ncompute %d-d Delaunay triangulation\n", dim);
243 sprintf(flags,
"qhull s d Tcv %s", argc >= 3 ? argv[2] :
"");
245 makeDelaunay(qh, points, numpoints, dim, (
int)time(NULL));
246 for (i=numpoints; i--; )
247 rows[i]= points+dim*i;
249 exitcode=
qh_new_qhull(qh, dim, numpoints, points, ismalloc,
250 flags, outfile, errfile);
259 printf(
"\nfind %d-d Delaunay triangle closest to [0.5, 0.5, ...]\n", dim);
276 printf(
"\nCompute a new triangulation as a separate instance of Qhull\n");
277 sprintf(flags,
"qhull s d Tcv %s", argc >= 3 ? argv[2] :
"");
279 makeDelaunay(qhB, pointsB, numpoints, dim, (
int)time(NULL)+1);
280 for (i=numpoints; i--; )
281 rows[i]= pointsB+dim*i;
283 exitcode=
qh_new_qhull(qhB, dim, numpoints, pointsB, ismalloc,
284 flags, outfile, errfile);
287 printf(
"\nFree memory allocated by the new instance of Qhull, and redisplay the old results.\n");
290 if (curlong || totlong)
291 fprintf(errfile,
"qhull internal warning (user_eg, #4): did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
299 if (curlong || totlong)
300 fprintf(errfile,
"qhull internal warning (user_eg, #2): did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
305 printf(
"\ncompute halfspace intersection about the origin for a diamond\n");
306 sprintf(flags,
"qhull H0 s Tcv %s", argc >= 4 ? argv[3] :
"Fp");
309 for (i=numpoints; i--; )
310 rows[i]= points+(dim+1)*i;
311 qh_printmatrix(qh, outfile,
"input as halfspace coefficients + offsets", rows, numpoints, dim+1);
315 exitcode=
qh_new_qhull(qh, dim+1, numpoints, points, ismalloc,
316 flags, outfile, errfile);
321 if (curlong || totlong)
322 fprintf(stderr,
"qhull internal warning (user_eg, #3): did not free %d bytes of long memory (%d pieces)\n",
facetT * qh_findbestfacet(pointT *point, boolT bestoutside, realT *bestdist, boolT *isoutside)
void makecube(coordT *points, int numpoints, int dim)
#define FOREACHvertex_(vertices)
void qh_zero(qhT *qh, FILE *errfile)
void qh_setdelaunay(int dim, int count, pointT *points)
void qh_freeqhull(boolT allmem)
void print_summary(qhT *qh)
void qh_printmatrix(FILE *fp, const char *string, realT **rows, int numrow, int numcol)
int main(int argc, char *argv[])
void makeDelaunay(qhT *qh, coordT *points, int numpoints, int dim, int seed)
void makehalf(coordT *points, int numpoints, int dim)
void findDelaunay(qhT *qh, int dim)
void qh_memfreeshort(int *curlong, int *totlong)
int qh_new_qhull(int dim, int numpoints, coordT *points, boolT ismalloc, char *qhull_cmd, FILE *outfile, FILE *errfile)
void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge)
#define qh_RANDOMseed_(seed)