Go to the documentation of this file.
75 printf(
"\n%d vertices and %d facets with normals:\n",
76 qh->num_vertices,
qh->num_facets);
78 for (k=0; k <
qh->hull_dim; k++)
79 printf(
"%6.2g ", facet->
normal[k]);
92 for (j=0; j<numpoints; j++) {
93 point= points + j*
dim;
122 for (j= 0; j < numnew ; j++) {
123 point= points + (numpoints+j)*
dim;
124 if (points ==
qh->first_point)
125 qh->num_points= numpoints+j+1;
132 point[k]= (j & 1) ? 2.0 : -2.0;
141 printf(
"%d vertices and %d facets\n",
142 qh->num_vertices,
qh->num_facets);
147 else if (
qh->KEEPnearinside)
159 seed= (int)time(NULL);
160 printf(
"seed: %d\n",
seed);
162 for (j=0; j<numpoints; j++) {
163 point= points + j*
dim;
164 for (k= 0; k <
dim-1; k++) {
189 for (j= 0; j < numnew ; j++) {
190 point= points + (numpoints+j)*
dim;
191 if (points ==
qh->first_point)
192 qh->num_points= numpoints+j+1;
197 for (k= 0; k <
dim-1; k++) {
208 printf(
"%d points, %d extra points, %d vertices, and %d facets in total\n",
210 qh->num_vertices,
qh->num_facets);
216 else if (
qh->KEEPnearinside)
237 for (k= 0; k <
dim-1; k++)
242 fprintf(stderr,
"findDelaunay: not implemented for triangulated, non-simplicial Delaunay regions (tricoplanar facet, f%d).\n",
247 for (k=0; k <
dim-1; k++)
248 printf(
"%5.2f ", vertex->
point[k]);
263 for (j=0; j<numpoints; j++) {
264 point= points + j*(
dim+1);
298 coordT *point, normal[100], offset, *next;
303 for (j= 0; j < numnew ; j++) {
309 normal[k]= -normal[k];
313 point= points + (numpoints+j)* (
dim+1);
321 printf(
"%d points, %d extra points, %d vertices, and %d facets in total\n",
323 qh->num_vertices,
qh->num_facets);
328 else if (
qh->KEEPnearinside)
333 #define SIZEcube (1<<DIM)
334 #define SIZEdiamond (2*DIM)
335 #define TOTpoints (SIZEcube + SIZEdiamond)
346 int main(
int argc,
char *argv[]) {
348 int curlong, totlong, exitcode;
355 printf(
"This is the output from user_eg2_r.c\n\n\
356 It shows how qhull() may be called from an application using qhull's\n\
357 static, reentrant library. user_eg2 is not part of qhull itself. If it\n\
358 appears accidently, please remove user_eg2_r.c from your project. If it fails\n\
359 immediately, user_eg2_r.c was incorrectly linked to the non-reentrant library.\n\
360 Also try 'user_eg2 T1 2>&1'\n\n");
367 exitcode= setjmp(
qh->errexit);
372 strcat(
qh->rbox_command,
"user_eg2 cube example");
373 sprintf(options,
"qhull s Tcv Q11 %s ", argc >= 2 ? argv[1] :
"");
375 printf(
"\ncompute triangulated convex hull of cube after rotating input\n");
382 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
384 printf(
"\nadd points in a diamond\n");
389 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
395 if (curlong || totlong)
396 fprintf(stderr,
"qhull warning (user_eg2, run 1): did not free %d bytes of long memory (%d pieces)\n",
402 exitcode= setjmp(
qh->errexit);
407 strcat(
qh->rbox_command,
"user_eg2 Delaunay example");
408 sprintf(options,
"qhull s d Tcv %s", argc >= 3 ? argv[2] :
"");
410 printf(
"\ncompute %d-d Delaunay triangulation\n",
DIM-1);
425 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
427 printf(
"\nadd points to triangulation\n");
431 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
433 printf(
"\nfind Delaunay triangle closest to [0.5, 0.5, ...]\n");
439 if (curlong || totlong)
440 fprintf(stderr,
"qhull warning (user_eg2, run 2): did not free %d bytes of long memory (%d pieces)\n",
446 exitcode= setjmp(
qh->errexit);
452 strcat(
qh->rbox_command,
"user_eg2 halfspace example");
453 sprintf(options,
"qhull H0 s Tcv %s", argc >= 4 ? argv[3] :
"");
455 printf(
"\ncompute halfspace intersection about the origin for a diamond\n");
465 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
467 printf(
"\nadd halfspaces for cube to intersection\n");
471 if (
qh->VERIFYoutput && !
qh->STOPpoint && !
qh->STOPcone)
478 if (curlong || totlong)
479 fprintf(stderr,
"qhull warning (user_eg2, run 3): did not free %d bytes of long memory (%d pieces)\n",
495 if (
qh->ERREXITcalled) {
496 fprintf(
qh->ferr,
"qhull error while processing previous error. Exit program\n");
500 if (!
qh->QHULLfinished)
501 qh->hulltime= (unsigned)clock() -
qh->hulltime;
502 fprintf(
qh->ferr,
"\nWhile executing: %s | %s\n",
qh->rbox_command,
qh->qhull_command);
503 fprintf(
qh->ferr,
"Options selected:\n%s\n",
qh->qhull_options);
504 if (
qh->furthest_id >= 0) {
505 fprintf(
qh->ferr,
"\nLast point added to hull was p%d",
qh->furthest_id);
508 if (
qh->QHULLfinished)
509 fprintf(
qh->ferr,
"\nQhull has finished constructing the hull.");
510 else if (
qh->POSTmerging)
511 fprintf(
qh->ferr,
"\nQhull has started post-merging");
512 fprintf(
qh->ferr,
"\n\n");
515 fprintf(
qh->ferr,
"qhull error while ending program. Exit program\n");
521 longjmp(
qh->errexit, exitcode);
531 fprintf(
qh->ferr,
"%s facets f%d f%d ridge r%d vertex v%d\n",
549 fprintf(
qh->ferr,
"facet f%d\n", facet->
id);
560 if (
qh->MERGEexact ||
qh->PREmerge ||
qh->JOGGLEmax <
REALmax/2)
562 A Qhull error has occurred. Qhull should have corrected the above\n\
563 precision error. Please send the input and all of the output to\n\
564 qhull_bug@qhull.org\n");
567 Precision problems were detected during construction of the convex hull.\n\
568 This occurs because convex hull algorithms assume that calculations are\n\
569 exact, but floating-point arithmetic has roundoff errors.\n\
571 To correct for precision problems, do not use 'Q0'. By default, Qhull\n\
572 selects 'C-0' or 'Qx' and merges non-convex facets. With option 'QJ',\n\
573 Qhull joggles the input to prevent precision problems. See \"Imprecision\n\
574 in Qhull\" (qh-impre.htm).\n\
576 If you use 'Q0', the output may include\n\
577 coplanar ridges, concave ridges, and flipped facets. In 4-d and higher,\n\
578 Qhull may produce a ridge with four neighbors or two facets with the same \n\
579 vertices. Qhull reports these events when they occur. It stops when a\n\
580 concave ridge, flipped facet, or duplicate facet occurs.\n");
584 Qhull is currently using single precision arithmetic. The following\n\
585 will probably remove the precision problems:\n\
586 - recompile qhull for realT precision(#define REALfloat 0 in user.h).\n");
588 if (
qh->DELAUNAY && !
qh->SCALElast &&
qh->MAXabs_coord > 1e4)
591 When computing the Delaunay triangulation of coordinates > 1.0,\n\
592 - use 'Qbb' to scale the last coordinate to [0,m] (max previous coordinate)\n");
593 if (
qh->DELAUNAY && !
qh->ATinfinity)
595 When computing the Delaunay triangulation:\n\
596 - use 'Qz' to add a point at-infinity. This reduces precision problems.\n");
600 If you need triangular output:\n\
601 - use option 'Qt' to triangulate the output\n\
602 - use option 'QJ' to joggle the input points and remove precision errors\n\
603 - use option 'Ft'. It triangulates non-simplicial facets with added points.\n\
605 If you must use 'Q0',\n\
606 try one or more of the following options. They can not guarantee an output.\n\
607 - use 'QbB' to scale the input to a cube.\n\
608 - use 'Po' to produce output and prevent partitioning for flipped facets\n\
609 - use 'V0' to set min. distance to visible facet as 0 instead of roundoff\n\
610 - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
611 - options 'Qf', 'Qbb', and 'QR0' may also help\n",
615 To guarantee simplicial output:\n\
616 - use option 'Qt' to triangulate the output\n\
617 - use option 'QJ' to joggle the input points and remove precision errors\n\
618 - use option 'Ft' to triangulate the output by adding points\n\
619 - use exact arithmetic (see \"Imprecision in Qhull\", qh-impre.htm)\n\
635 The initial hull is narrow (cosine of min. angle is %.16f).\n\
636 A coplanar point may lead to a wide facet. Options 'QbB' (scale to unit box)\n\
637 or 'Qbb' (scale last coordinate) may remove this warning. Use 'Pp' to skip\n\
638 this warning. See 'Limitations' in qh-impre.htm.\n",
648 realT min, max, *coord, dist;
652 The input to qhull appears to be less than %d dimensional, or a\n\
653 computation has overflowed.\n\n\
654 Qhull could not construct a clearly convex simplex from points:\n",
659 The center point is coplanar with a facet, or a vertex is coplanar\n\
660 with a neighboring facet. The maximum round off error for\n\
661 computing distances is %2.2g. The center point, facets and distances\n\
662 to the center point are as follows:\n\n",
qh->DISTround);
676 These points are the dual of the given halfspaces. They indicate that\n\
677 the intersection is degenerate.\n");
679 These points either have a maximum or minimum x-coordinate, or\n\
680 they maximize the determinant for k coordinates. Trial points\n\
681 are first selected from points that maximize a coordinate.\n");
684 Because of the high dimension, the min x-coordinate and max-coordinate\n\
685 points are used if the determinant is non-zero. Option 'Qs' will\n\
686 do a better, though much slower, job. Instead of 'Qs', you can change\n\
687 the points by randomly rotating the input with 'QR0'.\n");
689 qh_fprintf(
qh, fp, 9385,
"\nThe min and max coordinates for each dimension are:\n");
690 for (k=0; k <
qh->hull_dim; k++) {
693 for (i=
qh->num_points, coord=
qh->first_point+k; i--; coord +=
qh->hull_dim) {
697 qh_fprintf(
qh, fp, 9386,
" %d: %8.4g %8.4g difference= %4.4g\n", k, min, max, max-min);
701 If the input should be full dimensional, you have several options that\n\
702 may determine an initial simplex:\n\
703 - use 'QJ' to joggle the input and make it full dimensional\n\
704 - use 'QbB' to scale the points to the unit cube\n\
705 - use 'QR0' to randomly rotate the input for different maximum points\n\
706 - use 'Qs' to search all points for the initial simplex\n\
707 - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
708 - trace execution with 'T3' to see the determinant for each point.\n",
712 - recompile qhull for realT precision(#define REALfloat 0 in libqhull.h).\n");
715 If the input is lower dimensional:\n\
716 - use 'QJ' to joggle the input and make it full dimensional\n\
717 - use 'Qbk:0Bk:0' to delete coordinate k from the input. You should\n\
718 pick the coordinate with the least range. The hull will have the\n\
720 - determine the flat containing the points, rotate the points\n\
721 into a coordinate plane, and delete the other coordinates.\n\
722 - add one or more points to make the input full dimensional.\n\
724 if (
qh->DELAUNAY && !
qh->ATinfinity)
726 This is a Delaunay triangulation and the input is co-circular or co-spherical:\n\
727 - use 'Qz' to add a point \"at infinity\" (i.e., above the paraboloid)\n\
728 - or use 'QJ' to joggle the input and avoid co-circular data\n");
facetT * qh_findbestfacet(pointT *point, boolT bestoutside, realT *bestdist, boolT *isoutside)
boolT qh_sethalfspace(int dim, coordT *coords, coordT **nextp, coordT *normal, coordT *offset, coordT *feasible)
void seed(unsigned int seed_value)
#define FORALLfacet_(facetlist)
void qh_printvertexlist(FILE *fp, const char *string, facetT *facetlist, setT *facets, boolT printall)
#define FOREACHfacet_(facets)
void qh_check_maxout(void)
int main(int argc, char *argv[])
boolT qh_addpoint(pointT *furthest, facetT *facet, boolT checkdist)
void qh_printafacet(FILE *fp, qh_PRINT format, facetT *facet, boolT printall)
void print_summary(qhT *qh)
void qh_check_output(void)
void makehalf(coordT *points, int numpoints, int dim)
void qh_printpoint(FILE *fp, const char *string, pointT *point)
void qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall)
#define qh_RANDOMseed_(seed)
void qh_errprint(qhT *qh, const char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex)
void qh_setdelaunay(int dim, int count, pointT *points)
void qh_check_points(void)
void adddiamond(qhT *qh, coordT *points, int numpoints, int numnew, int dim)
void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[])
void qh_freeqhull(boolT allmem)
void qh_printpointid(FILE *fp, const char *string, int dim, pointT *point, int id)
int qh_setsize(setT *set)
void qh_user_memsizes(qhT *qh)
void qh_setfeasible(int dim)
coordT * qh_sethalfspace_all(int dim, int count, coordT *halfspaces, pointT *feasible)
void qh_nearcoplanar(void)
void qh_printhelp_degenerate(qhT *qh, FILE *fp)
#define minimize_(minval, val)
void addDelaunay(qhT *qh, coordT *points, int numpoints, int numnew, int dim)
int qh_pointid(pointT *point)
void qh_distplane(pointT *point, facetT *facet, realT *dist)
void findDelaunay(qhT *qh, int dim)
void qh_produce_output(void)
void qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge)
void addhalf(qhT *qh, coordT *points, int numpoints, int numnew, int dim, coordT *feasible)
void qh_triangulate(void)
void qh_printhelp_singular(qhT *qh, FILE *fp)
void qh_memfreeshort(int *curlong, int *totlong)
void qh_printend(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall)
void qh_initflags(char *command)
#define FOREACHvertex_(vertices)
void qh_printhelp_narrowhull(qhT *qh, FILE *fp, realT minangle)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
#define maximize_(maxval, val)
void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc)
void makecube(coordT *points, int numpoints, int dim)
void makeDelaunay(qhT *qh, coordT *points, int numpoints, int dim)
void qh_printbegin(FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall)
hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:59