00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "qhull_a.h"
00042
00043 #ifdef USE_DMALLOC
00044 #include "dmalloc.h"
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #if 0
00066 char qh_version[] = "user_eg 97/3/31";
00067
00068 int call_qhull (void) {
00069 int curlong, totlong, exitcode, numpoints, dim;
00070 coordT *points;
00071 boolT ismalloc;
00072 char *flags;
00073
00074 qh_init_A (stdin, stdout, stderr, 0, NULL);
00075 exitcode= setjmp (qh errexit);
00076 if (!exitcode) {
00077 strcat (qh rbox_command, "user");
00078 qh_initflags ("qhull Tc (your flags go here)");
00079
00080
00081 points= array;
00082 ismalloc= False;
00083 dim= 3;
00084 numpoints= 100; ;
00085
00086
00087
00088
00089
00090
00091 qh_init_B (points, numpoints, dim, ismalloc);
00092
00093 qh_qhull();
00094
00095 qh_check_output();
00096 qh_produce_output();
00097 if (qh VERIFYoutput && !qh STOPpoint && !qh STOPcone)
00098 qh_check_points();
00099
00100 }
00101 qh NOerrexit= True;
00102 qh_freeqhull(!qh_ALL);
00103 qh_memfreeshort (&curlong, &totlong);
00104 if (curlong || totlong)
00105 fprintf (stderr, "qhull internal warning (main): did not free %d bytes of long memory (%d pieces)\n",
00106 totlong, curlong);
00107 return exitcode;
00108 }
00109 #endif
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge) {
00134
00135 if (qh ERREXITcalled) {
00136 fprintf (qh ferr, "\nqhull error while processing previous error. Exit program\n");
00137 exit(1);
00138 }
00139 qh ERREXITcalled= True;
00140 if (!qh QHULLfinished)
00141 qh hulltime= qh_CPUclock - qh hulltime;
00142 qh_errprint("ERRONEOUS", facet, NULL, ridge, NULL);
00143 fprintf (qh ferr, "\nWhile executing: %s | %s\n", qh rbox_command, qh qhull_command);
00144 fprintf(qh ferr, "Options selected for %s:\n%s\n", qh_version, qh qhull_options);
00145 if (qh furthest_id >= 0) {
00146 fprintf(qh ferr, "Last point added to hull was p%d.", qh furthest_id);
00147 if (zzval_(Ztotmerge))
00148 fprintf(qh ferr, " Last merge was #%d.", zzval_(Ztotmerge));
00149 if (qh QHULLfinished)
00150 fprintf(qh ferr, "\nQhull has finished constructing the hull.");
00151 else if (qh POSTmerging)
00152 fprintf(qh ferr, "\nQhull has started post-merging.");
00153 fprintf (qh ferr, "\n");
00154 }
00155 if (qh FORCEoutput && (qh QHULLfinished || (!facet && !ridge)))
00156 qh_produce_output();
00157 else {
00158 if (exitcode != qh_ERRsingular && zzval_(Zsetplane) > qh hull_dim+1) {
00159 fprintf (qh ferr, "\nAt error exit:\n");
00160 qh_printsummary (qh ferr);
00161 if (qh PRINTstatistics) {
00162 qh_collectstatistics();
00163 qh_printstatistics(qh ferr, "at error exit");
00164 qh_memstatistics (qh ferr);
00165 }
00166 }
00167 if (qh PRINTprecision)
00168 qh_printstats (qh ferr, qhstat precision, NULL);
00169 }
00170 if (!exitcode)
00171 exitcode= qh_ERRqhull;
00172 else if (exitcode == qh_ERRsingular)
00173 qh_printhelp_singular(qh ferr);
00174 else if (exitcode == qh_ERRprec && !qh PREmerge)
00175 qh_printhelp_degenerate (qh ferr);
00176 if (qh NOerrexit) {
00177 fprintf (qh ferr, "qhull error while ending program. Exit program\n");
00178 exit(1);
00179 }
00180 qh NOerrexit= True;
00181 longjmp(qh errexit, exitcode);
00182 }
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 void qh_errprint(char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex) {
00196 int i;
00197
00198 if (atfacet) {
00199 fprintf(qh ferr, "%s FACET:\n", string);
00200 qh_printfacet(qh ferr, atfacet);
00201 }
00202 if (otherfacet) {
00203 fprintf(qh ferr, "%s OTHER FACET:\n", string);
00204 qh_printfacet(qh ferr, otherfacet);
00205 }
00206 if (atridge) {
00207 fprintf(qh ferr, "%s RIDGE:\n", string);
00208 qh_printridge(qh ferr, atridge);
00209 if (atridge->top && atridge->top != atfacet && atridge->top != otherfacet)
00210 qh_printfacet(qh ferr, atridge->top);
00211 if (atridge->bottom
00212 && atridge->bottom != atfacet && atridge->bottom != otherfacet)
00213 qh_printfacet(qh ferr, atridge->bottom);
00214 if (!atfacet)
00215 atfacet= atridge->top;
00216 if (!otherfacet)
00217 otherfacet= otherfacet_(atridge, atfacet);
00218 }
00219 if (atvertex) {
00220 fprintf(qh ferr, "%s VERTEX:\n", string);
00221 qh_printvertex (qh ferr, atvertex);
00222 }
00223 if (qh FORCEoutput && atfacet && !qh QHULLfinished && !qh IStracing) {
00224 fprintf(qh ferr, "ERRONEOUS and NEIGHBORING FACETS to output\n");
00225 for (i= 0; i < qh_PRINTEND; i++)
00226 qh_printneighborhood (qh fout, qh PRINTout[i], atfacet, otherfacet,
00227 !qh_ALL);
00228 }
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 void qh_printfacetlist(facetT *facetlist, setT *facets, boolT printall) {
00244 facetT *facet, **facetp;
00245
00246 qh_printbegin (qh ferr, qh_PRINTfacets, facetlist, facets, printall);
00247 FORALLfacet_(facetlist)
00248 qh_printafacet(qh ferr, qh_PRINTfacets, facet, printall);
00249 FOREACHfacet_(facets)
00250 qh_printafacet(qh ferr, qh_PRINTfacets, facet, printall);
00251 qh_printend (qh ferr, qh_PRINTfacets, facetlist, facets, printall);
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 void qh_user_memsizes (void) {
00265
00266
00267 }
00268