30 for (scan= (
int)hash; (elem=
SETelem_(hashtable, scan));
31 scan= (++scan >= hashsize ? 0 : scan)) {
68 facetT *facet, *bestfacet, *errfacet1= NULL, *errfacet2= NULL;
72 int numpart= 0, facet_i, facet_n, notgood= 0, notverified= 0;
75 trace1((qh, qh->
ferr, 1020,
"qh_check_bestdist: check points below nearest facet. Facet_list f%d\n",
80 trace1((qh, qh->
ferr, 1021,
"qh_check_bestdist: check that all points are within %2.2g of best facet\n", maxoutside));
84 qhull output completed. Verifying that %d points are\n\ 85 below %2.2g of the nearest %sfacet.\n",
102 if (dist > maxoutside) {
104 && !((bestfacet=
qh_findgooddist(qh, point, bestfacet, &dist, &facetlist))
105 && dist > maxoutside))
109 qh_fprintf(qh, qh->
ferr, 6109,
"qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n",
110 facet_i, bestfacet->
id, dist, maxoutside);
111 if (errfacet1 != bestfacet) {
112 errfacet2= errfacet1;
113 errfacet1= bestfacet;
116 }
else if (unassigned && dist < -qh->MAXcoplanar)
121 qh_fprintf(qh, qh->
ferr, 8092,
"\n%d points were well inside the hull. If the hull contains\n\ 122 a lens-shaped component, these points were not verified. Use\n\ 123 options 'Qci Tv' to verify all points.\n", notverified);
125 qh_fprintf(qh, qh->
ferr, 6110,
"qhull precision error (qh_check_bestdist): a coplanar point is %6.2g from convex hull. The maximum value(qh.outside_err) is %6.2g\n",
131 trace0((qh, qh->
ferr, 20,
"qh_check_bestdist: max distance outside %2.2g\n", maxdist));
151 vertexT *vertex, **vertexp, *vertexA, **vertexAp;
152 realT dist, innerplane, mergedist, outerplane, prevdist, ratio;
155 mergedist=
fmin_(dist1, dist2);
157 prevdist=
fmax_(outerplane, innerplane);
160 ratio= mergedist/prevdist;
163 if (vertex > vertexA){
169 trace0((qh, qh->
ferr, 16,
"qh_check_dupridge: duplicate ridge between f%d and f%d due to nearly-coincident vertices (%2.2g), dist %2.2g, reverse dist %2.2g, ratio %2.2g while processing p%d\n",
170 facet1->
id, facet2->
id, minvertex, dist1, dist2, ratio, qh->
furthest_id));
172 qh_fprintf(qh, qh->
ferr, 6271,
"qhull precision error (qh_check_dupridge): wide merge (%.0f times wider) due to duplicate ridge with nearly coincident points (%2.2g) between f%d and f%d, merge dist %2.2g, while processing p%d\n- Ignore error with option 'Q12'\n- To be fixed in a later version of Qhull\n",
175 qh_fprintf(qh, qh->
ferr, 8145,
"- A bounding box for the input sites may alleviate this error.\n");
177 qh_fprintf(qh, qh->
ferr, 8146,
"- Vertex distance %2.2g is greater than %d times maximum distance %2.2g\n Please report to bradb@shore.net with steps to reproduce and all output\n",
219 facetT *facet, *bestfacet, *neighbor, **neighborp, *facetlist;
220 realT dist, maxoutside, minvertex, old_maxoutside;
222 int numpart= 0, facet_i, facet_n, notgood= 0;
223 setT *facets, *vertices;
226 trace1((qh, qh->
ferr, 1022,
"qh_check_maxout: check and update maxoutside for each facet.\n"));
227 maxoutside= minvertex= 0;
232 trace1((qh, qh->
ferr, 1023,
"qh_check_maxout: determine actual maxoutside and minvertex\n"));
241 qh_fprintf(qh, qh->
ferr, 8093,
"qh_check_maxout: p%d(v%d) is %.2g from f%d\n",
263 if (bestfacet && dist > maxoutside) {
265 && !((bestfacet=
qh_findgooddist(qh, point, bestfacet, &dist, &facetlist))
266 && dist > maxoutside))
272 qh_fprintf(qh, qh->
ferr, 8094,
"qh_check_maxout: p%d is %.2g above f%d\n",
273 qh_pointid(qh, point), dist, (bestfacet ? bestfacet->
id : UINT_MAX));
277 (maxoutside > 2*old_maxoutside);
287 trace1((qh, qh->
ferr, 1024,
"qh_check_maxout: maxoutside %2.2g, min_vertex %2.2g, outside of not good %d\n",
330 if (dist > *maxoutside) {
331 if (*errfacet1 != facet) {
332 *errfacet2= *errfacet1;
335 qh_fprintf(qh, qh->
ferr, 6111,
"qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n",
366 facetT *facet, *errfacet1= NULL, *errfacet2= NULL;
368 pointT *point, **pointp, *pointtemp;
374 trace1((qh, qh->
ferr, 1025,
"qh_check_points: check all points below %2.2g of all facet planes\n",
382 qh_fprintf(qh, qh->
ferr, 7075,
"qhull input warning: merging without checking outer planes('Q5' or 'Po').\n\ 383 Verify may report that a point is outside of a facet.\n");
392 qh_fprintf(qh, qh->
ferr, 7076,
"qhull input warning: exact merge ('Qx'). Verify may report that a point\n\ 393 is outside of a facet. See qh-optq.htm#Qx\n");
395 qh_fprintf(qh, qh->
ferr, 7077,
"qhull input warning: no outer plane check ('Q5') or no processing of\n\ 396 near-inside points ('Q8'). Verify may report that a point is outside\n\ 402 Output completed. Verifying that all points are below outer planes of\n\ 403 all %sfacets. Will make %2.0f distance computations.\n",
404 (qh->
ONLYgood ?
"good " :
""), total);
407 Output completed. Verifying that all points are below %2.2g of\n\ 408 all %sfacets. Will make %2.0f distance computations.\n",
409 maxoutside, (qh->
ONLYgood ?
"good " :
""), total);
417 qh_fprintf(qh, qh->
ferr, 7061,
"qhull warning (qh_check_points): missing normal for facet f%d\n", facet->
id);
428 qh_check_point(qh, point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
432 qh_check_point(qh, point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2);
436 qh_fprintf(qh, qh->
ferr, 6112,
"qhull precision error (qh_check_points): a coplanar point is %6.2g from convex hull. The maximum value(qh.outside_err) is %6.2g\n",
442 trace0((qh, qh->
ferr, 21,
"qh_check_points: max distance outside %2.2g\n", maxdist));
476 facetT *facet, *neighbor, **neighborp, *errfacet1=NULL, *errfacet2=NULL;
483 trace1((qh, qh->
ferr, 1026,
"qh_checkconvex: check all ridges are convex\n"));
491 qh_fprintf(qh, qh->
ferr, 6113,
"qhull precision error: f%d is flipped(interior point is outside)\n",
498 allsimplicial=
False;
505 allsimplicial=
False;
512 qh_fprintf(qh, qh->
ferr, 6114,
"qhull precision error: initial simplex is not convex. Distance=%.2g\n", dist);
518 qh_fprintf(qh, qh->
ferr, 6115,
"qhull precision error: f%d is concave to f%d, since p%d(v%d) is %6.4g above\n",
527 qh_fprintf(qh, qh->
ferr, 6116,
"qhull precision error: f%d is clearly not convex to f%d, since p%d(v%d) is %6.4g above\n",
536 trace0((qh, qh->
ferr, 22,
"qhull precision error: f%d may be coplanar to f%d, since p%d(v%d) is within %6.4g during p%d\n",
542 if (!allsimplicial) {
549 centrum_warning=
True;
550 qh_fprintf(qh, qh->
ferr, 7062,
"qhull warning: recomputing centrums for convexity test. This may lead to false, precision errors.\n");
565 qh_fprintf(qh, qh->
ferr, 6117,
"qhull precision error: f%d is concave to f%d. Centrum of f%d is %6.4g above f%d\n",
566 facet->
id, neighbor->
id, facet->
id, dist, neighbor->
id);
570 }
else if (dist >= 0.0) {
574 qh_fprintf(qh, qh->
ferr, 6118,
"qhull precision error: f%d is coplanar or concave to f%d. Centrum of f%d is %6.4g above f%d\n",
575 facet->
id, neighbor->
id, facet->
id, dist, neighbor->
id);
628 facetT *neighbor, **neighborp, *errother=NULL;
629 ridgeT *ridge, **ridgep, *errridge= NULL, *ridge2;
631 unsigned previousid= INT_MAX;
632 int numneighbors, numvertices, numridges=0, numRvertices=0;
634 int skipA, skipB, ridge_i, ridge_n, i;
638 qh_fprintf(qh, qh->
ferr, 6119,
"qhull internal error (qh_checkfacet): facet f%d is on the visible_list\n",
643 qh_fprintf(qh, qh->
ferr, 6120,
"qhull internal error (qh_checkfacet): facet f%d does not have a normal\n",
654 qh_fprintf(qh, qh->
ferr, 6121,
"qhull internal error (qh_checkfacet): deleted vertex v%d in f%d\n", vertex->
id, facet->
id);
655 qh_errprint(qh,
"ERRONEOUS", NULL, NULL, NULL, vertex);
658 if (vertex->
id >= previousid) {
659 qh_fprintf(qh, qh->
ferr, 6122,
"qhull internal error (qh_checkfacet): vertices of f%d are not in descending id order at v%d\n", facet->
id, vertex->
id);
663 previousid= vertex->
id;
669 if (numvertices+numneighbors != 2*qh->
hull_dim 671 qh_fprintf(qh, qh->
ferr, 6123,
"qhull internal error (qh_checkfacet): for simplicial facet f%d, #vertices %d + #neighbors %d != 2*qh->hull_dim\n",
672 facet->
id, numvertices, numneighbors);
678 &&(numvertices < qh->hull_dim || numneighbors < qh->hull_dim)
680 qh_fprintf(qh, qh->
ferr, 6124,
"qhull internal error (qh_checkfacet): for facet f%d, #vertices %d or #neighbors %d < qh->hull_dim\n",
681 facet->
id, numvertices, numneighbors);
685 if (numridges < numneighbors
687 ||(qh->
hull_dim == 2 && numridges + numvertices + numneighbors != 6)) {
689 qh_fprintf(qh, qh->
ferr, 6125,
"qhull internal error (qh_checkfacet): for facet f%d, #ridges %d < #neighbors %d or(3-d) > #vertices %d or(2-d) not all 2\n",
690 facet->
id, numridges, numneighbors, numvertices);
697 qh_fprintf(qh, qh->
ferr, 6126,
"qhull internal error (qh_checkfacet): facet f%d still has a MERGE or DUP neighbor\n", facet->
id);
704 qh_fprintf(qh, qh->
ferr, 6127,
"qhull internal error (qh_checkfacet): facet f%d has neighbor f%d, but f%d does not have neighbor f%d\n",
705 facet->
id, neighbor->
id, neighbor->
id, facet->
id);
709 if (!neighbor->
seen) {
710 qh_fprintf(qh, qh->
ferr, 6128,
"qhull internal error (qh_checkfacet): facet f%d has a duplicate neighbor f%d\n",
711 facet->
id, neighbor->
id);
723 qh_fprintf(qh, qh->
ferr, 6129,
"qhull internal error (qh_checkfacet): facet f%d has a duplicate ridge r%d\n",
724 facet->
id, ridge->
id);
730 if (numRvertices != qh->
hull_dim - 1) {
731 qh_fprintf(qh, qh->
ferr, 6130,
"qhull internal error (qh_checkfacet): ridge between f%d and f%d has %d vertices\n",
739 qh_fprintf(qh, qh->
ferr, 6131,
"qhull internal error (qh_checkfacet): for facet f%d, neighbor f%d of ridge r%d not in facet\n",
740 facet->
id, neighbor->
id, ridge->
id);
747 if (!neighbor->
seen) {
748 qh_fprintf(qh, qh->
ferr, 6132,
"qhull internal error (qh_checkfacet): facet f%d does not have a ridge for neighbor f%d\n",
749 facet->
id, neighbor->
id);
766 qh_fprintf(qh, qh->
ferr, 6133,
"qhull internal error (qh_checkfacet): vertex v%d in r%d not in f%d intersect f%d\n",
767 vertex->
id, ridge->
id, facet->
id, neighbor->
id);
775 if (!vertex->
seen2) {
777 qh_fprintf(qh, qh->
ferr, 6134,
"qhull precision error (qh_checkfacet): vertex v%d in f%d intersect f%d but\n\ 778 not in a ridge. This is ok under merging. Last point was p%d\n",
781 qh_errprint(qh,
"ERRONEOUS", facet, neighbor, NULL, vertex);
797 qh_fprintf(qh, qh->
ferr, 6135,
"qhull internal error (qh_checkfacet): facet f%d skip %d and neighbor f%d skip %d do not match \n",
798 facet->
id, skipA, neighbor->
id, skipB);
807 for (i=ridge_i+1; i < ridge_n; i++) {
810 qh_fprintf(qh, qh->
ferr, 6227,
"Qhull internal error (qh_checkfacet): ridges r%d and r%d have the same vertices\n",
811 ridge->
id, ridge2->id);
819 qh_errprint(qh,
"ERRONEOUS", facet, errother, errridge, NULL);
840 qh_fprintf(qh, qh->
ferr, 6136,
"qhull precision error: facet f%d is flipped, distance= %6.12g\n",
843 qh_errprint(qh,
"ERRONEOUS", facet, NULL, NULL, NULL);
850 A flipped facet occurs when its distance to the interior point is\n\ 851 greater than %2.2g, the maximum roundoff error.\n", -qh->
DISTround);
880 vertexT *vertex, **vertexp, *vertexlist;
881 int numfacets= 0, numvertices= 0, numridges= 0;
882 int totvneighbors= 0, totvertices= 0;
885 trace1((qh, qh->
ferr, 1027,
"qh_checkpolygon: check all facets from f%d\n", facetlist->
id));
901 qh_fprintf(qh, qh->
ferr, 6137,
"qhull internal error (qh_checkpolygon): f%d has outside points before qh->facet_next\n",
912 qh_fprintf(qh, qh->
ferr, 6138,
"qhull internal error (qh_checkpolygon): visible list f%d no longer on facet list\n", qh->
visible_list->
id);
939 qh_fprintf(qh, qh->
ferr, 6139,
"qhull internal error (qh_checkpolygon): unknown point %p for vertex v%d first_point %p\n",
949 qh_fprintf(qh, qh->
ferr, 6140,
"qhull internal error (qh_checkpolygon): actual number of facets is %d, cumulative facet count is %d - %d visible facets\n",
963 if (totvneighbors != totvertices) {
964 qh_fprintf(qh, qh->
ferr, 6141,
"qhull internal error (qh_checkpolygon): vertex neighbors inconsistent. Totvneighbors %d, totvertices %d\n",
965 totvneighbors, totvertices);
970 qh_fprintf(qh, qh->
ferr, 6142,
"qhull internal error (qh_checkpolygon): actual number of vertices is %d, cumulative vertex count is %d\n",
974 if (qh->
hull_dim == 2 && numvertices != numfacets) {
975 qh_fprintf(qh, qh->
ferr, 6143,
"qhull internal error (qh_checkpolygon): #vertices %d != #facets %d\n",
976 numvertices, numfacets);
979 if (qh->
hull_dim == 3 && numvertices + numfacets - numridges/2 != 2) {
980 qh_fprintf(qh, qh->
ferr, 7063,
"qhull warning: #vertices %d + #facets %d - #edges %d != 2\n\ 981 A vertex appears twice in a edge list. May occur during merging.",
982 numvertices, numfacets, numridges/2);
1003 facetT *neighbor, **neighborp, *errfacet=NULL;
1006 qh_fprintf(qh, qh->
ferr, 6144,
"qhull internal error (qh_checkvertex): unknown point id %p\n", vertex->
point);
1010 qh_fprintf(qh, qh->
ferr, 6145,
"qhull internal error (qh_checkvertex): unknown vertex id %d\n", vertex->
id);
1013 if (!waserror && !vertex->
deleted) {
1017 qh_fprintf(qh, qh->
ferr, 6146,
"qhull internal error (qh_checkvertex): neighbor f%d does not contain v%d\n", neighbor->
id, vertex->
id);
1025 qh_errprint(qh,
"ERRONEOUS", NULL, NULL, NULL, vertex);
1061 trace2((qh, qh->
ferr, 2043,
"qh_clearcenters: switched to center type %d\n", type));
1083 facetT *facet= NULL, *newfacet;
1085 int vertex_i, vertex_n, nth;
1096 newfacet->toporient= (
unsigned char)toporient;
1098 newfacet->newfacet=
True;
1106 if (facet != newfacet)
1107 SETelem_(newfacet->neighbors, nth++)= facet;
1112 trace1((qh, qh->
ferr, 1028,
"qh_createsimplex: created simplex\n"));
1170 ridgeT *ridge, *firstridge;
1172 int cntvertices, cntprojected=0;
1178 if (cntvertices != 3) {
1179 qh_fprintf(qh, qh->
ferr, 6147,
"qhull internal error (qh_facet3vertex): only %d vertices for simplicial facet f%d\n",
1180 cntvertices, facet->
id);
1193 if (++cntprojected > cntvertices || ridge == firstridge)
1196 if (!ridge || cntprojected != cntvertices) {
1197 qh_fprintf(qh, qh->
ferr, 6148,
"qhull internal error (qh_facet3vertex): ridges for facet %d don't match up. got at least %d\n",
1198 facet->
id, cntprojected);
1242 int numpart, totpart= 0;
1246 bestdist, isoutside, &totpart);
1247 if (*bestdist < -qh->DISTround) {
1250 if ((isoutside && *isoutside && bestoutside)
1251 || (isoutside && !*isoutside && bestfacet->
upperdelaunay)) {
1253 bestoutside,
False, bestoutside,
1254 bestdist, isoutside, &totpart);
1258 trace3((qh, qh->
ferr, 3014,
"qh_findbestfacet: f%d dist %2.2g isoutside %d totpart %d\n",
1259 bestfacet->
id, *bestdist, (isoutside ? *isoutside : UINT_MAX), totpart));
1279 facetT *neighbor, **neighborp, *bestfacet= NULL;
1291 if (dist > bestdist) {
1292 bestfacet= neighbor;
1306 if (dist > bestdist) {
1307 bestfacet= neighbor;
1316 trace3((qh, qh->
ferr, 3025,
"qh_findbestlower: all neighbors of facet %d are flipped or upper Delaunay. Search all facets\n",
1321 *bestdistp= bestdist;
1322 trace3((qh, qh->
ferr, 3015,
"qh_findbestlower: f%d dist %2.2g for f%d p%d\n",
1323 bestfacet->
id, bestdist, upperfacet->
id,
qh_pointid(qh, point)));
1350 facetT *bestfacet= NULL, *facet;
1357 if (facet->flipped || !facet->normal)
1361 if (dist > *bestdist) {
1371 trace3((qh, qh->
ferr, 3016,
"qh_findfacet_all: f%d dist %2.2g isoutside %d totpart %d\n",
1372 getid_(bestfacet), *bestdist, *isoutside, totpart));
1409 facetT *facet, *bestfacet= NULL;
1430 if ((qh->
GOODpoint > 0) ^ (dist > 0.0)) {
1443 if (angle < bestangle) {
1450 if (!numgood && (!goodhorizon || qh->
GOODclosest)) {
1456 if (angle < bestangle)
1466 trace2((qh, qh->
ferr, 2044,
"qh_findgood: f%d is closest(%2.2g) to thresholds\n",
1467 bestfacet->
id, bestangle));
1476 trace2((qh, qh->
ferr, 2045,
"qh_findgood: found %d good facets with %d good horizon\n",
1477 numgood, goodhorizon));
1509 facetT *facet, *bestfacet=NULL;
1511 int numgood=0, startgood;
1527 qh_fprintf(qh, qh->
ferr, 7064,
"qhull warning: good vertex p%d does not match last good facet f%d. Ignored.\n",
1531 qh_fprintf(qh, qh->
ferr, 7065,
"qhull warning: point p%d is not a vertex('QV%d').\n",
1534 qh_fprintf(qh, qh->
ferr, 7066,
"qhull warning: point p%d is a vertex for every facet('QV-%d').\n",
1548 if (angle < bestangle) {
1555 if (!numgood && bestfacet) {
1558 trace0((qh, qh->
ferr, 23,
"qh_findgood_all: f%d is closest(%2.2g) to thresholds\n",
1559 bestfacet->
id, bestangle));
1564 trace0((qh, qh->
ferr, 24,
"qh_findgood_all: %d good facets remain out of %d facets\n",
1565 numgood, startgood));
1579 facetT *facet, *bestfacet= NULL;
1584 #if qh_COMPUTEfurthest 1592 if (dist > bestdist) {
1601 trace1((qh, qh->
ferr, 1029,
"qh_furthestnext: made f%d next facet(dist %.2g)\n",
1602 bestfacet->
id, bestdist));
1622 pointT *point, **pointp, *bestpoint= NULL;
1628 if (dist > bestdist) {
1636 #if !qh_COMPUTEfurthest 1641 trace3((qh, qh->
ferr, 3017,
"qh_furthestout: p%d is furthest outside point of f%d\n",
1654 qh_fprintf(qh, qh->
ferr, 6149,
"qhull internal error (qh_infiniteloop): potential infinite loop detected\n");
1684 setT *maxpoints, *vertices;
1710 qh_fprintf(qh, qh->
ferr, 6150,
"qhull input error: either QGn or QVn point is > p%d\n",
1756 qh_fprintf(qh, qh->
ferr, 6151,
"qhull input error: 'Qg QVn' (only good vertex) does not work with merging.\nUse 'QJ' to joggle the input or 'Q0' to turn off merging.\n");
1761 qh_fprintf(qh, qh->
ferr, 6152,
"qhull input error: 'Qg' (ONLYgood) needs a good threshold('Pd0D0'), a\n\ 1762 good point(QGn or QG-n), or a good vertex with 'QJ' or 'Q0' (QVn).\n");
1768 &dist, !
qh_ALL, &isoutside, &numpart);
1771 qh_fprintf(qh, qh->
ferr, 6153,
"qhull input error: point for QV%d is inside initial simplex. It can not be made a vertex.\n",
1785 trace1((qh, qh->
ferr, 1030,
"qh_initbuild: initial hull created and points partitioned\n"));
1803 facetT *facet, *firstfacet, *neighbor, **neighborp;
1825 trace1((qh, qh->
ferr, 1031,
"qh_initialhull: initial orientation incorrect. Correct all facets\n"));
1838 qh_fprintf(qh, qh->
ferr, 6240,
"Qhull precision error: Initial simplex is cocircular or cospherical. Option 'Qs' searches all points. Can not compute the upper Delaunay triangulation or upper Voronoi diagram of cocircular/cospherical points.\n");
1840 qh_fprintf(qh, qh->
ferr, 6239,
"Qhull precision error: Initial simplex is cocircular or cospherical. Use option 'Qz' for the Delaunay triangulation or Voronoi diagram of cocircular/cospherical points. Option 'Qz' adds a point \"at infinity\". Use option 'Qs' to search all points for the initial simplex.\n");
1844 qh_fprintf(qh, qh->
ferr, 6154,
"Qhull precision error: Initial simplex is flat (facet %d is coplanar with the interior point)\n",
1853 if (minangle < qh_MAXnarrow && !qh->NOnarrow) {
1854 realT diff= 1.0 + minangle;
1857 qh_option(qh,
"_narrow-hull", NULL, &diff);
1858 if (minangle < qh_WARNnarrow && !qh->RERUN && qh->
PRINTprecision)
1866 qh_fprintf(qh, qh->
ferr, 8105,
"qh_initialhull: simplex constructed, interior point:");
1894 setT *vertices, *simplex, *tested;
1896 int idx, point_i, point_n, k;
1921 if (point_i & 0x1) {
1946 while (k != dim && (point=
qh_point(qh, idx++))) {
1956 qh_maxsimplex(qh, dim, maxpoints, points, numpoints, &simplex);
1958 qh_maxsimplex(qh, dim, maxpoints, points, numpoints, &simplex);
1979 if (vertex->
point == point)
2021 facetT *visible, *newfacet= NULL, *newfacet2= NULL, *neighbor, **neighborp;
2034 neighbor->seen=
False;
2043 newfacet= newfacet2;
2051 trace1((qh, qh->
ferr, 1032,
"qh_makenewfacets: created %d new facets from point p%d to horizon\n",
2089 boolT same, ismatch;
2091 facetT *facet, *newfacet, *maxmatch= NULL, *maxmatch2= NULL, *nextfacet;
2092 int skip, newskip, nextskip= 0, maxskip= 0, maxskip2= 0, makematch;
2097 trace2((qh, qh->
ferr, 2046,
"qh_matchduplicates: find duplicate matches for f%d skip %d hash %d hashcount %d\n",
2098 atfacet->
id, atskip, hash, *hashcount));
2099 for (makematch= 0; makematch < 2; makematch++) {
2101 for (newfacet= atfacet, newskip= atskip; newfacet; newfacet= nextfacet, newskip= nextskip) {
2106 scan= (++scan >= hashsize ? 0 : scan)) {
2114 qh_fprintf(qh, qh->
ferr, 6155,
"qhull internal error (qh_matchduplicates): missing dupridge at f%d skip %d for new f%d skip %d hash %d\n",
2115 facet->
id, skip, newfacet->
id, newskip, hash);
2118 }
else if (ismatch && makematch) {
2126 trace4((qh, qh->
ferr, 4059,
"qh_matchduplicates: duplicate f%d skip %d matched with new f%d skip %d merge\n",
2127 facet->
id, skip, newfacet->
id, newskip));
2129 }
else if (ismatch) {
2133 if (mindist > maxdist) {
2137 maxmatch2= newfacet;
2140 trace3((qh, qh->
ferr, 3018,
"qh_matchduplicates: duplicate f%d skip %d new f%d skip %d at dist %2.2g, max is now f%d f%d\n",
2141 facet->
id, skip, newfacet->
id, newskip, mindist,
2142 maxmatch->
id, maxmatch2->id));
2148 if (makematch && !facet
2150 qh_fprintf(qh, qh->
ferr, 6156,
"qhull internal error (qh_matchduplicates): no MERGEridge match for duplicate f%d skip %d at hash %d\n",
2151 newfacet->
id, newskip, hash);
2158 qh_fprintf(qh, qh->
ferr, 6157,
"qhull internal error (qh_matchduplicates): no maximum match at duplicate f%d skip %d at hash %d\n",
2159 atfacet->
id, atskip, hash);
2163 SETelem_(maxmatch2->neighbors, maxskip2)= maxmatch;
2166 trace0((qh, qh->
ferr, 25,
"qh_matchduplicates: duplicate f%d skip %d matched with new f%d skip %d keep\n",
2167 maxmatch->
id, maxskip, maxmatch2->id, maxskip2));
2170 qh_errprint(qh,
"DUPLICATED/MATCH", maxmatch, maxmatch2, NULL, NULL);
2202 realT dist, innerplane;
2219 if (dist < innerplane) {
2250 vertexT *bestvertex= NULL, *vertex, **vertexp, *apex;
2252 facetT *neighbor, **neighborp;
2260 qh_fprintf(qh, qh->
ferr, 6158,
"qhull internal error (qh_nearvertex): qh.VERTEXneighbors and facet->center required for tricoplanar facets\n");
2267 if (neighbor->
center == center) {
2276 if (dist < bestdist) {
2283 *bestdistp= sqrt(bestdist);
2285 qh_fprintf(qh, qh->
ferr, 6261,
"qhull internal error (qh_nearvertex): did not find bestvertex for f%d p%d\n", facet->
id,
qh_pointid(qh, point));
2288 trace3((qh, qh->
ferr, 3019,
"qh_nearvertex: v%d dist %2.2g for f%d p%d\n",
2309 if (newsize<0 || size<0) {
2310 qh_fprintf(qh, qh->
qhmem.
ferr, 6236,
"qhull error (qh_newhashtable): negative request (%d) or size (%d). Did int overflow due to high-D?\n", newsize, size);
2313 if ((size%3) && (size%5))
2334 memset((
char *) vertex, (
size_t)0,
sizeof(
vertexT));
2337 qh_fprintf(qh, qh->
ferr, 6159,
"qhull error: more than 2^32 vertices. vertexT.id field overflows. Vertices would not be sorted correctly.\n");
2343 vertex->point= point;
2344 trace4((qh, qh->
ferr, 4060,
"qh_newvertex: vertex p%d(v%d) created\n",
qh_pointid(qh, vertex->point),
2369 vertexT *atvertex, *vertex, *othervertex;
2377 if (ridge == atridge)
2379 if ((ridge->
top == facet) ^ qh_ORIENTclock) {
2386 if (vertex == atvertex) {
2388 *vertexp= othervertex;
2422 trace1((qh, qh->
ferr, 1033,
"qh_outcoplanar: move outsideset to coplanarset for qh->NARROWhull\n"));
2450 if (id < qh->num_points)
2475 qh_fprintf(qh, qh->
ferr, 7067,
"qhull internal warning (point_add): unknown point %p id %d\n",
2477 else if (
id >= size) {
2478 qh_fprintf(qh, qh->
ferr, 6160,
"qhull internal errror(point_add): point p%d is out of bounds(%d)\n",
2575 facetT *prevfacet, *list;
2578 trace4((qh, qh->
ferr, 4061,
"qh_prependfacet: prepend f%d before f%d\n",
2586 prevfacet->
next= facet;
2588 facet->
next= *facetlist;
2614 facetT *facet, *neighbor;
2615 int id, facet_i, facet_n, neighbor_i= 0, neighbor_n= 0;
2624 if (neighbor_i == neighbor_n)
2626 qh_fprintf(qh, fp, 9283,
"hash %d f%d ", facet_i, facet->
id);
2658 if (++count % 100 == 0)
2662 qh_fprintf(qh, qh->
ferr, 8111,
"\n new facets %d visible facets %d next facet for qh_addpoint %d\n vertices(new %d):",
2667 if (++count % 100 == 0)
2687 facetT *newfacet, *visible;
2688 int totnew=0, totver=0;
2768 facetT *facet, *nextfacet, *owner;
2770 facetT *neighbor, *visible= NULL, *facet1, *facet2, *new_facet_list= NULL;
2771 facetT *orig_neighbor= NULL, *otherfacet;
2772 vertexT *new_vertex_list= NULL;
2775 int neighbor_i, neighbor_n;
2779 trace1((qh, qh->
ferr, 1034,
"qh_triangulate: triangulate non-simplicial facets\n"));
2791 for (facet= qh->
facet_list; facet && facet->
next; facet= nextfacet) {
2792 nextfacet= facet->
next;
2796 if (!new_facet_list)
2797 new_facet_list= facet;
2800 trace2((qh, qh->
ferr, 2047,
"qh_triangulate: delete null facets from f%d -- apex same as second vertex\n",
getid_(new_facet_list)));
2801 for (facet= new_facet_list; facet && facet->
next; facet= nextfacet) {
2802 nextfacet= facet->
next;
2807 qh_fprintf(qh, qh->
ferr, 6161,
"qhull error (qh_triangulate): ridges still defined for f%d\n", facet->
id);
2822 mergetype= merge->
type;
2830 trace2((qh, qh->
ferr, 2049,
"qh_triangulate: update neighbor lists for vertices from v%d\n",
getid_(new_vertex_list)));
2836 trace2((qh, qh->
ferr, 2050,
"qh_triangulate: identify degenerate tricoplanar facets from f%d\n",
getid_(new_facet_list)));
2837 trace2((qh, qh->
ferr, 2051,
"qh_triangulate: and replace facet->f.triowner with tricoplanar facets that own center, normal, etc.\n"));
2841 if (neighbor_i == 0) {
2845 orig_neighbor= neighbor;
2850 otherfacet= neighbor;
2851 if (orig_neighbor == otherfacet) {
2861 trace2((qh, qh->
ferr, 2052,
"qh_triangulate: delete visible facets -- non-simplicial, null, and mirrored facets\n"));
2864 for (facet= new_facet_list; facet && facet->
next; facet= nextfacet) {
2865 nextfacet= facet->
next;
2871 if (visible && !owner) {
2873 trace2((qh, qh->
ferr, 2053,
"qh_triangulate: all tricoplanar facets degenerate for non-simplicial facet f%d\n",
2882 if (facet->
f.
triowner != visible || visible==NULL) {
2883 qh_fprintf(qh, qh->
ferr, 6162,
"qhull error (qh_triangulate): tricoplanar facet f%d not owned by its visible, non-simplicial facet f%d\n", facet->
id,
getid_(visible));
2890 nextfacet= visible->
next;
2905 if (visible && !owner) {
2906 trace2((qh, qh->
ferr, 2054,
"qh_triangulate: all tricoplanar facets degenerate for last non-simplicial facet f%d\n",
2956 facetT *neighbor, **neighborp;
2960 trace3((qh, qh->
ferr, 3020,
"qh_triangulate_facet: triangulate facet f%d\n", facetA->
id));
3012 if (!(*first_vertex))
3030 int errmirror=
False;
3032 trace3((qh, qh->
ferr, 3021,
"qh_triangulate_link: relink old facets f%d and f%d between neighbors f%d and f%d\n",
3033 oldfacetA->
id, oldfacetB->
id, facetA->
id, facetB->
id));
3042 qh_fprintf(qh, qh->
ferr, 6163,
"qhull error (qh_triangulate_link): mirror facets f%d and f%d do not match for old facets f%d and f%d\n",
3043 facetA->
id, facetB->
id, oldfacetA->
id, oldfacetB->
id);
3061 facetT *neighbor, *neighborB;
3062 int neighbor_i, neighbor_n;
3064 trace3((qh, qh->
ferr, 3022,
"qh_triangulate_mirror: delete mirrored facets f%d and f%d\n",
3065 facetA->
id, facetB->
id));
3068 if (neighbor == neighborB)
3090 facetT *neighbor, *otherfacet;
3092 trace3((qh, qh->
ferr, 3023,
"qh_triangulate_null: delete null facet f%d\n", facetA->
id));
3122 *vertexsetA= intersection;
3140 while (*vertexA && *vertexB) {
3141 if (*vertexA == *vertexB) {
3143 vertexA++; vertexB++;
3145 if ((*vertexA)->id > (*vertexB)->id)
3151 return intersection;
3180 trace1((qh, qh->
ferr, 1035,
"qh_vertexneighbors: determing neighboring facets for each vertex\n"));
3215 if ((*vertexA)->id > (*vertexB)->id)
3217 if (*vertexA == *vertexB)
boolT qh_checkflipped(facetT *facet, realT *distp, boolT allerror)
void qh_furthestout(qhT *qh, facetT *facet)
facetT * qh_newfacet(void)
void qh_initbuild(qhT *qh)
void qh_point_add(qhT *qh, setT *set, pointT *point, void *elem)
void qh_triangulate_link(qhT *qh, facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB)
void qh_check_points(qhT *qh)
void qh_settruncate(setT *set, int size)
pointT * qh_getcenter(setT *vertices)
#define otherfacet_(ridge, facet)
#define FOREACHvertex_(vertices)
void qh_removefacet(facetT *facet)
void qh_createsimplex(qhT *qh, setT *vertices)
void qh_partitionall(setT *vertices, pointT *points, int numpoints)
setT * qh_pointvertex(qhT *qh)
void qh_setcompact(setT *set)
void qh_setreplace(setT *set, void *oldelem, void *newelem)
qh_PRINT PRINTout[qh_PRINTEND]
#define SETfirstt_(set, type)
void qh_printhelp_narrowhull(FILE *fp, realT minangle)
void qh_setcheck(setT *set, const char *tname, unsigned id)
#define FORALLvertex_(vertexlist)
facetT * qh_findbestnew(pointT *point, facetT *startfacet, realT *dist, boolT bestoutside, boolT *isoutside, int *numpart)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
void qh_removevertex(vertexT *vertex)
facetT * qh_findbestlower(qhT *qh, facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart)
void qh_precision(const char *reason)
void qh_checkflipped_all(qhT *qh, facetT *facetlist)
void qh_prependfacet(qhT *qh, facetT *facet, facetT **facetlist)
void qh_printfacetlist(facetT *facetlist, setT *facets, boolT printall)
int qh_newhashtable(qhT *qh, int newsize)
#define FORALLfacet_(facetlist)
ridgeT * qh_nextridge3d(ridgeT *atridge, facetT *facet, vertexT **vertexp)
facetT * qh_findbestfacet(qhT *qh, pointT *point, boolT bestoutside, realT *bestdist, boolT *isoutside)
void qh_setvoronoi_all(qhT *qh)
int qh_setindex(setT *set, void *atelem)
void qh_initialhull(qhT *qh, setT *vertices)
int qh_pointid(pointT *point)
#define FOREACHvertexA_(vertices)
void qh_printhashtable(qhT *qh, FILE *fp)
void qh_outcoplanar(qhT *qh)
#define qh_DUPLICATEridge
void qh_appendfacet(facetT *facet)
void qh_vertexintersect(qhT *qh, setT **vertexsetA, setT *vertexsetB)
void qh_nearcoplanar(qhT *qh)
int qh_setin(setT *set, void *setelem)
setT * qh_pointfacet(qhT *qh)
void qh_printfacet(FILE *fp, facetT *facet)
boolT qh_addpoint(pointT *furthest, facetT *facet, boolT checkdist)
void qh_check_bestdist(qhT *qh)
void qh_delfacet(facetT *facet)
boolT qh_inthresholds(coordT *normal, realT *angle)
void qh_printlists(qhT *qh)
realT qh_getangle(pointT *vect1, pointT *vect2)
facetT * qh_findgooddist(pointT *point, facetT *facetA, realT *distp, facetT **facetlist)
facetT * qh_findbest(pointT *point, facetT *startfacet, boolT bestoutside, boolT isnewfacets, boolT noupper, realT *dist, boolT *isoutside, int *numpart)
setT * qh_vertexintersect_new(qhT *qh, setT *vertexsetA, setT *vertexsetB)
void qh_triangulate_facet(qhT *qh, facetT *facetA, vertexT **first_vertex)
boolT qh_matchvertices(int firstindex, setT *verticesA, int skipA, setT *verticesB, int *skipB, boolT *same)
void qh_addhash(void *newelem, setT *hashtable, int hashsize, int hash)
void qh_triangulate_mirror(qhT *qh, facetT *facetA, facetT *facetB)
facetT * qh_makenew_nonsimplicial(facetT *visible, vertexT *apex, int *numnew)
facetT * qh_findfacet_all(qhT *qh, pointT *point, realT *bestdist, boolT *isoutside, int *numpart)
void * qh_setlast(setT *set)
void qh_settempfree(setT **set)
#define FOREACHvertex_i_(vertices)
#define FOREACHridge_(ridges)
int qh_findgood(qhT *qh, facetT *facetlist, int goodhorizon)
facetT * qh_findbesthorizon(boolT ischeckmax, pointT *point, facetT *startfacet, boolT noupper, realT *bestdist, int *numpart)
#define FOREACHfacet_i_(facets)
pointT * qh_getcentrum(facetT *facet)
void qh_delridge(qhT *qh, ridgeT *ridge)
void qh_appendmergeset(facetT *facet, facetT *neighbor, mergeType mergetype, realT *angle)
void qh_checkconvex(qhT *qh, facetT *facetlist, int fault)
void qh_delvertex(qhT *qh, vertexT *vertex)
#define maximize_(maxval, val)
void qh_errexit2(int exitcode, facetT *facet, facetT *otherfacet)
void qh_checkvertex(qhT *qh, vertexT *vertex)
void qh_setprint(FILE *fp, const char *string, setT *set)
realT qh_detsimplex(pointT *apex, setT *points, int dim, boolT *nearzero)
void qh_option(const char *option, int *i, realT *r)
vertexT * qh_nearvertex(qhT *qh, facetT *facet, pointT *point, realT *bestdistp)
setT * qh_setnew_delnthsorted(setT *set, int size, int nth, int prepend)
void qh_furthestnext(qhT *qh)
facetT * qh_makenew_simplicial(facetT *visible, vertexT *apex, int *numnew)
void qh_settemppush(setT *set)
void qh_setzero(setT *set, int idx, int size)
#define SETreturnsize_(set, size)
boolT qh_orientoutside(facetT *facet)
void qh_setfree(setT **setp)
coordT qh_pointdist(pointT *point1, pointT *point2, int dim)
void qh_setaddnth(setT **setp, int nth, void *newelem)
#define FOREACHneighbor_(facet)
#define SETelemt_(set, n, type)
vertexT * qh_makenewfacets(qhT *qh, pointT *point)
#define SETindex_(set, elem)
setT * qh_initialvertices(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints)
void qh_setappend(setT **setp, void *newelem)
vertexT * qh_newvertex(qhT *qh, pointT *point)
#define qh_memfree_(object, insize, freelistp)
#define qh_COMPUTEfurthest
pointT * qh_point(qhT *qh, int id)
void qh_infiniteloop(qhT *qh, facetT *facet)
void qh_check_output(qhT *qh)
void * qh_setdellast(setT *set)
void qh_memfree(void *object, int insize)
void qh_appendvertex(vertexT *vertex)
void qh_checkfacet(qhT *qh, facetT *facet, boolT newmerge, boolT *waserrorp)
unsigned int vertex_visit
void qh_partitioncoplanar(pointT *point, facetT *facet, realT *dist)
void qh_outerinner(facetT *facet, realT *outerplane, realT *innerplane)
boolT qh_vertexsubset(setT *vertexsetA, setT *vertexsetB)
void * qh_setdel(setT *set, void *oldelem)
boolT qh_newstats(int idx, int *nextindex)
#define qh_ALGORITHMfault
void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge)
void qh_matchnewfacets(void)
int qh_setequal_skip(setT *setA, int skipA, setT *setB, int skipB)
void qh_scalelast(coordT *points, int numpoints, int dim, coordT low, coordT high, coordT newhigh)
void qh_clearcenters(qhT *qh, qh_CENTER type)
void qh_check_point(qhT *qh, pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2)
setT * qh_settemp(int setsize)
void qh_triangulate(qhT *qh)
#define FOREACHridge_i_(ridges)
setT * qh_facet3vertex(qhT *qh, facetT *facet)
#define FORALLvisible_facets
void qh_check_maxout(qhT *qh)
void qh_findgood_all(qhT *qh, facetT *facetlist)
void qh_triangulate_null(qhT *qh, facetT *facetA)
setT * qh_maxmin(pointT *points, int numpoints, int dimension)
vertexT * qh_isvertex(pointT *point, setT *vertices)
void qh_updatevertices(void)
void qh_detroundoff(void)
void qh_resetlists(qhT *qh, boolT stats, boolT resetVisible)
int qh_setequal(setT *setA, setT *setB)
void * qh_memalloc(int insize)
void qh_distplane(pointT *point, facetT *facet, realT *dist)
int qh_setsize(setT *set)
setT * qh_setnew(int setsize)
void qh_vertexneighbors(qhT *qh)
void qh_check_dupridge(qhT *qh, facetT *facet1, realT dist1, facetT *facet2, realT dist2)
realT qh_getdistance(facetT *facet, facetT *neighbor, realT *mindist, realT *maxdist)
void qh_matchduplicates(qhT *qh, facetT *atfacet, int atskip, int hashsize, int *hashcount)
void qh_errprint(const char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex)
#define SETaddr_(set, type)
#define FOREACHpoint_(points)
#define FOREACHneighbor_i_(facet)
void qh_maxsimplex(int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex)
void qh_willdelete(facetT *facet, facetT *replace)
#define FOREACHpoint_i_(points)
int qh_gethash(int hashsize, setT *set, int size, int firstindex, void *skipelem)
#define minimize_(minval, val)
#define SETsecondt_(set, type)
void qh_checkpolygon(qhT *qh, facetT *facetlist)
pointT * qh_facetcenter(setT *vertices)
void qh_setfacetplane(facetT *facet)