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 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 #if 0
00063 char qh_version[] = "user_eg 98/7/25";  
00064 
00065 {
00066   int dim;                  
00067   int numpoints;            
00068   coordT *points;           
00069   boolT ismalloc;           
00070   char flags[]= "qhull Tv"; 
00071   FILE *outfile= stdout;    
00072 
00073   FILE *errfile= stderr;    
00074   int exitcode;             
00075   facetT *facet;            
00076   int curlong, totlong;     
00077 
00078   
00079   exitcode= qh_new_qhull (dim, numpoints, points, ismalloc,
00080                       flags, outfile, errfile); 
00081   if (!exitcode) {                  
00082     
00083     FORALLfacets {
00084        
00085     }
00086   }
00087   qh_freeqhull(!qh_ALL);
00088   qh_memfreeshort (&curlong, &totlong);
00089   if (curlong || totlong) 
00090     fprintf (errfile, "qhull internal warning (main): did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
00091 }
00092 #endif
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 int qh_new_qhull (int dim, int numpoints, coordT *points, boolT ismalloc, 
00121                 char *qhull_cmd, FILE *outfile, FILE *errfile) {
00122   int exitcode, hulldim;
00123   boolT new_ismalloc;
00124   static boolT firstcall = True;
00125   coordT *new_points;
00126 
00127   if (firstcall) {
00128     qh_meminit (errfile);
00129     firstcall= False;
00130   }
00131   if (strncmp (qhull_cmd,"qhull ", 6)) {
00132     fprintf (errfile, "qh_new_qhull: start qhull_cmd argument with \"qhull \"\n");
00133     exit(1);
00134   }
00135   qh_initqhull_start (NULL, outfile, errfile);
00136   trace1(( qh ferr, "qh_new_qhull: build new Qhull for %d %d-d points with %s\n", numpoints, dim, qhull_cmd));
00137   exitcode = setjmp (qh errexit);
00138   if (!exitcode)
00139   {
00140     qh NOerrexit = False;
00141     qh_initflags (qhull_cmd);
00142     if (qh DELAUNAY)
00143       qh PROJECTdelaunay= True;
00144     if (qh HALFspace) {
00145       
00146 
00147       hulldim= dim-1;
00148       qh_setfeasible (hulldim); 
00149       new_points= qh_sethalfspace_all (dim, numpoints, points, qh feasible_point);
00150       new_ismalloc= True;
00151       if (ismalloc)
00152         free (points);
00153     }else {
00154       hulldim= dim;
00155       new_points= points;
00156       new_ismalloc= ismalloc;
00157     }
00158     qh_init_B (new_points, numpoints, hulldim, new_ismalloc);
00159     qh_qhull();
00160     qh_check_output();
00161     if (outfile)
00162       qh_produce_output(); 
00163     if (qh VERIFYoutput && !qh STOPpoint && !qh STOPcone)
00164       qh_check_points();
00165   }
00166   qh NOerrexit = True;
00167   return exitcode;
00168 } 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge) {
00193 
00194   if (qh ERREXITcalled) {
00195     fprintf (qh ferr, "\nqhull error while processing previous error.  Exit program\n");
00196     exit(1);
00197   }
00198   qh ERREXITcalled= True;
00199   if (!qh QHULLfinished)
00200     qh hulltime= qh_CPUclock - qh hulltime;
00201   qh_errprint("ERRONEOUS", facet, NULL, ridge, NULL);
00202   fprintf (qh ferr, "\nWhile executing: %s | %s\n", qh rbox_command, qh qhull_command);
00203   fprintf(qh ferr, "Options selected for Qhull %s:\n%s\n", qh_version, qh qhull_options);
00204   if (qh furthest_id >= 0) {
00205     fprintf(qh ferr, "Last point added to hull was p%d.", qh furthest_id);
00206     if (zzval_(Ztotmerge))
00207       fprintf(qh ferr, "  Last merge was #%d.", zzval_(Ztotmerge));
00208     if (qh QHULLfinished)
00209       fprintf(qh ferr, "\nQhull has finished constructing the hull.");
00210     else if (qh POSTmerging)
00211       fprintf(qh ferr, "\nQhull has started post-merging.");
00212     fprintf (qh ferr, "\n");
00213   }
00214   if (qh FORCEoutput && (qh QHULLfinished || (!facet && !ridge)))
00215     qh_produce_output();
00216   else {
00217     if (exitcode != qh_ERRsingular && zzval_(Zsetplane) > qh hull_dim+1) {
00218       fprintf (qh ferr, "\nAt error exit:\n");
00219       qh_printsummary (qh ferr);
00220       if (qh PRINTstatistics) {
00221         qh_collectstatistics();
00222         qh_printstatistics(qh ferr, "at error exit");
00223         qh_memstatistics (qh ferr);
00224       }
00225     }
00226     if (qh PRINTprecision)
00227       qh_printstats (qh ferr, qhstat precision, NULL);
00228   }
00229   if (!exitcode)
00230     exitcode= qh_ERRqhull;
00231   else if (exitcode == qh_ERRsingular)
00232     qh_printhelp_singular(qh ferr);
00233   else if (exitcode == qh_ERRprec && !qh PREmerge)
00234     qh_printhelp_degenerate (qh ferr);
00235   if (qh NOerrexit) {
00236     fprintf (qh ferr, "qhull error while ending program.  Exit program\n");
00237     exit(1);
00238   }
00239   qh NOerrexit= True;
00240   longjmp(qh errexit, exitcode);
00241 } 
00242 
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 void qh_errprint(char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex) {
00255   int i;
00256 
00257   if (atfacet) {
00258     fprintf(qh ferr, "%s FACET:\n", string);
00259     qh_printfacet(qh ferr, atfacet);
00260   }
00261   if (otherfacet) {
00262     fprintf(qh ferr, "%s OTHER FACET:\n", string);
00263     qh_printfacet(qh ferr, otherfacet);
00264   }
00265   if (atridge) {
00266     fprintf(qh ferr, "%s RIDGE:\n", string);
00267     qh_printridge(qh ferr, atridge);
00268     if (atridge->top && atridge->top != atfacet && atridge->top != otherfacet)
00269       qh_printfacet(qh ferr, atridge->top);
00270     if (atridge->bottom
00271         && atridge->bottom != atfacet && atridge->bottom != otherfacet)
00272       qh_printfacet(qh ferr, atridge->bottom);
00273     if (!atfacet)
00274       atfacet= atridge->top;
00275     if (!otherfacet)
00276       otherfacet= otherfacet_(atridge, atfacet);
00277   }
00278   if (atvertex) {
00279     fprintf(qh ferr, "%s VERTEX:\n", string);
00280     qh_printvertex (qh ferr, atvertex);
00281   }
00282   if (qh fout && qh FORCEoutput && atfacet && !qh QHULLfinished && !qh IStracing) {
00283     fprintf(qh ferr, "ERRONEOUS and NEIGHBORING FACETS to output\n");
00284     for (i= 0; i < qh_PRINTEND; i++)  
00285       qh_printneighborhood (qh fout, qh PRINTout[i], atfacet, otherfacet,
00286                             !qh_ALL);
00287   }
00288 } 
00289 
00290 
00291 
00292 
00293 
00294 
00295 
00296 
00297 
00298 
00299 
00300 
00301 
00302 void qh_printfacetlist(facetT *facetlist, setT *facets, boolT printall) {
00303   facetT *facet, **facetp;
00304 
00305   qh_printbegin (qh ferr, qh_PRINTfacets, facetlist, facets, printall);
00306   FORALLfacet_(facetlist)
00307     qh_printafacet(qh ferr, qh_PRINTfacets, facet, printall);
00308   FOREACHfacet_(facets)
00309     qh_printafacet(qh ferr, qh_PRINTfacets, facet, printall);
00310   qh_printend (qh ferr, qh_PRINTfacets, facetlist, facets, printall);
00311 } 
00312 
00313 
00314 
00315 
00316 
00317 
00318 
00319 
00320 
00321 
00322 
00323 void qh_user_memsizes (void) {
00324 
00325   
00326 } 
00327