53 trace4((qh, qh->
ferr, 4044,
"qh_appendfacet: append f%d to facet_list\n", facet->
id));
86 trace4((qh, qh->
ferr, 4045,
"qh_appendvertex: append v%d to vertex_list\n", vertex->
id));
130 facetT *newfacet= NULL, *neighbor, **neighborp, *horizon, *visible;
134 trace3((qh, qh->
ferr, 3012,
"qh_attachnewfacets: delete interior ridges\n"));
138 if (visible->ridges) {
141 if (neighbor->visitid == qh->
visit_id 142 || (!neighbor->visible && neighbor->simplicial)) {
143 if (!neighbor->visible)
153 trace1((qh, qh->
ferr, 1017,
"qh_attachnewfacets: attach horizon facets to new facets\n"));
156 if (horizon->simplicial) {
159 if (neighbor->visible) {
162 SETindex_(horizon->neighbors, neighbor))) {
171 visible->f.replace= newfacet;
174 qh_fprintf(qh, qh->
ferr, 6102,
"qhull internal error (qh_attachnewfacets): couldn't find visible facet for horizon f%d of newfacet f%d\n",
175 horizon->id, newfacet->
id);
180 if (neighbor->visible) {
181 neighbor->f.replace= newfacet;
183 SETindex_(horizon->neighbors, neighbor));
189 if (ridge->
top == horizon)
192 ridge->
top= newfacet;
197 if (!visible->f.replace)
227 if ((allerror && dist > -qh->
DISTround)|| (!allerror && dist >= 0.0)) {
230 trace0((qh, qh->
ferr, 19,
"qh_checkflipped: facet f%d is flipped, distance= %6.12g during p%d\n",
250 trace4((qh, qh->
ferr, 4046,
"qh_delfacet: delete f%d\n", facet->
id));
293 facetT *visible, *nextfacet;
297 trace1((qh, qh->
ferr, 1018,
"qh_deletevisible: delete %d visible facets and %d vertices\n",
300 visible= nextfacet) {
301 nextfacet= visible->
next;
306 qh_fprintf(qh, qh->
ferr, 6103,
"qhull internal error (qh_deletevisible): qh->num_visible %d is not number of visible facets %d\n",
344 int *skipA,
int *skipB,
int prepend) {
347 facetT **neighborsA, **neighborsB;
352 if (facetB == *neighborsA++)
354 else if (facetB == *neighborsA++)
356 else if (facetB == *neighborsA++)
359 for (i=3; i < dim; i++) {
360 if (facetB == *neighborsA++) {
366 if (facetA == *neighborsB++)
368 else if (facetA == *neighborsB++)
370 else if (facetA == *neighborsB++)
373 for (j=3; j < dim; j++) {
374 if (facetA == *neighborsB++) {
380 if (i >= dim || j >= dim) {
381 qh_fprintf(qh, qh->
ferr, 6104,
"qhull internal error (qh_facetintersect): f%d or f%d not in others neighbors\n",
382 facetA->
id, facetB->
id);
386 trace4((qh, qh->
ferr, 4047,
"qh_facetintersect: f%d skip %d matches f%d skip %d\n",
387 facetA->
id, *skipA, facetB->
id, *skipB));
411 #pragma warning( push) 412 #pragma warning( disable : 4311) 415 switch (size-firstindex) {
444 hash ^= (elem << i) + (elem >> (32-i));
453 qh_fprintf(qh, qh->
ferr, 6202,
"qhull internal error: negative hashsize %d passed to qh_gethash [poly.c]\n", hashsize);
456 result= (unsigned)hash;
457 result %= (unsigned)hashsize;
461 #pragma warning( pop) 491 newfacet->
toporient= (
unsigned char)toporient;
566 facetT *neighbor, *newfacet= NULL, *samecycle;
582 toporient= (ridge->
top == visible);
590 if (!neighbor->
seen) {
603 if (neighbor->
seen) {
605 qh_fprintf(qh, qh->
ferr, 6105,
"qhull internal error (qh_makenew_nonsimplicial): simplicial f%d sharing two ridges with f%d\n",
606 neighbor->
id, visible->
id);
619 ridge->
top= newfacet;
623 trace4((qh, qh->
ferr, 4048,
"qh_makenew_nonsimplicial: created facet f%d from v%d and r%d of horizon f%d\n",
624 newfacet->
id, apex->
id, ridgeid, neighbor->
id));
661 facetT *neighbor, **neighborp, *newfacet= NULL;
663 boolT flip, toporient;
664 int horizonskip= 0, visibleskip= 0;
668 vertices=
qh_facetintersect(qh, neighbor,visible, &horizonskip, &visibleskip, 1);
670 flip= ((horizonskip & 0x1) ^ (visibleskip & 0x1));
672 toporient= horizonskip & 0x1;
674 toporient= (horizonskip & 0x1) ^ 0x1;
685 trace4((qh, qh->
ferr, 4049,
"qh_makenew_simplicial: create facet f%d top %d from v%d and horizon f%d skip %d top %d and visible f%d skip %d, flip? %d\n",
686 newfacet->
id, toporient, apex->
id, neighbor->
id, horizonskip,
687 neighbor->
toporient, visible->
id, visibleskip, flip));
728 facetT *facet, *matchfacet;
733 trace4((qh, qh->
ferr, 4050,
"qh_matchneighbor: newfacet f%d skip %d hash %d hashcount %d\n",
734 newfacet->
id, newskip, hash, *hashcount));
737 scan= (++scan >= hashsize ? 0 : scan)) {
738 if (facet == newfacet) {
747 qh_fprintf(qh, qh->
ferr, 6106,
"qhull precision error: Vertex sets are the same for f%d and f%d. Can not force output.\n",
748 facet->
id, newfacet->
id);
753 if (ismatch && !matchfacet) {
757 trace4((qh, qh->
ferr, 4051,
"qh_matchneighbor: f%d skip %d matched with new f%d skip %d\n",
758 facet->
id, skip, newfacet->
id, newskip));
762 qh_precision(qh,
"a ridge with more than two neighbors");
763 qh_fprintf(qh, qh->
ferr, 6107,
"qhull precision error: facets f%d, f%d and f%d meet at a ridge with more than 2 neighbors. Can not continue.\n",
783 qh_fprintf(qh, qh->
ferr, 6260,
"qhull internal error (qh_matchneighbor): matchfacet f%d is in f%d neighbors but not vice versa. Can not continue.\n",
784 matchfacet->
id, facet->
id);
795 trace4((qh, qh->
ferr, 4052,
"qh_matchneighbor: new f%d skip %d duplicates ridge for f%d skip %d matching f%d ismatch %d at hash %d\n",
796 newfacet->
id, newskip, facet->
id, skip,
805 trace4((qh, qh->
ferr, 4053,
"qh_matchneighbor: no match for f%d skip %d at hash %d\n",
806 newfacet->
id, newskip, hash));
842 int numnew=0, hashcount=0, newskip;
843 facetT *newfacet, *neighbor;
844 int dim= qh->
hull_dim, hashsize, neighbor_i, neighbor_n;
847 int facet_i, facet_n, numfree= 0;
851 trace1((qh, qh->
ferr, 1019,
"qh_matchnewfacets: match neighbors for new facets.\n"));
856 neighbors->
e[neighbors->
maxsize].
i= dim+1;
865 for (newskip=1; newskip<qh->
hull_dim; newskip++)
880 if (facet == newfacet)
883 if (count != hashcount) {
884 qh_fprintf(qh, qh->
ferr, 8088,
"qh_matchnewfacets: after adding facet %d, hashcount %d != count %d\n",
885 newfacet->
id, hashcount, count);
904 qh_fprintf(qh, qh->
ferr, 6108,
"qhull internal error (qh_matchnewfacets): %d neighbors did not match up\n",
915 qh_fprintf(qh, qh->
ferr, 8089,
"qh_matchnewfacets: %d new facets, %d unused hash entries . hashsize %d\n",
953 setT *verticesB,
int *skipB,
boolT *same) {
954 vertexT **elemAp, **elemBp, **skipBp=NULL, **skipAp;
959 do if (elemAp != skipAp) {
960 while (*elemAp != *elemBp++) {
965 }
while (*(++elemAp));
969 *same= !((skipA & 0x1) ^ (*skipB & 0x1));
970 trace4((qh, qh->
ferr, 4054,
"qh_matchvertices: matched by skip %d(v%d) and skip %d(v%d) same? %d\n",
971 skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same));
990 memset((
char *)facet, (
size_t)0,
sizeof(
facetT));
995 #if !qh_COMPUTEfurthest 996 facet->furthestdist= 0.0;
1004 facet->simplicial=
True;
1006 facet->newfacet=
True;
1007 trace4((qh, qh->
ferr, 4055,
"qh_newfacet: created facet f%d\n", facet->id));
1023 memset((
char *)ridge, (
size_t)0,
sizeof(
ridgeT));
1027 qhull warning: more than 2^32 ridges. Qhull results are OK. Since the ridge ID wraps around to 0, two ridges may have the same identifier.\n");
1030 trace4((qh, qh->
ferr, 4056,
"qh_newridge: created ridge r%d\n", ridge->id));
1094 previous->
next= next;
1101 trace4((qh, qh->
ferr, 4057,
"qh_removefacet: remove f%d from facet_list\n", facet->
id));
1121 previous->
next= next;
1128 trace4((qh, qh->
ferr, 4058,
"qh_removevertex: remove v%d from vertex_list\n", vertex->
id));
1156 facetT *newfacet= NULL, *neighbor, **neighborp, *visible;
1159 trace3((qh, qh->
ferr, 3013,
"qh_updatevertices: delete interior vertices and update vertex->neighbors\n"));
1163 if (neighbor->visible)
1176 if (!neighbor->visible)
1184 trace2((qh, qh->
ferr, 2041,
"qh_updatevertices: delete vertex p%d(v%d) in f%d\n",
1196 trace2((qh, qh->
ferr, 2042,
"qh_updatevertices: delete vertex p%d(v%d) in f%d\n",
int qh_pointid(qhT *qh, pointT *point)
void qh_settruncate(setT *set, int size)
#define otherfacet_(ridge, facet)
void qh_appendvertex(qhT *qh, vertexT *vertex)
facetT * qh_makenew_simplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew)
void qh_checkflipped_all(facetT *facetlist)
void qh_addhash(void *newelem, setT *hashtable, int hashsize, int hash)
#define FOREACHvertex_(vertices)
void qh_setcompact(setT *set)
void qh_setreplace(setT *set, void *oldelem, void *newelem)
ridgeT * qh_newridge(qhT *qh)
#define SETfirstt_(set, type)
#define FORALLvertex_(vertexlist)
void qh_removevertex(qhT *qh, vertexT *vertex)
#define qh_memalloc_(insize, freelistp, object, type)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
void qh_makenewplanes(qhT *qh)
void qh_precision(const char *reason)
void qh_matchneighbor(qhT *qh, facetT *newfacet, int newskip, int hashsize, int *hashcount)
void qh_printfacetlist(facetT *facetlist, setT *facets, boolT printall)
#define FORALLfacet_(facetlist)
boolT qh_checkflipped(qhT *qh, facetT *facet, realT *distp, boolT allerror)
int qh_gethash(qhT *qh, int hashsize, setT *set, int size, int firstindex, void *skipelem)
void qh_delvertex(vertexT *vertex)
int qh_setindex(setT *set, void *atelem)
void qh_printhashtable(FILE *fp)
setT * qh_facetintersect(qhT *qh, facetT *facetA, facetT *facetB, int *skipA, int *skipB, int prepend)
#define qh_DUPLICATEridge
void qh_delfacet(qhT *qh, facetT *facet)
facetT * qh_makenewfacet(qhT *qh, setT *vertices, boolT toporient, facetT *horizon)
#define FOREACHridge_(ridges)
void qh_setappend_set(setT **setp, setT *setA)
int qh_newhashtable(int newsize)
#define FOREACHfacet_i_(facets)
void qh_errexit2(int exitcode, facetT *facet, facetT *otherfacet)
#define SETelemaddr_(set, n, type)
setT * qh_setnew_delnthsorted(setT *set, int size, int nth, int prepend)
void qh_deletevisible(qhT *qh)
void * qh_setdelnth(setT *set, int nth)
void qh_setfree(setT **setp)
#define FOREACHneighbor_(facet)
void qh_matchduplicates(facetT *atfacet, int atskip, int hashsize, int *hashcount)
#define SETelemt_(set, n, type)
void qh_appendfacet(qhT *qh, facetT *facet)
#define SETindex_(set, elem)
void qh_setappend(setT **setp, void *newelem)
#define qh_memfree_(object, insize, freelistp)
void qh_memfree(void *object, int insize)
facetT * qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew)
void * qh_setdel(setT *set, void *oldelem)
void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge)
int qh_setequal_skip(setT *setA, int skipA, setT *setB, int skipB)
void qh_matchnewfacets(qhT *qh)
void qh_removefacet(qhT *qh, facetT *facet)
#define FORALLvisible_facets
void qh_attachnewfacets(qhT *qh)
void qh_distplane(pointT *point, facetT *facet, realT *dist)
int qh_setsize(setT *set)
void qh_updatevertices(qhT *qh)
setT * qh_setnew(int setsize)
#define SETaddr_(set, type)
#define FOREACHneighbor_i_(facet)
boolT qh_matchvertices(qhT *qh, int firstindex, setT *verticesA, int skipA, setT *verticesB, int *skipB, boolT *same)
facetT * qh_newfacet(qhT *qh)
#define minimize_(minval, val)
void qh_setfacetplane(facetT *facet)