65 if (!
qh PRINTout[i]) {
66 qh PRINTout[i]= format;
87 char *s= command, *
t, *chkerr;
88 char key, opt, prevopt;
94 if (*hiddenflags !=
' ' || hiddenflags[strlen(hiddenflags)-1] !=
' ') {
95 qh_fprintf(
qh ferr, 6026,
"qhull error (qh_checkflags): hiddenflags must start and end with a space: \"%s\"", hiddenflags);
98 if (strpbrk(hiddenflags,
",\n\r\t")) {
99 qh_fprintf(
qh ferr, 6027,
"qhull error (qh_checkflags): hiddenflags contains commas, newlines, or tabs: \"%s\"", hiddenflags);
102 while (*s && !isspace(*s))
105 while (*s && isspace(*s))
113 if (key ==
'T' && (*s ==
'I' || *s ==
'O')) {
118 if (strstr(hiddenflags, chkkey)) {
120 }
else if (isupper(key)) {
125 while (!chkerr && *s && !isspace(*s)) {
129 if (strstr(hiddenflags, chkopt))
131 if (prevopt !=
' ') {
134 if (strstr(hiddenflags, chkopt2))
137 }
else if (key ==
'Q' && isdigit(opt) && prevopt !=
'b' 138 && (prevopt ==
' ' || islower(prevopt))) {
140 if (strstr(hiddenflags, chkopt))
152 chkerr[strlen(chkerr)-1]=
'\'';
153 qh_fprintf(
qh ferr, 6029,
"qhull error: option %s is not used with this program.\n It may be used with qhull.\n", chkerr);
179 qh GOODvertexp= NULL;
204 for (k=
qh input_dim+1; k--; ) {
215 if (!
qh qhull_commandsiz2)
216 qh qhull_commandsiz2= (int)strlen(
qh qhull_command);
218 qh qhull_command[
qh qhull_commandsiz2]=
'\0';
220 if (!
qh qhull_optionsiz2)
221 qh qhull_optionsiz2= (int)strlen(
qh qhull_options);
223 qh qhull_options[
qh qhull_optionsiz2]=
'\0';
241 #if (qh_CLOCKtype == 2) 248 if ((clktck= sysconf(_SC_CLK_TCK)) < 0) {
249 qh_fprintf(
qh ferr, 6030,
"qhull internal error (qh_clock): sysconf() failed. Use qh_CLOCKtype 1 in user.h\n");
253 if (times(&time) == -1) {
254 qh_fprintf(
qh ferr, 6031,
"qhull internal error (qh_clock): times() failed. Use qh_CLOCKtype 1 in user.h\n");
258 ticks= time.tms_utime * ratio;
261 qh_fprintf(
qh ferr, 6032,
"qhull internal error (qh_clock): use qh_CLOCKtype 2 in user.h\n");
278 trace5((
qh ferr, 5001,
"qh_freebuffers: freeing up global memory buffers\n"));
287 qh NEARzero=
qh lower_threshold=
qh upper_threshold= NULL;
288 qh lower_bound=
qh upper_bound= NULL;
300 if (
qh feasible_point)
302 if (
qh feasible_string)
304 qh line=
qh feasible_string= NULL;
305 qh half_space=
qh feasible_point=
qh temp_malloc= NULL;
307 if (
qh first_point &&
qh POINTSmalloc) {
309 qh first_point= NULL;
311 if (
qh input_points &&
qh input_malloc) {
313 qh input_points= NULL;
315 trace5((
qh ferr, 5002,
"qh_freebuffers: finished\n"));
346 trace1((
qh ferr, 1005,
"qh_freebuild: free memory from qh_inithull and qh_buildhull\n"));
350 while ((vertex=
qh vertex_list)) {
355 qh newvertex_list=
qh vertex_list= NULL;
358 }
else if (
qh VERTEXneighbors) {
363 qh GOODclosest= NULL;
377 while ((facet=
qh facet_list)) {
394 qh visible_list=
qh newfacet_list=
qh facet_list= NULL;
410 qh interior_point= NULL;
413 qh facet_mergeset= NULL;
414 qh degen_mergeset= NULL;
456 trace1((
qh ferr, 1006,
"qh_freeqhull: free global memory\n"));
461 memset((
char *)qh_qh, 0,
sizeof(
qhT));
464 memset((
char *)&qh_qh, 0,
sizeof(
qhT));
487 void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile,
int argc,
char *argv[]) {
541 if (
qh PROJECTinput || (
qh DELAUNAY &&
qh PROJECTdelaunay))
545 if (
qh ROTATErandom >= 0) {
548 int k, lastk=
qh hull_dim-1;
549 for (k=0; k < lastk; k++) {
550 qh gm_row[k][lastk]= 0.0;
551 qh gm_row[lastk][k]= 0.0;
553 qh gm_row[lastk][lastk]= 1.0;
579 qh_fprintf(
qh ferr, 6033,
"qhull input error: more than %d characters in command line\n",
580 (
int)
sizeof(
qh qhull_command));
616 int k, i, lastproject;
617 char *s= command, *
t, *prev_s, *start, key;
622 qh_fprintf(
qh ferr, 6245,
"qhull initflags error: qh.NOerrexit was not cleared before calling qh_initflags(). It should be cleared after setjmp(). Exit qhull.");
625 if (command <= &
qh qhull_command[0] || command > &
qh qhull_command[0] +
sizeof(
qh qhull_command)) {
626 if (command != &
qh qhull_command[0]) {
627 *
qh qhull_command=
'\0';
628 strncat(
qh qhull_command, command,
sizeof(
qh qhull_command)-strlen(
qh qhull_command)-1);
630 while (*s && !isspace(*s))
634 while (*s && isspace(*s))
680 if (!isdigit(*s) && *s !=
'.' && *s !=
'-')
681 qh_fprintf(
qh ferr, 7002,
"qhull warning: no maximum cosine angle given for option 'An'. Ignored.\n");
685 qh_option(
"Angle-premerge-", NULL, &
qh premerge_cos);
689 qh_option(
"Angle-postmerge", NULL, &
qh postmerge_cos);
696 if (!isdigit(*s) && *s !=
'.' && *s !=
'-')
697 qh_fprintf(
qh ferr, 7003,
"qhull warning: no centrum radius given for option 'Cn'. Ignored.\n");
701 qh_option(
"Centrum-premerge-", NULL, &
qh premerge_centrum);
705 qh_option(
"Centrum-postmerge", NULL, &
qh postmerge_centrum);
713 qh_fprintf(
qh ferr, 7004,
"qhull warning: negative maximum roundoff given for option 'An'. Ignored.\n");
714 else if (!isdigit(*s))
715 qh_fprintf(
qh ferr, 7005,
"qhull warning: no maximum roundoff given for option 'En'. Ignored.\n");
718 qh_option(
"Distance-roundoff", NULL, &
qh DISTround);
727 if (*t && !isspace(*t)) {
731 qh_fprintf(
qh ferr, 7006,
"qhull warning: origin for Halfspace intersection should be 'Hn,n,n,...'\n");
737 if (!(
qh feasible_string= (
char*)calloc((
size_t)(t-start+1), (
size_t)1))) {
738 qh_fprintf(
qh ferr, 6034,
"qhull error: insufficient memory for 'Hn,n,n'\n");
741 strncpy(
qh feasible_string, start, (
size_t)(t-start));
742 qh_option(
"Halfspace-about", NULL, NULL);
749 qh_fprintf(
qh ferr, 7007,
"qhull warning: missing random perturbation for option 'Rn'. Ignored\n");
752 qh_option(
"Random_perturb", NULL, &
qh RANDOMfactor);
757 if (!isdigit(*s) && *s !=
'-')
758 qh_fprintf(
qh ferr, 7008,
"qhull warning: missing visible distance for option 'Vn'. Ignored\n");
765 if (!isdigit(*s) && *s !=
'-')
766 qh_fprintf(
qh ferr, 7009,
"qhull warning: missing coplanar distance for option 'Un'. Ignored\n");
774 qh_fprintf(
qh ferr, 7010,
"qhull warning: negative outside width for option 'Wn'. Ignored.\n");
775 else if (!isdigit(*s))
776 qh_fprintf(
qh ferr, 7011,
"qhull warning: missing outside width for option 'Wn'. Ignored\n");
785 while (*s && !isspace(*s)) {
837 qh_option(
"FNeighbors-vertex", NULL, NULL);
845 if (
qh PRINToptions1st) {
852 qh_option(
"Fpoint-intersect", NULL, NULL);
881 qh_option(
"FVertex-average", NULL, NULL);
890 qh_fprintf(
qh ferr, 7012,
"qhull warning: unknown 'F' output option %c, rest ignored\n", (
int)s[0]);
891 while (*++s && !isspace(*s));
899 while (*s && !isspace(*s)) {
935 qh PRINTtransparent=
True;
943 qh_fprintf(
qh ferr, 6035,
"qhull input error: missing dimension for option 'GDn'\n");
946 qh_fprintf(
qh ferr, 7013,
"qhull warning: can only drop one dimension. Previous 'GD%d' ignored\n",
954 qh_fprintf(
qh ferr, 7014,
"qhull warning: unknown 'G' print option %c, rest ignored\n", (
int)s[0]);
955 while (*++s && !isspace(*s));
961 while (*s && !isspace(*s)) {
972 qh_option(
"Pdrop-facets-dim-less", &i, &r);
974 qh_option(
"PDrop-facets-dim-more", &i, &r);
981 qh_option(
"PGood-facet-neighbors", NULL, NULL);
989 qh_option(
"Pprecision-ignore", NULL, NULL);
994 qh_fprintf(
qh ferr, 6036,
"qhull input error: missing facet count for keep area option 'PAn'\n");
1003 qh_fprintf(
qh ferr, 6037,
"qhull input error: missing facet area for option 'PFn'\n");
1006 qh_option(
"PFacet-area-keep", NULL, &
qh KEEPminArea);
1012 qh_fprintf(
qh ferr, 6038,
"qhull input error: missing merge count for option 'PMn'\n");
1020 qh_fprintf(
qh ferr, 7015,
"qhull warning: unknown 'P' print option %c, rest ignored\n", (
int)s[0]);
1021 while (*++s && !isspace(*s));
1028 while (*s && !isspace(*s)) {
1032 if (key ==
'b' && *s ==
'B') {
1036 qh_option(
"QbBound-unit-box", NULL, &r);
1039 if (key ==
'b' && *s ==
'b') {
1052 while (*t && !isspace(*t)) {
1053 if (toupper(*t++) ==
'B' 1058 trace2((
qh ferr, 2004,
"qh_initflags: project dimension %d\n", k));
1068 if (lastproject == k && r == 0.0)
1070 else if (key ==
'b') {
1084 qh_option(
"Qcoplanar-keep", NULL, NULL);
1088 qh_option(
"Qfurthest-outside", NULL, NULL);
1092 qh_option(
"Qgood-facets-only", NULL, NULL);
1096 qh_option(
"Qinterior-keep", NULL, NULL);
1100 qh_option(
"Qmax-outside-only", NULL, NULL);
1104 qh_option(
"Qrandom-outside", NULL, NULL);
1108 qh_option(
"Qsearch-initial-simplex", NULL, NULL);
1118 qh_fprintf(
qh ferr, 6039,
"qhull input error: missing number of test points for option 'QTn'\n");
1125 qh_option(
"QupperDelaunay", NULL, NULL);
1129 qh_option(
"Qvertex-neighbors-convex", NULL, NULL);
1137 qh_option(
"Qz-infinity-point", NULL, NULL);
1141 qh_option(
"Q0-no-premerge", NULL, NULL);
1146 qh_option(
"Q1-no-angle-sort", NULL, NULL);
1156 qh_option(
"Q11-trinormals Qtriangulate", NULL, NULL);
1161 qh_option(
"Q12-no-wide-dup", NULL, NULL);
1166 qh_fprintf(
qh ferr, 7016,
"qhull warning: unknown 'Q' qhull option 1%c, rest ignored\n", (
int)s[0]);
1167 while (*++s && !isspace(*s));
1172 qh_option(
"Q2-no-merge-independent", NULL, NULL);
1174 goto LABELcheckdigit;
1177 qh_option(
"Q3-no-merge-vertices", NULL, NULL);
1181 qh_fprintf(
qh ferr, 7017,
"qhull warning: can not follow '1', '2', or '3' with a digit. '%c' skipped.\n",
1185 qh_option(
"Q4-avoid-old-into-new", NULL, NULL);
1189 qh_option(
"Q5-no-check-outer", NULL, NULL);
1193 qh_option(
"Q6-no-concave-merge", NULL, NULL);
1197 qh_option(
"Q7-no-breadth-first", NULL, NULL);
1201 qh_option(
"Q8-no-near-inside", NULL, NULL);
1205 qh_option(
"Q9-pick-furthest", NULL, NULL);
1211 qh_fprintf(
qh ferr, 7018,
"qhull warning: good point already defined for option 'QGn'. Ignored\n");
1213 qh_fprintf(
qh ferr, 7019,
"qhull warning: missing good point id for option 'QGn'. Ignored\n");
1214 else if (i < 0 || *s ==
'-') {
1216 qh_option(
"QGood-if-dont-see-point", &i, NULL);
1219 qh_option(
"QGood-if-see-point", &i, NULL);
1224 if (!isdigit(*s) && *s !=
'-')
1232 if (!isdigit(*s) && *s !=
'-')
1233 qh_fprintf(
qh ferr, 7020,
"qhull warning: missing random seed for option 'QRn'. Ignored\n");
1245 qh_fprintf(
qh ferr, 7021,
"qhull warning: good vertex already defined for option 'QVn'. Ignored\n");
1247 qh_fprintf(
qh ferr, 7022,
"qhull warning: no good point id given for option 'QVn'. Ignored\n");
1249 qh GOODvertex= i - 1;
1250 qh_option(
"QV-good-facets-not-point", &i, NULL);
1252 qh_option(
"QV-good-facets-point", &i, NULL);
1253 qh GOODvertex= i + 1;
1259 qh_fprintf(
qh ferr, 7023,
"qhull warning: unknown 'Q' qhull option %c, rest ignored\n", (
int)s[0]);
1260 while (*++s && !isspace(*s));
1266 while (*s && !isspace(*s)) {
1267 if (isdigit(*s) || *s ==
'-')
1269 else switch (*s++) {
1271 qh_option(
"Tannotate-output", NULL, NULL);
1275 qh_option(
"Tcheck-frequently", NULL, NULL);
1276 qh CHECKfrequently=
True;
1280 qh PRINTstatistics=
True;
1292 qh_fprintf(
qh ferr, 7024,
"qhull warning: output file undefined(stdout). Option 'Tz' ignored.\n");
1302 qh_fprintf(
qh ferr, 7025,
"qhull warning: missing point id for cone for trace option 'TCn'. Ignored\n");
1311 qh_fprintf(
qh ferr, 7026,
"qhull warning: missing frequency count for trace option 'TFn'. Ignored\n");
1315 qh REPORTfreq2=
qh REPORTfreq/2;
1320 qh_fprintf(
qh ferr, 7027,
"qhull warning: missing space between 'TI' and filename, %s\n", s);
1329 if (!freopen(filename,
"r", stdin)) {
1330 qh_fprintf(
qh ferr, 6041,
"qhull error: could not open file \"%s\".", filename);
1340 qh_fprintf(
qh ferr, 7028,
"qhull warning: missing space between 'TO' and filename, %s\n", s);
1350 qh_fprintf(
qh ferr, 6266,
"qhull input warning: qh.fout was not set by caller. Cannot use option 'TO' to redirect output. Ignoring option 'TO'\n");
1351 }
else if (!freopen(filename,
"w",
qh fout)) {
1352 qh_fprintf(
qh ferr, 6044,
"qhull error: could not open file \"%s\".", filename);
1362 qh_fprintf(
qh ferr, 7029,
"qhull warning: missing point id for trace option 'TPn'. Ignored\n");
1370 qh_fprintf(
qh ferr, 7030,
"qhull warning: missing merge id for trace option 'TMn'. Ignored\n");
1378 qh_fprintf(
qh ferr, 7031,
"qhull warning: missing rerun count for trace option 'TRn'. Ignored\n");
1387 qh_fprintf(
qh ferr, 7032,
"qhull warning: missing furthest point id for trace option 'TVn'. Ignored\n");
1389 qh STOPpoint= i - 1;
1390 qh_option(
"TV-stop-before-point", &i, NULL);
1392 qh STOPpoint= i + 1;
1393 qh_option(
"TV-stop-after-point", &i, NULL);
1399 qh_fprintf(
qh ferr, 7033,
"qhull warning: missing max width for trace option 'TWn'. Ignored\n");
1407 qh_fprintf(
qh ferr, 7034,
"qhull warning: unknown 'T' trace option %c, rest ignored\n", (
int)s[0]);
1408 while (*++s && !isspace(*s));
1414 qh_fprintf(
qh ferr, 7035,
"qhull warning: unknown flag %c(%x)\n", (
int)s[-1],
1418 if (s-1 == prev_s && *s && !isspace(*s)) {
1419 qh_fprintf(
qh ferr, 7036,
"qhull warning: missing space after flag %c(%x); reserved for menu. Skipped.\n",
1420 (
int)*prev_s, (
int)*prev_s);
1421 while (*s && !isspace(*s))
1426 qh_fprintf(
qh ferr, 7078,
"qhull warning: 'TCn' (stopCone) ignored when used with 'QJn' (joggle)\n");
1427 if (isgeom && !
qh FORCEoutput &&
qh PRINTout[1])
1428 qh_fprintf(
qh ferr, 7037,
"qhull warning: additional output formats are not compatible with Geomview\n");
1456 for (k=
qh input_dim+1; k--; ) {
1497 int seed, pointsneeded, extra= 0, i, randi, k;
1503 trace0((
qh ferr, 13,
"qh_initqhull_globals: for %s | %s\n",
qh rbox_command,
1505 qh POINTSmalloc= ismalloc;
1506 qh first_point= points;
1507 qh num_points= numpoints;
1508 qh hull_dim=
qh input_dim= dim;
1509 if (!
qh NOpremerge && !
qh MERGEexact && !
qh PREmerge &&
qh JOGGLEmax >
REALmax/2) {
1511 if (
qh hull_dim <= 4) {
1518 }
else if (
qh MERGEexact)
1525 if (
qh TRIangulate &&
qh JOGGLEmax <
REALmax/2 &&
qh PRINTprecision)
1526 qh_fprintf(
qh ferr, 7038,
"qhull warning: joggle('QJ') always produces simplicial output. Triangulated output('Qt') does nothing.\n");
1527 if (
qh JOGGLEmax <
REALmax/2 &&
qh DELAUNAY && !
qh SCALEinput && !
qh SCALElast) {
1529 qh_option(
"Qbbound-last-qj", NULL, NULL);
1531 if (
qh MERGING && !
qh POSTmerge &&
qh premerge_cos >
REALmax/2
1532 &&
qh premerge_centrum == 0) {
1537 if (
qh JOGGLEmax < REALmax/2 && REALepsilon > 2e-8 &&
qh PRINTprecision)
1538 qh_fprintf(
qh ferr, 7039,
"qhull warning: real epsilon, %2.2g, is probably too large for joggle('QJn')\nRecompile with double precision reals(see user.h).\n",
1542 qh_fprintf(
qh ferr, 6045,
"qhull input error: merging not installed(qh_NOmerge + 'Qx', 'Cn' or 'An')\n");
1546 if (
qh DELAUNAY &&
qh KEEPcoplanar && !
qh KEEPinside) {
1548 qh_option(
"Qinterior-keep", NULL, NULL);
1550 if (
qh DELAUNAY &&
qh HALFspace) {
1551 qh_fprintf(
qh ferr, 6046,
"qhull input error: can not use Delaunay('d') or Voronoi('v') with halfspace intersection('H')\n");
1554 if (!
qh DELAUNAY && (
qh UPPERdelaunay ||
qh ATinfinity)) {
1555 qh_fprintf(
qh ferr, 6047,
"qhull input error: use upper-Delaunay('Qu') or infinity-point('Qz') with Delaunay('d') or Voronoi('v')\n");
1558 if (
qh UPPERdelaunay &&
qh ATinfinity) {
1559 qh_fprintf(
qh ferr, 6048,
"qhull input error: can not use infinity-point('Qz') with upper-Delaunay('Qu')\n");
1562 if (
qh SCALElast && !
qh DELAUNAY &&
qh PRINTprecision)
1563 qh_fprintf(
qh ferr, 7040,
"qhull input warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
1564 qh DOcheckmax= (!
qh SKIPcheckmax &&
qh MERGING );
1565 qh KEEPnearinside= (
qh DOcheckmax && !(
qh KEEPinside &&
qh KEEPcoplanar)
1566 && !
qh NOnearinside);
1569 else if (
qh VORONOI)
1571 if (
qh TESTvneighbors && !
qh MERGING) {
1572 qh_fprintf(
qh ferr, 6049,
"qhull input error: test vertex neighbors('Qv') needs a merge option\n");
1575 if (
qh PROJECTinput || (
qh DELAUNAY &&
qh PROJECTdelaunay)) {
1576 qh hull_dim -=
qh PROJECTinput;
1583 if (
qh hull_dim <= 1) {
1584 qh_fprintf(
qh ferr, 6050,
"qhull error: dimension %d must be > 1\n",
qh hull_dim);
1587 for (k=2, factorial=1.0; k <
qh hull_dim; k++)
1589 qh AREAfactor= 1.0 / factorial;
1590 trace2((
qh ferr, 2005,
"qh_initqhull_globals: initialize globals. dim %d numpoints %d malloc? %d projected %d to hull_dim %d\n",
1591 dim, numpoints, ismalloc,
qh PROJECTinput,
qh hull_dim));
1592 qh normal_size=
qh hull_dim *
sizeof(
coordT);
1593 qh center_size=
qh normal_size -
sizeof(
coordT);
1594 pointsneeded=
qh hull_dim+1;
1597 qh_option(
"Q3-no-merge-vertices-dim-high", NULL, NULL);
1603 qh_fprintf(
qh ferr, 6051,
"qhull input error: tracing is not installed(qh_NOtrace in user.h)");
1608 qh TRACElastrun=
qh IStracing;
1609 if (
qh IStracing != -1)
1612 qh TRACElevel= (
qh IStracing?
qh IStracing : 3);
1615 if (
qh ROTATErandom == 0 ||
qh ROTATErandom == -1) {
1616 seed= (int)time(&timedata);
1617 if (
qh ROTATErandom == -1) {
1619 qh_option(
"QRandom-seed", &seed, NULL );
1621 qh_option(
"QRotate-random", &seed, NULL);
1622 qh ROTATErandom= seed;
1624 seed=
qh ROTATErandom;
1625 if (seed == INT_MIN)
1631 for (i=1000; i--; ) {
1636 qhull configuration error (qh_RANDOMmax in user.h):\n\ 1637 random integer %d > qh_RANDOMmax(%.8g)\n",
1647 qhull configuration warning (qh_RANDOMmax in user.h):\n\ 1648 average of 1000 random integers (%.2g) is much different than expected (%.2g).\n\ 1649 Is qh_RANDOMmax (%.2g) wrong?\n",
1652 qh RANDOMb= 1.0 -
qh RANDOMfactor;
1654 qh_fprintf(
qh ferr, 6052,
"qhull internal error (qh_initqhull_globals): qh_HASHfactor %d must be at least 1.1. Qhull uses linear hash probing\n",
1658 if (numpoints+extra < pointsneeded) {
1659 qh_fprintf(
qh ferr, 6214,
"qhull input error: not enough points(%d) to construct initial simplex (need %d)\n",
1660 numpoints, pointsneeded);
1726 trace3((
qh ferr, 3024,
"qh_initqhull_outputflags: %s\n",
qh qhull_command));
1727 if (!(
qh PRINTgood ||
qh PRINTneighbors)) {
1728 if (
qh KEEParea ||
qh KEEPminArea <
REALmax/2 ||
qh KEEPmerge ||
qh DELAUNAY
1729 || (!
qh ONLYgood && (
qh GOODvertex ||
qh GOODpoint))) {
1734 if (
qh PRINTtransparent) {
1735 if (
qh hull_dim != 4 || !
qh DELAUNAY ||
qh VORONOI ||
qh DROPdim >= 0) {
1736 qh_fprintf(
qh ferr, 6215,
"qhull input error: transparent Delaunay('Gt') needs 3-d Delaunay('d') w/o 'GDn'\n");
1748 printcoplanar=
True;
1750 printcoplanar=
True;
1752 qh_fprintf(
qh ferr, 6053,
"qhull input error: option 'Fp' is only used for \nhalfspace intersection('Hn,n,n').\n");
1755 qh_fprintf(
qh ferr, 6054,
"qhull input error: option 'Ft' is not available for Voronoi vertices or halfspace intersection\n");
1758 qh_fprintf(
qh ferr, 6055,
"qhull input error: option 'FC' is not available for Voronoi vertices('v')\n");
1767 if (printcoplanar &&
qh DELAUNAY &&
qh JOGGLEmax <
REALmax/2) {
1768 if (
qh PRINTprecision)
1769 qh_fprintf(
qh ferr, 7041,
"qhull input warning: 'QJ' (joggle) will usually prevent coincident input sites for options 'Fc' and 'FP'\n");
1771 if (printmath && (
qh hull_dim > 3 ||
qh VORONOI)) {
1772 qh_fprintf(
qh ferr, 6056,
"qhull input error: Mathematica and Maple output is only available for 2-d and 3-d convex hulls and 2-d Delaunay triangulations\n");
1776 if (
qh hull_dim > 4) {
1777 qh_fprintf(
qh ferr, 6057,
"qhull input error: Geomview output is only available for 2-d, 3-d and 4-d\n");
1780 if (
qh PRINTnoplanes && !(
qh PRINTcoplanar +
qh PRINTcentrums
1781 +
qh PRINTdots +
qh PRINTspheres +
qh DOintersections +
qh PRINTridges)) {
1782 qh_fprintf(
qh ferr, 6058,
"qhull input error: no output specified for Geomview\n");
1785 if (
qh VORONOI && (
qh hull_dim > 3 ||
qh DROPdim >= 0)) {
1786 qh_fprintf(
qh ferr, 6059,
"qhull input error: Geomview output for Voronoi diagrams only for 2-d\n");
1790 if (
qh hull_dim == 4 &&
qh DROPdim == -1 &&
1791 (
qh PRINTcoplanar ||
qh PRINTspheres ||
qh PRINTcentrums)) {
1792 qh_fprintf(
qh ferr, 7042,
"qhull input warning: coplanars, vertices, and centrums output not\n\ 1793 available for 4-d output(ignored). Could use 'GDn' instead.\n");
1794 qh PRINTcoplanar=
qh PRINTspheres=
qh PRINTcentrums=
False;
1797 if (!
qh KEEPcoplanar && !
qh KEEPinside && !
qh ONLYgood) {
1798 if ((
qh PRINTcoplanar &&
qh PRINTspheres) || printcoplanar) {
1799 if (
qh QHULLfinished) {
1800 qh_fprintf(
qh ferr, 7072,
"qhull output warning: ignoring coplanar points, option 'Qc' was not set for the first run of qhull.\n");
1807 qh PRINTdim=
qh hull_dim;
1808 if (
qh DROPdim >=0) {
1809 if (
qh DROPdim <
qh hull_dim) {
1811 if (!printgeom ||
qh hull_dim < 3)
1812 qh_fprintf(
qh ferr, 7043,
"qhull input warning: drop dimension 'GD%d' is only available for 3-d/4-d Geomview\n",
qh DROPdim);
1815 }
else if (
qh VORONOI) {
1816 qh DROPdim=
qh hull_dim-1;
1817 qh PRINTdim=
qh hull_dim-1;
1831 qh_fprintf(errfile, 6205,
"qhull error (qh_initqhull_start): qh_qh already defined. Call qh_save_qhull() first\n");
1835 qh_fprintf(errfile, 6060,
"qhull error (qh_initqhull_start): insufficient memory\n");
1862 memset((
char *)qh_qh, 0,
sizeof(
qhT));
1864 memset((
char *)&qh_qh, 0,
sizeof(
qhT));
1877 qh max_outside= 0.0;
1879 qh MAXabs_coord= 0.0;
1880 qh MAXsumcoord= 0.0;
1882 qh MERGEindependent=
True;
1888 qh premerge_centrum= 0.0;
1891 qh PRINTradius= 0.0;
1893 qh postmerge_centrum= 0.0;
1894 qh ROTATErandom= INT_MIN;
1900 qh tracefacet_id= UINT_MAX;
1901 qh tracevertex_id= UINT_MAX;
1902 seed= (int)time(&timedata);
1908 strcat(
qh qhull,
"qhull");
1937 maxdim=
qh input_dim;
1938 if (
qh DELAUNAY && (
qh PROJECTdelaunay ||
qh PROJECTinput))
1945 while (*s && !isspace(key= *s++)) {
1946 if (key ==
'd' || key ==
'D') {
1948 qh_fprintf(
qh ferr, 7044,
"qhull warning: no dimension given for Print option '%c' at: %s. Ignored\n",
1953 if (idx >=
qh hull_dim) {
1954 qh_fprintf(
qh ferr, 7045,
"qhull warning: dimension %d for Print option '%c' is >= %d. Ignored\n",
1955 idx, key,
qh hull_dim);
1961 if (fabs((
double)value) > 1.0) {
1962 qh_fprintf(
qh ferr, 7046,
"qhull warning: value %2.4g for Print option %c is > +1 or < -1. Ignored\n",
1969 qh lower_threshold[idx]= value;
1971 qh upper_threshold[idx]= value;
1974 }
else if (*s ==
'Q') {
1976 while (*s && !isspace(key= *s++)) {
1977 if (key ==
'b' && *s ==
'B') {
1979 for (k=maxdim; k--; ) {
1983 }
else if (key ==
'b' && *s ==
'b')
1985 else if (key ==
'b' || key ==
'B') {
1987 qh_fprintf(
qh ferr, 7047,
"qhull warning: no dimension given for Qhull option %c. Ignored\n",
1992 if (idx >= maxdim) {
1993 qh_fprintf(
qh ferr, 7048,
"qhull warning: dimension %d for Qhull option %c is >= %d. Ignored\n",
2000 }
else if (key ==
'b')
2005 qh lower_bound[idx]= value;
2007 qh upper_bound[idx]= value;
2011 while (*s && !isspace(*s))
2017 for (k=
qh hull_dim; k--; ) {
2018 if (
qh lower_threshold[k] > -
REALmax/2) {
2020 if (
qh upper_threshold[k] <
REALmax/2) {
2021 qh SPLITthresholds=
True;
2025 }
else if (
qh upper_threshold[k] <
REALmax/2)
2039 void qh_lib_check(
int qhullLibraryType,
int qhTsize,
int vertexTsize,
int ridgeTsize,
int facetTsize,
int setTsize,
int qhmemTsize) {
2042 #if defined(_MSC_VER) && defined(_DEBUG) && defined(QHULL_CRTDBG) 2044 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) );
2045 _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
2046 _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
2047 _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
2048 _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
2049 _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
2050 _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
2055 qh_fprintf_stderr(6246,
"qh_lib_check: Incorrect qhull library called. Caller uses a static qhT while library uses a dynamic qhT via qh_QHpointer. Both caller and library are non-reentrant.\n");
2060 qh_fprintf_stderr(6247,
"qh_lib_check: Incorrect qhull library called. Caller uses a dynamic qhT via qh_QHpointer while library uses a static qhT. Both caller and library are non-reentrant.\n");
2064 qh_fprintf_stderr(6248,
"qh_lib_check: Incorrect qhull library called. Caller uses reentrant Qhull while library is non-reentrant\n");
2067 qh_fprintf_stderr(6262,
"qh_lib_check: Expecting qhullLibraryType QHULL_NON_REENTRANT(0), QHULL_QH_POINTER(1), or QHULL_REENTRANT(2). Got %d\n", qhullLibraryType);
2070 if (qhTsize !=
sizeof(
qhT)) {
2071 qh_fprintf_stderr(6249,
"qh_lib_check: Incorrect qhull library called. Size of qhT for caller is %d, but for library is %d.\n", qhTsize,
sizeof(
qhT));
2074 if (vertexTsize !=
sizeof(
vertexT)) {
2075 qh_fprintf_stderr(6250,
"qh_lib_check: Incorrect qhull library called. Size of vertexT for caller is %d, but for library is %d.\n", vertexTsize,
sizeof(
vertexT));
2078 if (ridgeTsize !=
sizeof(
ridgeT)) {
2079 qh_fprintf_stderr(6251,
"qh_lib_check: Incorrect qhull library called. Size of ridgeT for caller is %d, but for library is %d.\n", ridgeTsize,
sizeof(
ridgeT));
2082 if (facetTsize !=
sizeof(
facetT)) {
2083 qh_fprintf_stderr(6252,
"qh_lib_check: Incorrect qhull library called. Size of facetT for caller is %d, but for library is %d.\n", facetTsize,
sizeof(
facetT));
2086 if (setTsize && setTsize !=
sizeof(
setT)) {
2087 qh_fprintf_stderr(6253,
"qh_lib_check: Incorrect qhull library called. Size of setT for caller is %d, but for library is %d.\n", setTsize,
sizeof(
setT));
2090 if (qhmemTsize && qhmemTsize !=
sizeof(
qhmemT)) {
2091 qh_fprintf_stderr(6254,
"qh_lib_check: Incorrect qhull library called. Size of qhmemT for caller is %d, but for library is %d.\n", qhmemTsize,
sizeof(
qhmemT));
2096 qh_fprintf_stderr(6255,
"qh_lib_check: Cannot continue. Library '%s' uses a dynamic qhT via qh_QHpointer (e.g., qhull_p.so)\n",
qh_version2);
2119 sprintf(buf,
" %s", option);
2121 sprintf(buf+strlen(buf),
" %d", *i);
2123 sprintf(buf+strlen(buf),
" %2.2g", *r);
2124 len= (int)strlen(buf);
2125 qh qhull_optionlen += len;
2126 maxlen=
sizeof(
qh qhull_options) - len -1;
2129 qh qhull_optionlen= len;
2130 strncat(
qh qhull_options,
"\n", (
size_t)(maxlen--));
2132 strncat(
qh qhull_options, buf, (
size_t)maxlen);
2154 void qh_restore_qhull(
qhT **oldqh) {
2156 if (*oldqh && strcmp((*oldqh)->qhull,
"qhull")) {
2157 qh_fprintf(
qhmem.
ferr, 6061,
"qhull internal error (qh_restore_qhull): %p is not a qhull data structure\n",
2162 qh_fprintf(
qhmem.
ferr, 6062,
"qhull internal error (qh_restore_qhull): did not save or free existing qhull\n");
2166 qh_fprintf(
qhmem.
ferr, 6063,
"qhull internal error (qh_restore_qhull): did not previously save qhull %p\n",
2175 qh old_tempstack= 0;
2176 trace1((
qh ferr, 1007,
"qh_restore_qhull: restored qhull from %p\n", *oldqh));
2199 qhT *qh_save_qhull(
void) {
2204 qh_fprintf(
qhmem.
ferr, 6064,
"qhull internal error (qh_save_qhull): qhull not initialized\n");
void qh_clear_outputflags(void)
void qh_settempfree_all(void)
void qh_initqhull_start2(FILE *infile, FILE *outfile, FILE *errfile)
void seed(unsigned int seed_value)
void * qh_malloc(size_t size)
double qh_strtod(const char *s, char **endp)
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
void qh_settruncate(setT *set, int size)
#define otherfacet_(ridge, facet)
char * qh_skipfilename(char *filename)
boolT qh_gram_schmidt(int dim, realT **rows)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
void qh_copyfilename(char *filename, int size, const char *source, int length)
int qh_strtol(const char *s, char **endp)
void qh_delvertex(vertexT *vertex)
void qh_user_memsizes(void)
void qh_lib_check(int qhullLibraryType, int qhTsize, int vertexTsize, int ridgeTsize, int facetTsize, int setTsize, int qhmemTsize)
void qh_init_A(FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[])
void qh_delfacet(facetT *facet)
void qh_meminitbuffers(int tracelevel, int alignment, int numsizes, int bufsize, int bufinit)
#define FOREACHridge_(ridges)
void qh_init_qhull_command(int argc, char *argv[])
unsigned long qh_clock(void)
void qh_freeqhull(boolT allmem)
void qh_freestatistics(void)
#define maximize_(maxval, val)
void qh_memsize(int size)
void qh_option(const char *option, int *i, realT *r)
void qh_exit(int exitcode)
void qh_initthresholds(char *command)
void qh_setfree(setT **setp)
#define FOREACHmerge_(merges)
void qh_freeqhull2(boolT allmem)
void qh_initstatistics(void)
void qh_randommatrix(realT *buffer, int dim, realT **row)
void qh_init_B(coordT *points, int numpoints, int dim, boolT ismalloc)
#define qh_DIMmergeVertex
int qh_argv_to_command(int argc, char *argv[], char *command, int max_size)
void qh_projectinput(void)
void qh_memfree(void *object, int insize)
void qh_freebuild(boolT allmem)
void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge)
void qh_rotateinput(realT **rows)
void qh_setfreelong(setT **setp)
void qh_initflags(char *command)
void qh_initqhull_start(FILE *infile, FILE *outfile, FILE *errfile)
void qh_initqhull_buffers(void)
void qh_meminit(FILE *ferr)
void * qh_memalloc(int insize)
setT * qh_setnew(int setsize)
void qh_initqhull_outputflags(void)
#define qh_RANDOMseed_(seed)
void qh_initqhull_mem(void)
void qh_freebuffers(void)
void qh_checkflags(char *command, char *hiddenflags)
void qh_appendprint(qh_PRINT format)
#define QHULL_NON_REENTRANT
void qh_initqhull_globals(coordT *points, int numpoints, int dim, boolT ismalloc)