45 qh_fprintf(
qh,
qh->ferr, 6206,
"qhull internal error (qh_produce_output): temporary sets not empty(%d)\n",
62 if (
qh->PRINTprecision && !
qh->MERGING && (
qh->JOGGLEmax >
REALmax/2 ||
qh->RERUN))
66 if (
qh->PRINTstatistics) {
71 size in bytes: merge %d ridge %d vertex %d facet %d\n\
72 normal %d ridge vertices %d facet vertices or neighbors %d\n",
78 qh_fprintf(
qh,
qh->ferr, 6065,
"qhull internal error (qh_produce_output2): temporary sets not empty(%d)\n",
95 if (facet->
id ==
id) {
113 if (vertex->
id ==
id) {
134 if (
a->f.area >
b->f.area)
136 else if (
a->f.area ==
b->f.area)
150 return(
a->nummerge -
b->nummerge);
163 if (!(i=
a->visitid))
165 if (!(j=
b->visitid))
196 if (length > size + 1) {
197 qh_fprintf(
qh,
qh->ferr, 6040,
"qhull error: filename is more than %d characters, %s\n", size-1, source);
202 if (
c ==
'\'' ||
c ==
'"') {
245 int *numfacetsp,
int *numsimplicialp,
int *totneighborsp,
int *numridgesp,
int *numcoplanarsp,
int *numtricoplanarsp) {
247 int numfacets= 0, numsimplicial= 0, numridges= 0, totneighbors= 0, numcoplanars= 0, numtricoplanars= 0;
284 qh->visit_id += numfacets+1;
285 *numfacetsp= numfacets;
286 *numsimplicialp= numsimplicial;
287 *totneighborsp= totneighbors;
288 *numridgesp= numridges;
289 *numcoplanarsp= numcoplanars;
290 *numtricoplanarsp= numtricoplanars;
336 int i, k, pointid, pointidA, point_i, point_n;
338 pointT *point, **pointp, *point0, *midpoint, *normal, *inpoint;
339 coordT *coord, *gmcoord, *normalp;
344 int dim=
qh->hull_dim - 1;
345 realT dist, offset, angle, zero= 0.0;
347 midpoint=
qh->gm_matrix +
qh->hull_dim *
qh->hull_dim;
348 for (k=0; k <
dim; k++)
349 midpoint[k]= (vertex->
point[k] + vertexA->
point[k])/2;
360 if (numcenters >
dim) {
367 }
else if (numcenters ==
dim) {
372 qh_fprintf(
qh,
qh->ferr, 6216,
"qhull internal error (qh_detvnorm): too few points(%d) to compute separating plane\n", numcenters);
376 gmcoord=
qh->gm_matrix;
379 if (
qh->IStracing >= 4)
382 if (point != point0) {
383 qh->gm_row[i++]= gmcoord;
386 *(gmcoord++)= *point++ - *coord++;
389 qh->gm_row[i]= gmcoord;
392 normal, &offset, &nearzero);
393 if (
qh->GOODvertexp == vertexA->
point)
394 inpoint= vertexA->
point;
396 inpoint= vertex->
point;
403 *normalp= -(*normalp);
407 if (
qh->VERIFYoutput ||
qh->PRINTstatistics) {
418 trace4((
qh,
qh->ferr, 4014,
"qh_detvnorm: points %d %d midpoint dist %2.2g\n",
419 pointid, pointidA, dist));
420 for (k=0; k <
dim; k++)
421 midpoint[k]= vertexA->
point[k] - vertex->
point[k];
430 trace4((
qh,
qh->ferr, 4015,
"qh_detvnorm: points %d %d angle %2.2g nearzero %d\n",
431 pointid, pointidA, angle, nearzero));
442 if (simplex != points) {
453 trace4((
qh,
qh->ferr, 4016,
"qh_detvnorm: points %d %d Voronoi vertex %d dist %2.2g\n",
454 pointid, pointidA, facet->
visitid, dist));
460 if (simplex != points)
480 facetT *neighbor, **neighborp;
484 if (neighbor->
seen) {
488 }
else if (firstinf) {
522 facetT *neighbor, **neighborp, *facet= NULL;
528 if (!neighbor->
seen2) {
535 if (neighbor->
seen) {
539 }
else if (firstinf) {
545 if (!neighbor->
seen2) {
554 if (
qh->CHECKfrequently) {
556 if (!neighbor->
seen2) {
557 qh_fprintf(
qh,
qh->ferr, 6217,
"qhull internal error (qh_detvridge3): neighbors of vertex p%d are not connected at facet %d\n",
621 facetT *neighbor, **neighborp, *neighborA, **neighborAp;
627 unsigned int numfacets= (
unsigned int)
qh->num_facets;
637 if (neighbor->
visitid < numfacets)
641 if (neighbor->
seen) {
649 if (neighborA->
seen) {
653 }
else if (firstinf) {
659 if (count >=
qh->hull_dim - 1) {
670 trace4((
qh,
qh->ferr, 4017,
"qh_eachvoronoi: Voronoi ridge of %d vertices between sites %d and %d\n",
672 if (printvridge && fp) {
673 if (inorder &&
qh->hull_dim == 3+1)
677 (*printvridge)(
qh, fp, atvertex, vertex, centers, unbounded);
744 !
qh_ALL, innerouter, inorder);
807 if (facetlist ==
qh->facet_list && allfacets && !facets) {
819 if (vertex->
visitid !=
qh->vertex_visit) {
830 if (vertex->
visitid !=
qh->vertex_visit) {
854 radius=
qh->PRINTradius;
856 radius -=
qh->JOGGLEmax * sqrt((
realT)
qh->hull_dim);
857 *outerplane += radius;
858 *innerplane -= radius;
859 if (
qh->PRINTcoplanar ||
qh->PRINTspheres) {
864 *innerplane= *outerplane= 0;
896 trace2((
qh,
qh->ferr, 2006,
"qh_markkeep: only keep %d largest and/or %d most merged facets and/or min area %.2g\n",
897 qh->KEEParea,
qh->KEEPmerge,
qh->KEEPminArea));
906 if ((count= size -
qh->KEEParea) > 0) {
917 if ((count= size -
qh->KEEPmerge) > 0) {
1012 *numcentersp= numcenters;
1013 trace2((
qh,
qh->ferr, 2007,
"qh_markvoronoi: isLower %d numcenters %d\n", isLower, numcenters));
1034 facetT *facet, *neighbor, **neighborp;
1036 trace4((
qh,
qh->ferr, 4018,
"qh_order_vertexneighbors: order neighbors of v%d for 3-d\n", vertex->
id));
1050 qh_fprintf(
qh,
qh->ferr, 6066,
"qhull internal error (qh_order_vertexneighbors): no neighbor of v%d for f%d\n",
1051 vertex->
id, facet->
id);
1076 if (
qh->TRIangulate && !
qh->hasTriangulation) {
1078 if (
qh->VERIFYoutput && !
qh->CHECKfrequently)
1084 if (
qh->KEEParea ||
qh->KEEPmerge ||
qh->KEEPminArea <
REALmax/2)
1086 if (
qh->PRINTstatistics)
1114 realT color[4], offset, dist, outerplane, innerplane;
1116 coordT *point, *normp, *coordp, **pointp, *feasiblep;
1119 facetT *neighbor, **neighborp;
1152 for (k=
qh->hull_dim; k--; ) {
1153 color[k]= (facet->
normal[k]+1.0)/2.0;
1158 if (
qh->PRINTdim !=
qh->hull_dim)
1160 if (
qh->hull_dim <= 2)
1162 else if (
qh->hull_dim == 3) {
1189 offset= facet->
offset - innerplane;
1190 goto LABELprintnorm;
1197 goto LABELprintnorm;
1201 offset= facet->
offset - outerplane;
1204 qh_fprintf(
qh, fp, 9017,
"no normal for facet f%d\n", facet->
id);
1207 if (
qh->CDDoutput) {
1209 for (k=0; k <
qh->hull_dim; k++)
1212 for (k=0; k <
qh->hull_dim; k++)
1220 if (
qh->hull_dim == 2)
1233 if (!
qh->feasible_point) {
1234 qh_fprintf(
qh,
qh->ferr, 6067,
"qhull input error (qh_printafacet): option 'Fp' needs qh->feasible_point\n");
1238 goto LABELprintinfinite;
1241 feasiblep=
qh->feasible_point;
1242 if (facet->
offset < -
qh->MINdenom) {
1243 for (k=
qh->hull_dim; k--; )
1244 *(coordp++)= (*(normp++) / - facet->
offset) + *(feasiblep++);
1246 for (k=
qh->hull_dim; k--; ) {
1248 &zerodiv) + *(feasiblep++);
1251 goto LABELprintinfinite;
1259 for (k=
qh->hull_dim; k--; )
1310 int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
1315 pointT *point, **pointp, *pointtemp;
1318 qh_countfacets(
qh, facetlist, facets, printall, &numfacets, &numsimplicial,
1319 &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
1340 if (
qh->hull_dim > 4)
1342 if (
qh->VORONOI &&
qh->hull_dim > 3)
1344 if (
qh->hull_dim == 2 && (
qh->PRINTridges ||
qh->DOintersections))
1345 qh_fprintf(
qh,
qh->ferr, 7049,
"qhull warning: output for ridges and intersections not implemented in 2-d\n");
1346 if (
qh->hull_dim == 4 && (
qh->PRINTinner ||
qh->PRINTouter ||
1347 (
qh->PRINTdim == 4 &&
qh->PRINTcentrums)))
1348 qh_fprintf(
qh,
qh->ferr, 7050,
"qhull warning: output for outer/inner planes and centrums not implemented in 4-d\n");
1349 if (
qh->PRINTdim == 4 && (
qh->PRINTspheres))
1350 qh_fprintf(
qh,
qh->ferr, 7051,
"qhull warning: output for vertices not implemented in 4-d\n");
1351 if (
qh->PRINTdim == 4 &&
qh->DOintersections &&
qh->PRINTnoplanes)
1352 qh_fprintf(
qh,
qh->ferr, 7052,
"qhull warning: 'Gnh' generates no output in 4-d\n");
1353 if (
qh->PRINTdim == 2) {
1354 qh_fprintf(
qh, fp, 9036,
"{appearance {linewidth 3} LIST # %s | %s\n",
1355 qh->rbox_command,
qh->qhull_command);
1356 }
else if (
qh->PRINTdim == 3) {
1357 qh_fprintf(
qh, fp, 9037,
"{appearance {+edge -evert linewidth 2} LIST # %s | %s\n",
1358 qh->rbox_command,
qh->qhull_command);
1359 }
else if (
qh->PRINTdim == 4) {
1366 qh->ridgeoutnum= num;
1368 qh_fprintf(
qh, fp, 9038,
"LIST # %s | %s\n",
qh->rbox_command,
qh->qhull_command);
1371 if (
qh->PRINTdots) {
1374 if (
qh->DELAUNAY &&
qh->ATinfinity)
1376 if (
qh->PRINTdim == 4)
1381 for (i=num; i--; ) {
1387 for (i=num-1; i--; ) {
1395 if (
qh->PRINTdim == 4)
1402 if (
qh->PRINTdim == 4)
1407 qh_fprintf(
qh, fp, 9047,
"0 1 1 1 # color of points\n");
1410 if (
qh->PRINTdim == 4 && !
qh->PRINTnoplanes)
1412 qh_fprintf(
qh, fp, 9048,
"4OFF %d %d 1\n", 3*
qh->ridgeoutnum,
qh->ridgeoutnum);
1413 qh->PRINTcradius= 2 *
qh->DISTround;
1416 }
else if (
qh->POSTmerge)
1418 qh->PRINTradius=
qh->PRINTcradius;
1419 if (
qh->PRINTspheres +
qh->PRINTcoplanar)
1423 }
else if (!
qh->PREmerge &&
qh->POSTmerge &&
qh->postmerge_cos <
REALmax/2) {
1424 maximize_(
qh->PRINTradius, (1-
qh->postmerge_cos) *
qh->MAXabs_coord);
1428 qh->PRINTradius +=
qh->JOGGLEmax * sqrt((
realT)
qh->hull_dim);
1429 if (
qh->PRINTdim != 4 &&
1430 (
qh->PRINTcoplanar ||
qh->PRINTspheres ||
qh->PRINTcentrums)) {
1432 if (
qh->PRINTspheres &&
qh->PRINTdim <= 3)
1434 if (
qh->PRINTcoplanar ||
qh->PRINTcentrums) {
1436 if (
qh->PRINTcoplanar&& !
qh->PRINTspheres) {
1445 if (
qh->PRINTcentrums &&
qh->PRINTdim <= 3)
1447 if (!
qh->PRINTcoplanar)
1459 if (
qh->PRINTcentrums &&
qh->PRINTdim <= 3)
1461 if (!
qh->PRINTcoplanar)
1477 if (
qh->VORONOI &&
qh->PRINTprecision)
1478 qh_fprintf(
qh,
qh->ferr, 7053,
"qhull warning: writing Delaunay. Use 'p' or 'o' for Voronoi centers\n");
1479 qh->printoutvar=
qh->vertex_id;
1480 if (
qh->hull_dim <= 3)
1483 qh_fprintf(
qh, fp, 9051,
"%d\n", numsimplicial+numridges);
1489 qh_fprintf(
qh, fp, 9052,
"%s | %s\nbegin\n %d %d real\n",
qh->rbox_command,
1490 qh->qhull_command, numfacets,
qh->hull_dim+1);
1496 if (
qh->hull_dim > 3)
1499 qh_fprintf(
qh,
qh->ferr, 7054,
"qhull warning: output is the Delaunay triangulation\n");
1501 if (
qh->hull_dim == 2)
1525 qh->num_points+
qh_setsize(
qh,
qh->other_points), numfacets, totneighbors/2);
1531 + numfacets - numsimplicial, numsimplicial + numridges, totneighbors/2);
1551 qh_fprintf(
qh, fp, 9063,
"%s | %s\nbegin\n%d %d real\n",
qh->rbox_command,
1552 qh->qhull_command, numfacets,
qh->hull_dim);
1562 qh_fprintf(
qh,
qh->ferr, 6068,
"qhull internal error (qh_printbegin): can not use this format for dimension %d\n",
1591 num=
qh->hull_dim-1;
1595 for (k=0; k < num; k++)
1598 for (k=0; k < num; k++)
1607 for (k=0; k < num; k++)
1628 pointT *centrum, *projpt;
1630 realT xaxis[4], yaxis[4], normal[4], dist;
1631 realT green[3]={0, 1, 0};
1643 qh_fprintf(
qh, fp, 9072,
"{appearance {-normal -edge normscale 0} ");
1644 if (
qh->firstcentrum) {
1646 qh_fprintf(
qh, fp, 9073,
"{INST geom { define centrum CQUAD # f%d\n\
1647 -0.3 -0.3 0.0001 0 0 1 1\n\
1648 0.3 -0.3 0.0001 0 0 1 1\n\
1649 0.3 0.3 0.0001 0 0 1 1\n\
1650 -0.3 0.3 0.0001 0 0 1 1 } transform { \n", facet->
id);
1652 qh_fprintf(
qh, fp, 9074,
"{INST geom { : centrum } transform { # f%d\n", facet->
id);
1656 for (k=
qh->hull_dim; k--; ) {
1657 xaxis[k]= projpt[k] - centrum[k];
1658 normal[k]= facet->
normal[k];
1660 if (
qh->hull_dim == 2) {
1663 }
else if (
qh->hull_dim == 4) {
1669 qh_fprintf(
qh, fp, 9075,
"%8.4g %8.4g %8.4g 0\n", xaxis[0], xaxis[1], xaxis[2]);
1670 qh_fprintf(
qh, fp, 9076,
"%8.4g %8.4g %8.4g 0\n", yaxis[0], yaxis[1], yaxis[2]);
1671 qh_fprintf(
qh, fp, 9077,
"%8.4g %8.4g %8.4g 0\n", normal[0], normal[1], normal[2]);
1694 if (!
qh->printoutnum)
1695 qh_fprintf(
qh,
qh->ferr, 7055,
"qhull warning: no facets printed\n");
1698 if (
qh->hull_dim == 4 &&
qh->DROPdim < 0 && !
qh->PRINTnoplanes) {
1705 if (num !=
qh->ridgeoutnum ||
qh->printoutvar !=
qh->ridgeoutnum) {
1706 qh_fprintf(
qh,
qh->ferr, 6069,
"qhull internal error (qh_printend): number of ridges %d != number printed %d and at end %d\n",
qh->ridgeoutnum,
qh->printoutvar, num);
1754 facetT *neighbor, **neighborp;
1759 if (
qh->PRINTnoplanes || (facet->
visible &&
qh->NEWfacets))
1764 for (i=0; i < 3; i++) {
1765 color[i]= (facet->
normal[i]+1.0)/2.0;
1773 if (neighbor->
visitid !=
qh->visit_id) {
1775 qh_fprintf(
qh, fp, 9084,
"3 %d %d %d %8.4g %8.4g %8.4g 1 # f%d f%d\n",
1776 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
1777 facet->
id, neighbor->
id);
1784 if (neighbor->
visitid !=
qh->visit_id) {
1786 qh_fprintf(
qh, fp, 9085,
"3 %d %d %d %8.4g %8.4g %8.4g 1 #r%d f%d f%d\n",
1787 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
1788 ridge->
id, facet->
id, neighbor->
id);
1809 setT *vertices, *points;
1813 int numpoints=0, point_i, point_n;
1848 int numfacets, numridges, totneighbors, numcoplanars, numsimplicial, numtricoplanars;
1850 facetT *facet, *startfacet, *nextfacet;
1853 qh_countfacets(
qh, facetlist, facets, printall, &numfacets, &numsimplicial,
1854 &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
1874 qh_fprintf(
qh,
qh->ferr, 6218,
"Qhull internal error (qh_printextremes_2d): loop in facet list. facet %d nextfacet %d\n",
1875 facet->
id, nextfacet->
id);
1879 if (vertexA->
visitid !=
qh->vertex_visit) {
1883 if (vertexB->
visitid !=
qh->vertex_visit) {
1890 }
while (facet && facet != startfacet);
1907 boolT upperseen, lowerseen;
1908 facetT *neighbor, **neighborp;
1914 upperseen= lowerseen=
False;
1921 if (upperseen && lowerseen) {
1965 realT mindist, innerplane, outerplane;
1970 if (
qh->PRINTouter || (!
qh->PRINTnoplanes && !
qh->PRINTinner))
1972 if (
qh->PRINTinner || (!
qh->PRINTnoplanes && !
qh->PRINTouter &&
1975 color[k]= 1.0 - color[k];
1994 if (offset != 0.0) {
1998 qh_fprintf(
qh, fp, 9094,
"%8.4g %8.4g %8.4g\n%8.4g %8.4g %8.4g\n",
1999 p1[0],
p1[1], 0.0, p2[0], p2[1], 0.0);
2000 if (offset != 0.0) {
2004 qh_fprintf(
qh, fp, 9095,
"%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
2022 const char *pointfmt;
2028 pointfmt=
"[[%16.8f, %16.8f], [%16.8f, %16.8f]]\n";
2030 pointfmt=
"Line[{{%16.8f, %16.8f}, {%16.8f, %16.8f}}]\n";
2031 qh_fprintf(
qh, fp, 9097, pointfmt, point0[0], point0[1], point1[0], point1[1]);
2049 setT *projectedpoints, *vertices;
2050 vertexT *vertex, **vertexp, *vertexA, *vertexB;
2051 pointT *projpt, *point, **pointp;
2053 realT dist, outerplane, innerplane;
2055 realT black[3]={0, 0, 0}, green[3]={0, 1, 0};
2067 if (
qh->PRINTouter || (!
qh->PRINTnoplanes && !
qh->PRINTinner))
2069 if (
qh->PRINTinner || (!
qh->PRINTnoplanes && !
qh->PRINTouter &&
2072 color[k]= 1.0 - color[k];
2079 if ((
qh->DOintersections ||
qh->PRINTridges)
2080 && (!facet->
visible || !
qh->NEWfacets)) {
2084 if (neighbor->
visitid !=
qh->visit_id) {
2085 if (
qh->DOintersections)
2087 if (
qh->PRINTridges) {
2111 if (offset != 0.0) {
2116 printpoints= points;
2118 for (k=0; k <
qh->hull_dim; k++) {
2119 if (k ==
qh->DROPdim)
2124 if (printpoints != points)
2128 if (printpoints != points)
2131 for (i=0; i < n; i++)
2133 qh_fprintf(
qh, fp, 9104,
"%8.4g %8.4g %8.4g 1.0 }\n", color[0], color[1], color[2]);
2152 setT *points, *vertices;
2153 vertexT *vertex, **vertexp, *vertexA, *vertexB;
2154 facetT *neighbor, **neighborp;
2155 realT outerplane, innerplane;
2156 realT black[3]={0, 0, 0}, green[3]={0, 1, 0};
2164 if (
qh->PRINTouter || (!
qh->PRINTnoplanes && !
qh->PRINTinner))
2166 if (
qh->PRINTinner || (!
qh->PRINTnoplanes && !
qh->PRINTouter &&
2169 color[k]= 1.0 - color[k];
2174 if ((
qh->DOintersections ||
qh->PRINTridges)
2175 && (!facet->
visible || !
qh->NEWfacets)) {
2178 if (neighbor->
visitid !=
qh->visit_id) {
2181 if (
qh->DOintersections)
2183 if (
qh->PRINTridges) {
2207 setT *points, *vertices;
2211 const char *pointfmt, *endfmt;
2225 pointfmt=
"[%16.8f, %16.8f, %16.8f]";
2229 pointfmt=
"{%16.8f, %16.8f, %16.8f}";
2237 qh_fprintf(
qh, fp, 9109, pointfmt, point[0], point[1], point[2]);
2292 if (
qh->PRINTnoplanes || (facet->
visible &&
qh->NEWfacets))
2298 if (
qh->PRINTtransparent && !neighbor->
good)
2300 if (
qh->DOintersections)
2303 if (
qh->DROPdim >= 0)
2307 qh_fprintf(
qh, fp, 9115,
"# r%d between f%d f%d\n", ridge->
id, facet->
id, neighbor->
id);
2313 for (k=0; k <
qh->hull_dim; k++) {
2314 if (k !=
qh->DROPdim)
2320 if (
qh->DROPdim >= 0)
2321 qh_fprintf(
qh, fp, 9118,
"3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
2339 facetT *neighbor, **neighborp;
2344 if (
qh->PRINTnoplanes || (facet->
visible &&
qh->NEWfacets))
2349 if (
qh->PRINTtransparent && !neighbor->
good)
2353 if (
qh->DOintersections)
2356 if (
qh->DROPdim >= 0)
2357 qh_fprintf(
qh, fp, 9119,
"OFF 3 1 1 # ridge between f%d f%d\n",
2358 facet->
id, neighbor->
id);
2361 qh_fprintf(
qh, fp, 9120,
"# ridge between f%d f%d\n", facet->
id, neighbor->
id);
2364 for (k=0; k <
qh->hull_dim; k++) {
2365 if (k !=
qh->DROPdim)
2370 if (
qh->DROPdim >= 0)
2371 qh_fprintf(
qh, fp, 9123,
"3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
2444 pointT *point, **pointp, *furthest;
2445 facetT *neighbor, **neighborp;
2458 qh->old_randomdist=
qh->RANDOMdist;
2539 #if !qh_COMPUTEfurthest
2557 qh_fprintf(
qh, fp, 9173,
" furthest distance= %2.2g\n", dist);
2570 qh->RANDOMdist=
qh->old_randomdist;
2587 facetT *neighbor, **neighborp;
2593 qh_fprintf(
qh, fp, 9179,
" - ridges(ids may be garbage):");
2601 if (
qh->hull_dim == 3) {
2603 while (ridge && !ridge->
seen) {
2644 int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
2648 realT outerplane, innerplane;
2650 qh->old_randomdist=
qh->RANDOMdist;
2653 qh_fprintf(
qh,
qh->ferr, 7056,
"qhull warning: CDD format is not available for centrums, halfspace\nintersections, and OFF file format.\n");
2666 else if (
qh->hull_dim == 2)
2675 qh_fprintf(
qh, fp, 9188,
"%s | %s\n",
qh->rbox_command,
qh->qhull_command);
2682 qh_countfacets(
qh, facetlist, facets, printall, &numfacets, &numsimplicial,
2683 &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
2685 qh_fprintf(
qh, fp, 9193,
"10 %d %d %d %d %d %d %d %d %d %d\n2 ",
qh->hull_dim,
2687 qh->num_vertices,
qh->num_facets -
qh->num_visible,
2702 }
else if (
qh->VORONOI
2713 qh->RANDOMdist=
qh->old_randomdist;
2725 realT costheta, denominator, dist1, dist2, s,
t, mindenom, p[4];
2728 boolT nearzero1, nearzero2;
2731 denominator= 1 - costheta * costheta;
2733 if (
qh->hull_dim == 3)
2735 else if (
qh->hull_dim == 4 &&
qh->DROPdim >= 0)
2740 mindenom= 1 / (10.0 *
qh->MAXabs_coord);
2745 s=
qh_divzero(-dist1 + costheta * dist2, denominator,mindenom,&nearzero1);
2746 t=
qh_divzero(-dist2 + costheta * dist1, denominator,mindenom,&nearzero2);
2747 if (nearzero1 || nearzero2)
2749 for (k=
qh->hull_dim; k--; )
2751 if (
qh->PRINTdim <= 3) {
2753 qh_fprintf(
qh, fp, 9198,
"%8.4g %8.4g %8.4g # ", p[0], p[1], p[2]);
2755 qh_fprintf(
qh, fp, 9199,
"%8.4g %8.4g %8.4g %8.4g # ", p[0], p[1], p[2], p[3]);
2756 if (nearzero1+nearzero2)
2761 if (
qh->hull_dim == 3)
2762 qh_fprintf(
qh, fp, 9202,
"%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
2763 else if (
qh->hull_dim == 4 &&
qh->DROPdim >= 0)
2764 qh_fprintf(
qh, fp, 9203,
"3 0 1 2 %8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
2784 if ((fabs(pA[0] - pB[0]) > 1e-3) ||
2785 (fabs(pA[1] - pB[1]) > 1e-3) ||
2786 (fabs(pA[2] - pB[2]) > 1e-3)) {
2788 for (k=0; k < 3; k++)
2793 for (k=0; k < 3; k++)
2796 qh_fprintf(
qh, fp, 9210,
"%8.4g %8.4g %8.4g 1\n", color[0], color[1], color[2]);
2810 facetT *neighbor, **neighborp, *facet;
2816 if (facetA == facetB)
2820 for (facet= facetA; facet; facet= ((facet == facetA) ? facetB : NULL)) {
2869 for (k=
dim; k--; ) {
2890 for (k=0; k < 3; k++)
2914 int numpoints=0, point_i, point_n;
2915 setT *vertices, *points;
2929 if (
qh->KEEPinside ||
qh->KEEPcoplanar ||
qh->KEEPnearinside) {
2955 qh_fprintf(
qh, fp, 9218,
"%s | %s\nbegin\n%d %d real\n",
qh->rbox_command,
2956 qh->qhull_command, numpoints,
qh->hull_dim + 1);
2979 realT diff[4], pointA[4];
2982 for (k=
qh->hull_dim; k--; ) {
2984 diff[k]= point[k]-center[k];
2992 for (k=
qh->hull_dim; k--; )
2993 pointA[k]= point[k]+diff[k] * radius;
3004 realT red[3]={1, 0, 0}, yellow[3]={1, 1, 0};
3047 qh_fprintf(
qh, fp, 9227,
"{appearance {-edge -normal normscale 0} {\n\
3048 INST geom {define vsphere OFF\n\
3057 0.707107 0 0.707107\n\
3058 0 -0.707107 0.707107\n\
3059 0.707107 -0.707107 0\n\
3060 -0.707107 0 0.707107\n\
3061 -0.707107 -0.707107 0\n\
3062 0 0.707107 0.707107\n\
3063 -0.707107 0.707107 0\n\
3064 0.707107 0.707107 0\n\
3065 0.707107 0 -0.707107\n\
3066 0 0.707107 -0.707107\n\
3067 -0.707107 0 -0.707107\n\
3068 0 -0.707107 -0.707107\n\
3101 3 17 10 16\n} transforms { TLIST\n");
3103 qh_fprintf(
qh, fp, 9228,
"%8.4g 0 0 0 # v%d\n 0 %8.4g 0 0\n0 0 %8.4g 0\n",
3104 radius, vertex->
id, radius, radius);
3141 int totcount, numcenters;
3156 qh_fprintf(
qh,
qh->ferr, 6219,
"Qhull internal error (qh_printvdiagram): unknown print format %d.\n", format);
3159 vertices=
qh_markvoronoi(
qh, facetlist, facets, printall, &isLower, &numcenters);
3202 int vertex_i, vertex_n;
3227 facetT *neighbor, **neighborp;
3235 point= vertex->
point;
3237 for (k=
qh->hull_dim; k--; ) {
3250 if (++count % 100 == 0)
3313 int numfacets, numsimplicial, numridges, totneighbors, numneighbors, numcoplanars, numtricoplanars;
3314 setT *vertices, *vertex_points, *coplanar_points;
3317 int vertex_i, vertex_n;
3318 facetT *facet, **facetp, *neighbor, **neighborp;
3321 qh_countfacets(
qh, facetlist, facets, printall, &numfacets, &numsimplicial,
3322 &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
3344 if (
qh->hull_dim == 3)
3346 else if (
qh->hull_dim >= 4)
3388 int k, numcenters, numvertices= 0, numneighbors, numinf, vid=1, vertex_i, vertex_n;
3389 facetT *facet, **facetp, *neighbor, **neighborp;
3393 unsigned int numfacets= (
unsigned int)
qh->num_facets;
3395 vertices=
qh_markvoronoi(
qh, facetlist, facets, printall, &isLower, &numcenters);
3399 numneighbors = numinf = 0;
3403 else if (neighbor->
visitid < numfacets)
3406 if (numinf && !numneighbors) {
3407 SETelem_(vertices, vertex_i)= NULL;
3413 qh_fprintf(
qh, fp, 9254,
"{appearance {+edge -face} OFF %d %d 1 # Voronoi centers and cells\n",
3414 numcenters, numvertices);
3418 for (k=
qh->hull_dim-1; k--; )
3422 for (k=
qh->hull_dim-1; k--; )
3444 if (
qh->hull_dim == 3)
3446 else if (
qh->hull_dim >= 4)
3453 else if (neighbor->
visitid < numfacets)
3466 qh_fprintf(
qh, fp, 9265,
" # p%d is coplanar or isolated\n", vertex_i);
3478 }
else if (neighbor->
visitid < numfacets)
3516 for (k=0; k<
qh->hull_dim-1; k++)
3561 for (k=0, i=0; k <
qh->hull_dim; k++) {
3562 if (
qh->hull_dim == 4) {
3563 if (k !=
qh->DROPdim)
3564 destination[i++]= source[k];
3565 }
else if (k ==
qh->DROPdim)
3566 destination[i++]= 0;
3568 destination[i++]= source[k];
3571 destination[i++]= 0.0;
3593 int linecount= 0, tokcount= 0;
3598 if (!
qh->HALFspace) {
3599 qh_fprintf(
qh,
qh->ferr, 6070,
"qhull input error: feasible point(dim 1 coords) is only valid for halfspace intersection\n");
3602 if (
qh->feasible_string)
3603 qh_fprintf(
qh,
qh->ferr, 7057,
"qhull input warning: feasible point(dim 1 coords) overrides 'Hn,n,n' feasible point for halfspace intersection\n");
3605 qh_fprintf(
qh,
qh->ferr, 6071,
"qhull error: insufficient memory for feasible point\n");
3608 coords=
qh->feasible_point;
3609 while ((s= (isfirst ? curline : fgets(firstline,
qh_MAXfirst,
qh->fin)))) {
3622 if (++tokcount ==
dim) {
3627 qh_fprintf(
qh,
qh->ferr, 6072,
"qhull input error: coordinates for feasible point do not finish out the line: %s\n",
3635 qh_fprintf(
qh,
qh->ferr, 6073,
"qhull input error: only %d coordinates. Could not read %d-d feasible point.\n",
3674 coordT *points, *coords, *infinity= NULL;
3676 realT *coordp= NULL, *offsetp= NULL, *normalp= NULL;
3678 int diminput=0, numinput=0, dimfeasible= 0, newnum, k, tempi;
3679 int firsttext=0, firstshort=0, firstlong=0, firstpoint=0;
3680 int tokcount= 0, linecount=0, maxcount, coordcount=0;
3682 boolT isdelaunay=
qh->DELAUNAY && !
qh->PROJECTinput;
3687 if (
qh->HALFspace && linecount == 1 && isdigit(*s)) {
3695 }
else if (!memcmp(firstline,
"begin", (
size_t)5) || !memcmp(firstline,
"BEGIN", (
size_t)5))
3697 else if (!*
qh->rbox_command)
3698 strncat(
qh->rbox_command, s,
sizeof(
qh->rbox_command)-1);
3701 qh_fprintf(
qh,
qh->ferr, 6074,
"qhull input error: missing \"begin\" for cdd-formated input\n");
3705 while (!numinput && (s= fgets(firstline,
qh_MAXfirst,
qh->fin))) {
3707 if (!memcmp(s,
"begin", (
size_t)5) || !memcmp(s,
"BEGIN", (
size_t)5))
3715 if (!*
qh->rbox_command) {
3716 strncat(
qh->rbox_command, s,
sizeof(
qh->rbox_command)-1);
3717 firsttext= linecount;
3725 if (numinput == 1 && diminput >= 2 &&
qh->HALFspace && !
qh->CDDinput) {
3727 dimfeasible= diminput;
3728 diminput= numinput= 0;
3735 qh_fprintf(
qh,
qh->ferr, 6075,
"qhull input error: short input file. Did not find dimension and number of points\n");
3738 if (diminput > numinput) {
3744 qh_fprintf(
qh,
qh->ferr, 6220,
"qhull input error: dimension %d(first number) should be at least 2\n",
3751 *dimension= diminput;
3753 *dimension= diminput+1;
3754 *numpoints= numinput;
3757 }
else if (
qh->HALFspace) {
3758 *dimension= diminput - 1;
3759 *numpoints= numinput;
3761 qh_fprintf(
qh,
qh->ferr, 6221,
"qhull input error: dimension %d(first number, includes offset) should be at least 3 for halfspaces\n",
3766 if (dimfeasible != *dimension) {
3767 qh_fprintf(
qh,
qh->ferr, 6222,
"qhull input error: dimension %d of feasible point is not one less than dimension %d for halfspaces\n",
3768 dimfeasible, diminput);
3775 *dimension= diminput-1;
3777 *dimension= diminput;
3778 *numpoints= numinput;
3780 qh->normal_size= *dimension *
sizeof(
coordT);
3781 if (
qh->HALFspace) {
3784 offsetp=
qh->half_space;
3785 normalp= offsetp + 1;
3787 normalp=
qh->half_space;
3788 offsetp= normalp + *dimension;
3795 coords= points=
qh->temp_malloc=
3797 if (!coords || !
qh->line || (
qh->HALFspace && !
qh->half_space)) {
3798 qh_fprintf(
qh,
qh->ferr, 6076,
"qhull error: insufficient memory to read %d points\n",
3802 if (isdelaunay &&
qh->ATinfinity) {
3803 infinity= points + numinput * (*dimension);
3804 for (k= (*dimension) - 1; k--; )
3807 maxcount= numinput * diminput;
3809 while ((s= (isfirst ? s : fgets(
qh->line,
qh->maxline,
qh->fin)))) {
3812 if (*s ==
'e' || *s ==
'E') {
3813 if (!memcmp(s,
"end", (
size_t)3) || !memcmp(s,
"END", (
size_t)3)) {
3817 qh_fprintf(
qh,
qh->ferr, 7058,
"qhull input warning: the input appears to be in cdd format. If so, use 'Fd'\n");
3827 if (!*
qh->rbox_command)
3828 strncat(
qh->rbox_command, s,
sizeof(
qh->rbox_command)-1);
3829 if (*s && !firsttext)
3830 firsttext= linecount;
3831 if (!islong && !firstshort && coordcount)
3832 firstshort= linecount;
3836 firstpoint= linecount;
3838 if (++tokcount > maxcount)
3840 if (
qh->HALFspace) {
3842 *(coordp++)= -
value;
3847 if (
qh->CDDinput && !coordcount) {
3849 qh_fprintf(
qh,
qh->ferr, 6077,
"qhull input error: for cdd format, point at line %d does not start with '1'\n",
3854 }
else if (isdelaunay) {
3856 if (
qh->ATinfinity) {
3858 infinity[coordcount-1] +=
value;
3860 infinity[coordcount] +=
value;
3864 if (++coordcount == diminput) {
3867 *(coords++)= paraboloid;
3870 }
else if (
qh->HALFspace) {
3871 if (!
qh_sethalfspace(
qh, *dimension, coords, &coords, normalp, offsetp,
qh->feasible_point)) {
3872 qh_fprintf(
qh,
qh->ferr, 8048,
"The halfspace was on line %d\n", linecount);
3874 qh_fprintf(
qh,
qh->ferr, 8049,
"The input appears to be in cdd format. If so, you should use option 'Fd'\n");
3877 coordp=
qh->half_space;
3884 firstlong= linecount;
3888 if (!islong && !firstshort && coordcount)
3889 firstshort= linecount;
3890 if (!isfirst && s -
qh->line >=
qh->maxline) {
3891 qh_fprintf(
qh,
qh->ferr, 6078,
"qhull input error: line %d contained more than %d characters\n",
3892 linecount, (
int) (s -
qh->line));
3897 if (tokcount != maxcount) {
3898 newnum=
fmin_(numinput, tokcount/diminput);
3900 qhull warning: instead of %d %d-dimensional points, input contains\n\
3901 %d points and %d extra coordinates. Line %d is the first\npoint",
3902 numinput, diminput, tokcount/diminput, tokcount % diminput, firstpoint);
3904 qh_fprintf(
qh,
qh->ferr, 8051,
", line %d is the first comment", firsttext);
3906 qh_fprintf(
qh,
qh->ferr, 8052,
", line %d is the first short\nline", firstshort);
3908 qh_fprintf(
qh,
qh->ferr, 8053,
", line %d is the first long line", firstlong);
3909 qh_fprintf(
qh,
qh->ferr, 8054,
". Continue with %d points.\n", newnum);
3911 if (isdelaunay &&
qh->ATinfinity) {
3912 for (k= tokcount % diminput; k--; )
3913 infinity[k] -= *(--coords);
3914 *numpoints= newnum+1;
3916 coords -= tokcount % diminput;
3920 if (isdelaunay &&
qh->ATinfinity) {
3921 for (k= (*dimension) -1; k--; )
3922 infinity[k] /= numinput;
3923 if (coords == infinity)
3924 coords += (*dimension) -1;
3926 for (k=0; k < (*dimension) -1; k++)
3927 *(coords++)= infinity[k];
3929 *(coords++)= maxboloid * 1.1;
3931 if (
qh->rbox_command[0]) {
3932 qh->rbox_command[strlen(
qh->rbox_command)-1]=
'\0';
3933 if (!strcmp(
qh->rbox_command,
"./rbox D4"))
3935 This is the qhull test case. If any errors or core dumps occur,\n\
3936 recompile qhull with 'make new'. If errors still occur, there is\n\
3937 an incompatibility. You should try a different compiler. You can also\n\
3938 change the choices in user.h. If you discover the source of the problem,\n\
3939 please send mail to qhull_bug@qhull.org.\n\
3941 Type 'qhull' for a short list of options.\n");
3945 if (
qh->half_space) {
3947 qh->half_space= NULL;
3949 qh->temp_malloc= NULL;
3950 trace1((
qh,
qh->ferr, 1008,
"qh_readpoints: read in %d %d-dimensional points\n",
3951 numinput, diminput));
3972 if (!(s=
qh->feasible_string)) {
3974 qhull input error: halfspace intersection needs a feasible point.\n\
3975 Either prepend the input with 1 point or use 'Hn,n,n'. See manual.\n");
3979 qh_fprintf(
qh,
qh->ferr, 6079,
"qhull error: insufficient memory for 'Hn,n,n'\n");
3982 coords=
qh->feasible_point;
3985 if (++tokcount >
dim) {
3986 qh_fprintf(
qh,
qh->ferr, 7059,
"qhull input warning: more coordinates for 'H%s' than dimension %d\n",
3987 qh->feasible_string,
dim);
3994 while (++tokcount <=
dim)
4008 facetT *neighbor, **neighborp;
4010 if (
qh->PRINTneighbors) {
4012 return !
qh->PRINTgood;
4018 }
else if (
qh->PRINTgood)
4019 return !facet->
good;
4041 while (*s && isspace(*s))
4045 qh_fprintf(
qh,
qh->ferr, 6204,
"qhull input error: filename expected, none found.\n");
4048 if (
c ==
'\'' ||
c ==
'"') {
4049 while (*s !=
c || s[-1] ==
'\\') {
4058 else while (*s && !isspace(*s))