user_r.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*<html><pre> -<a href="qh-user_r.htm"
  2. >-------------------------------</a><a name="TOP">-</a>
  3. user_r.c
  4. user redefinable functions
  5. see user2_r.c for qh_fprintf, qh_malloc, qh_free
  6. see README.txt see COPYING.txt for copyright information.
  7. see libqhull_r.h for data structures, macros, and user-callable functions.
  8. see user_eg_r.c, user_eg2_r.c, and unix_r.c for examples.
  9. see user_r.h for user-definable constants
  10. use qh_NOmem in mem_r.h to turn off memory management
  11. use qh_NOmerge in user_r.h to turn off facet merging
  12. set qh_KEEPstatistics in user_r.h to 0 to turn off statistics
  13. This is unsupported software. You're welcome to make changes,
  14. but you're on your own if something goes wrong. Use 'Tc' to
  15. check frequently. Usually qhull will report an error if
  16. a data structure becomes inconsistent. If so, it also reports
  17. the last point added to the hull, e.g., 102. You can then trace
  18. the execution of qhull with "T4P102".
  19. Please report any errors that you fix to qhull@qhull.org
  20. Qhull-template is a template for calling qhull from within your application
  21. if you recompile and load this module, then user.o will not be loaded
  22. from qhull.a
  23. you can add additional quick allocation sizes in qh_user_memsizes
  24. if the other functions here are redefined to not use qh_print...,
  25. then io.o will not be loaded from qhull.a. See user_eg_r.c for an
  26. example. We recommend keeping io.o for the extra debugging
  27. information it supplies.
  28. */
  29. #include "qhull_ra.h"
  30. #include <stdarg.h>
  31. /*-<a href="qh-user_r.htm#TOC"
  32. >-------------------------------</a><a name="qhull_template">-</a>
  33. Qhull-template
  34. Template for calling qhull from inside your program
  35. returns:
  36. exit code(see qh_ERR... in libqhull_r.h)
  37. all memory freed
  38. notes:
  39. This can be called any number of times.
  40. */
  41. #if 0
  42. {
  43. int dim; /* dimension of points */
  44. int numpoints; /* number of points */
  45. coordT *points; /* array of coordinates for each point */
  46. boolT ismalloc; /* True if qhull should free points in qh_freeqhull() or reallocation */
  47. char flags[]= "qhull Tv"; /* option flags for qhull, see html/qh-quick.htm */
  48. FILE *outfile= stdout; /* output from qh_produce_output
  49. use NULL to skip qh_produce_output */
  50. FILE *errfile= stderr; /* error messages from qhull code */
  51. int exitcode; /* 0 if no error from qhull */
  52. facetT *facet; /* set by FORALLfacets */
  53. int curlong, totlong; /* memory remaining after qh_memfreeshort */
  54. qhT qh_qh; /* Qhull's data structure. First argument of most calls */
  55. qhT *qh= &qh_qh; /* Alternatively -- qhT *qh= (qhT *)malloc(sizeof(qhT)) */
  56. QHULL_LIB_CHECK /* Check for compatible library */
  57. qh_zero(qh, errfile);
  58. /* initialize dim, numpoints, points[], ismalloc here */
  59. exitcode= qh_new_qhull(qh, dim, numpoints, points, ismalloc,
  60. flags, outfile, errfile);
  61. if (!exitcode) { /* if no error */
  62. /* 'qh->facet_list' contains the convex hull */
  63. FORALLfacets {
  64. /* ... your code ... */
  65. }
  66. }
  67. qh_freeqhull(qh, !qh_ALL);
  68. qh_memfreeshort(qh, &curlong, &totlong);
  69. if (curlong || totlong)
  70. qh_fprintf(qh, errfile, 7079, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n", totlong, curlong);
  71. }
  72. #endif
  73. /*-<a href="qh-user_r.htm#TOC"
  74. >-------------------------------</a><a name="new_qhull">-</a>
  75. qh_new_qhull(qh, dim, numpoints, points, ismalloc, qhull_cmd, outfile, errfile )
  76. Run qhull
  77. Before first call, either call qh_zero(qh, errfile), or set qh to all zero.
  78. returns:
  79. results in qh
  80. exitcode (0 if no errors).
  81. notes:
  82. do not modify points until finished with results.
  83. The qhull data structure contains pointers into the points array.
  84. do not call qhull functions before qh_new_qhull().
  85. The qhull data structure is not initialized until qh_new_qhull().
  86. do not call qh_init_A (global_r.c)
  87. Default errfile is stderr, outfile may be null
  88. qhull_cmd must start with "qhull "
  89. projects points to a new point array for Delaunay triangulations ('d' and 'v')
  90. transforms points into a new point array for halfspace intersection ('H')
  91. see:
  92. Qhull-template at the beginning of this file.
  93. An example of using qh_new_qhull is user_eg_r.c
  94. */
  95. int qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  96. char *qhull_cmd, FILE *outfile, FILE *errfile) {
  97. return qh_new_qhull_feaspoint(qh, dim, numpoints, points, ismalloc,
  98. qhull_cmd, outfile, errfile, NULL);
  99. }
  100. int qh_new_qhull_feaspoint(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  101. char *qhull_cmd, FILE *outfile, FILE *errfile, coordT* feaspoint) {
  102. /* gcc may issue a "might be clobbered" warning for dim, points, and ismalloc [-Wclobbered].
  103. These parameters are not referenced after a longjmp() and hence not clobbered.
  104. See http://stackoverflow.com/questions/7721854/what-sense-do-these-clobbered-variable-warnings-make */
  105. int exitcode, hulldim;
  106. boolT new_ismalloc;
  107. coordT *new_points;
  108. if(!errfile){
  109. errfile= stderr;
  110. }
  111. if (!qh->qhmem.ferr) {
  112. qh_meminit(qh, errfile);
  113. } else {
  114. qh_memcheck(qh);
  115. }
  116. if (strncmp(qhull_cmd, "qhull ", (size_t)6) && strcmp(qhull_cmd, "qhull") != 0) {
  117. qh_fprintf(qh, errfile, 6186, "qhull error (qh_new_qhull): start qhull_cmd argument with \"qhull \" or set to \"qhull\"\n");
  118. return qh_ERRinput;
  119. }
  120. qh_initqhull_start(qh, NULL, outfile, errfile);
  121. if(numpoints==0 && points==NULL){
  122. trace1((qh, qh->ferr, 1047, "qh_new_qhull: initialize Qhull\n"));
  123. return 0;
  124. }
  125. trace1((qh, qh->ferr, 1044, "qh_new_qhull: build new Qhull for %d %d-d points with %s\n", numpoints, dim, qhull_cmd));
  126. exitcode= setjmp(qh->errexit);
  127. if (!exitcode) {
  128. qh->NOerrexit= False;
  129. qh_initflags(qh, qhull_cmd);
  130. if (qh->DELAUNAY)
  131. qh->PROJECTdelaunay= True;
  132. if (qh->HALFspace) {
  133. /* points is an array of halfspaces,
  134. the last coordinate of each halfspace is its offset */
  135. hulldim= dim-1;
  136. if(feaspoint)
  137. {
  138. if (!(qh->feasible_point= (pointT*)qh_malloc(hulldim * sizeof(coordT)))) {
  139. qh_fprintf(qh, qh->ferr, 6079, "qhull error: insufficient memory for 'Hn,n,n'\n");
  140. qh_errexit(qh, qh_ERRmem, NULL, NULL);
  141. }
  142. coordT* coords = qh->feasible_point;
  143. coordT* value = feaspoint;
  144. int i;
  145. for(i = 0; i < hulldim; ++i)
  146. {
  147. *(coords++) = *(value++);
  148. }
  149. }
  150. else
  151. {
  152. qh_setfeasible(qh, hulldim);
  153. }
  154. new_points= qh_sethalfspace_all(qh, dim, numpoints, points, qh->feasible_point);
  155. new_ismalloc= True;
  156. if (ismalloc)
  157. qh_free(points);
  158. }else {
  159. hulldim= dim;
  160. new_points= points;
  161. new_ismalloc= ismalloc;
  162. }
  163. qh_init_B(qh, new_points, numpoints, hulldim, new_ismalloc);
  164. qh_qhull(qh);
  165. qh_check_output(qh);
  166. if (outfile) {
  167. qh_produce_output(qh);
  168. }else {
  169. qh_prepare_output(qh);
  170. }
  171. if (qh->VERIFYoutput && !qh->FORCEoutput && !qh->STOPadd && !qh->STOPcone && !qh->STOPpoint)
  172. qh_check_points(qh);
  173. }
  174. qh->NOerrexit= True;
  175. return exitcode;
  176. } /* new_qhull */
  177. /*-<a href="qh-user_r.htm#TOC"
  178. >-------------------------------</a><a name="errexit">-</a>
  179. qh_errexit(qh, exitcode, facet, ridge )
  180. report and exit from an error
  181. report facet and ridge if non-NULL
  182. reports useful information such as last point processed
  183. set qh.FORCEoutput to print neighborhood of facet
  184. see:
  185. qh_errexit2() in libqhull_r.c for printing 2 facets
  186. design:
  187. check for error within error processing
  188. compute qh.hulltime
  189. print facet and ridge (if any)
  190. report commandString, options, qh.furthest_id
  191. print summary and statistics (including precision statistics)
  192. if qh_ERRsingular
  193. print help text for singular data set
  194. exit program via long jump (if defined) or exit()
  195. */
  196. void qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge) {
  197. qh->tracefacet= NULL; /* avoid infinite recursion through qh_fprintf */
  198. qh->traceridge= NULL;
  199. qh->tracevertex= NULL;
  200. if (qh->ERREXITcalled) {
  201. qh_fprintf(qh, qh->ferr, 8126, "\nqhull error while handling previous error in qh_errexit. Exit program\n");
  202. qh_exit(qh_ERRother);
  203. }
  204. qh->ERREXITcalled= True;
  205. if (!qh->QHULLfinished)
  206. qh->hulltime= qh_CPUclock - qh->hulltime;
  207. qh_errprint(qh, "ERRONEOUS", facet, NULL, ridge, NULL);
  208. qh_option(qh, "_maxoutside", NULL, &qh->MAXoutside);
  209. qh_fprintf(qh, qh->ferr, 8127, "\nWhile executing: %s | %s\n", qh->rbox_command, qh->qhull_command);
  210. qh_fprintf(qh, qh->ferr, 8128, "Options selected for Qhull %s:\n%s\n", qh_version, qh->qhull_options);
  211. if (qh->furthest_id >= 0) {
  212. qh_fprintf(qh, qh->ferr, 8129, "Last point added to hull was p%d.", qh->furthest_id);
  213. if (zzval_(Ztotmerge))
  214. qh_fprintf(qh, qh->ferr, 8130, " Last merge was #%d.", zzval_(Ztotmerge));
  215. if (qh->QHULLfinished)
  216. qh_fprintf(qh, qh->ferr, 8131, "\nQhull has finished constructing the hull.");
  217. else if (qh->POSTmerging)
  218. qh_fprintf(qh, qh->ferr, 8132, "\nQhull has started post-merging.");
  219. qh_fprintf(qh, qh->ferr, 8133, "\n");
  220. }
  221. if (qh->FORCEoutput && (qh->QHULLfinished || (!facet && !ridge)))
  222. qh_produce_output(qh);
  223. else if (exitcode != qh_ERRinput) {
  224. if (exitcode != qh_ERRsingular && zzval_(Zsetplane) > qh->hull_dim+1) {
  225. qh_fprintf(qh, qh->ferr, 8134, "\nAt error exit:\n");
  226. qh_printsummary(qh, qh->ferr);
  227. if (qh->PRINTstatistics) {
  228. qh_collectstatistics(qh);
  229. qh_allstatistics(qh);
  230. qh_printstatistics(qh, qh->ferr, "at error exit");
  231. qh_memstatistics(qh, qh->ferr);
  232. }
  233. }
  234. if (qh->PRINTprecision)
  235. qh_printstats(qh, qh->ferr, qh->qhstat.precision, NULL);
  236. }
  237. if (!exitcode)
  238. exitcode= qh_ERRother;
  239. else if (exitcode == qh_ERRprec && !qh->PREmerge)
  240. qh_printhelp_degenerate(qh, qh->ferr);
  241. else if (exitcode == qh_ERRqhull)
  242. qh_printhelp_internal(qh, qh->ferr);
  243. else if (exitcode == qh_ERRsingular)
  244. qh_printhelp_singular(qh, qh->ferr);
  245. else if (exitcode == qh_ERRdebug)
  246. qh_fprintf(qh, qh->ferr, 8016, "qhull exit due to qh_ERRdebug\n");
  247. else if (exitcode == qh_ERRtopology || exitcode == qh_ERRwide || exitcode == qh_ERRprec) {
  248. if (qh->NOpremerge && !qh->MERGING)
  249. qh_printhelp_degenerate(qh, qh->ferr);
  250. else if (exitcode == qh_ERRtopology)
  251. qh_printhelp_topology(qh, qh->ferr);
  252. else if (exitcode == qh_ERRwide)
  253. qh_printhelp_wide(qh, qh->ferr);
  254. }else if (exitcode > 255) {
  255. qh_fprintf(qh, qh->ferr, 6426, "qhull internal error (qh_errexit): exit code %d is greater than 255. Invalid argument for exit(). Replaced with 255\n", exitcode);
  256. exitcode= 255;
  257. }
  258. if (qh->NOerrexit) {
  259. qh_fprintf(qh, qh->ferr, 6187, "qhull internal error (qh_errexit): either error while reporting error QH%d, or qh.NOerrexit not cleared after setjmp(). Exit program with error status %d\n",
  260. qh->last_errcode, exitcode);
  261. qh_exit(exitcode);
  262. }
  263. qh->ERREXITcalled= False;
  264. qh->NOerrexit= True;
  265. qh->ALLOWrestart= False; /* longjmp will undo qh_build_withrestart */
  266. longjmp(qh->errexit, exitcode);
  267. } /* errexit */
  268. /*-<a href="qh-user_r.htm#TOC"
  269. >-------------------------------</a><a name="errprint">-</a>
  270. qh_errprint(qh, fp, string, atfacet, otherfacet, atridge, atvertex )
  271. prints out the information of facets and ridges to fp
  272. also prints neighbors and geomview output
  273. notes:
  274. except for string, any parameter may be NULL
  275. */
  276. void qh_errprint(qhT *qh, const char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex) {
  277. int i;
  278. if (atvertex) {
  279. qh_fprintf(qh, qh->ferr, 8138, "%s VERTEX:\n", string);
  280. qh_printvertex(qh, qh->ferr, atvertex);
  281. }
  282. if (atridge) {
  283. qh_fprintf(qh, qh->ferr, 8137, "%s RIDGE:\n", string);
  284. qh_printridge(qh, qh->ferr, atridge);
  285. if (!atfacet)
  286. atfacet= atridge->top;
  287. if (!otherfacet)
  288. otherfacet= otherfacet_(atridge, atfacet);
  289. if (atridge->top && atridge->top != atfacet && atridge->top != otherfacet)
  290. qh_printfacet(qh, qh->ferr, atridge->top);
  291. if (atridge->bottom && atridge->bottom != atfacet && atridge->bottom != otherfacet)
  292. qh_printfacet(qh, qh->ferr, atridge->bottom);
  293. }
  294. if (atfacet) {
  295. qh_fprintf(qh, qh->ferr, 8135, "%s FACET:\n", string);
  296. qh_printfacet(qh, qh->ferr, atfacet);
  297. }
  298. if (otherfacet) {
  299. qh_fprintf(qh, qh->ferr, 8136, "%s OTHER FACET:\n", string);
  300. qh_printfacet(qh, qh->ferr, otherfacet);
  301. }
  302. if (qh->fout && qh->FORCEoutput && atfacet && !qh->QHULLfinished && !qh->IStracing) {
  303. qh_fprintf(qh, qh->ferr, 8139, "ERRONEOUS and NEIGHBORING FACETS to output\n");
  304. for (i=0; i < qh_PRINTEND; i++) /* use fout for geomview output */
  305. qh_printneighborhood(qh, qh->fout, qh->PRINTout[i], atfacet, otherfacet,
  306. !qh_ALL);
  307. }
  308. } /* errprint */
  309. /*-<a href="qh-user_r.htm#TOC"
  310. >-------------------------------</a><a name="printfacetlist">-</a>
  311. qh_printfacetlist(qh, fp, facetlist, facets, printall )
  312. print all fields for a facet list and/or set of facets to fp
  313. if !printall,
  314. only prints good facets
  315. notes:
  316. also prints all vertices
  317. */
  318. void qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall) {
  319. facetT *facet, **facetp;
  320. if (facetlist)
  321. qh_checklists(qh, facetlist);
  322. qh_fprintf(qh, qh->ferr, 9424, "printfacetlist: vertices\n");
  323. qh_printbegin(qh, qh->ferr, qh_PRINTfacets, facetlist, facets, printall);
  324. if (facetlist) {
  325. qh_fprintf(qh, qh->ferr, 9413, "printfacetlist: facetlist\n");
  326. FORALLfacet_(facetlist)
  327. qh_printafacet(qh, qh->ferr, qh_PRINTfacets, facet, printall);
  328. }
  329. if (facets) {
  330. qh_fprintf(qh, qh->ferr, 9414, "printfacetlist: %d facets\n", qh_setsize(qh, facets));
  331. FOREACHfacet_(facets)
  332. qh_printafacet(qh, qh->ferr, qh_PRINTfacets, facet, printall);
  333. }
  334. qh_fprintf(qh, qh->ferr, 9412, "printfacetlist: end\n");
  335. qh_printend(qh, qh->ferr, qh_PRINTfacets, facetlist, facets, printall);
  336. } /* printfacetlist */
  337. /*-<a href="qh-user_r.htm#TOC"
  338. >-------------------------------</a><a name="printhelp_degenerate">-</a>
  339. qh_printhelp_degenerate(qh, fp )
  340. prints descriptive message for precision error with qh_ERRprec
  341. notes:
  342. no message if qh_QUICKhelp
  343. */
  344. void qh_printhelp_degenerate(qhT *qh, FILE *fp) {
  345. if (qh->MERGEexact || qh->PREmerge || qh->JOGGLEmax < REALmax/2)
  346. qh_fprintf(qh, fp, 9368, "\n\
  347. A Qhull error has occurred. Qhull should have corrected the above\n\
  348. precision error. Please send the input and all of the output to\n\
  349. qhull_bug@qhull.org\n");
  350. else if (!qh_QUICKhelp) {
  351. qh_fprintf(qh, fp, 9369, "\n\
  352. Precision problems were detected during construction of the convex hull.\n\
  353. This occurs because convex hull algorithms assume that calculations are\n\
  354. exact, but floating-point arithmetic has roundoff errors.\n\
  355. \n\
  356. To correct for precision problems, do not use 'Q0'. By default, Qhull\n\
  357. selects 'C-0' or 'Qx' and merges non-convex facets. With option 'QJ',\n\
  358. Qhull joggles the input to prevent precision problems. See \"Imprecision\n\
  359. in Qhull\" (qh-impre.htm).\n\
  360. \n\
  361. If you use 'Q0', the output may include\n\
  362. coplanar ridges, concave ridges, and flipped facets. In 4-d and higher,\n\
  363. Qhull may produce a ridge with four neighbors or two facets with the same \n\
  364. vertices. Qhull reports these events when they occur. It stops when a\n\
  365. concave ridge, flipped facet, or duplicate facet occurs.\n");
  366. #if REALfloat
  367. qh_fprintf(qh, fp, 9370, "\
  368. \n\
  369. Qhull is currently using single precision arithmetic. The following\n\
  370. will probably remove the precision problems:\n\
  371. - recompile qhull for realT precision(#define REALfloat 0 in user_r.h).\n");
  372. #endif
  373. if (qh->DELAUNAY && !qh->SCALElast && qh->MAXabs_coord > 1e4)
  374. qh_fprintf(qh, fp, 9371, "\
  375. \n\
  376. When computing the Delaunay triangulation of coordinates > 1.0,\n\
  377. - use 'Qbb' to scale the last coordinate to [0,m] (max previous coordinate)\n");
  378. if (qh->DELAUNAY && !qh->ATinfinity)
  379. qh_fprintf(qh, fp, 9372, "\
  380. When computing the Delaunay triangulation:\n\
  381. - use 'Qz' to add a point at-infinity. This reduces precision problems.\n");
  382. qh_fprintf(qh, fp, 9373, "\
  383. \n\
  384. If you need triangular output:\n\
  385. - use option 'Qt' to triangulate the output\n\
  386. - use option 'QJ' to joggle the input points and remove precision errors\n\
  387. - use option 'Ft'. It triangulates non-simplicial facets with added points.\n\
  388. \n\
  389. If you must use 'Q0',\n\
  390. try one or more of the following options. They can not guarantee an output.\n\
  391. - use 'QbB' to scale the input to a cube.\n\
  392. - use 'Po' to produce output and prevent partitioning for flipped facets\n\
  393. - use 'V0' to set min. distance to visible facet as 0 instead of roundoff\n\
  394. - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
  395. - options 'Qf', 'Qbb', and 'QR0' may also help\n",
  396. qh->DISTround);
  397. qh_fprintf(qh, fp, 9374, "\
  398. \n\
  399. To guarantee simplicial output:\n\
  400. - use option 'Qt' to triangulate the output\n\
  401. - use option 'QJ' to joggle the input points and remove precision errors\n\
  402. - use option 'Ft' to triangulate the output by adding points\n\
  403. - use exact arithmetic (see \"Imprecision in Qhull\", qh-impre.htm)\n\
  404. ");
  405. }
  406. } /* printhelp_degenerate */
  407. /*-<a href="qh-user_r.htm#TOC"
  408. >-------------------------------</a><a name="printhelp_internal">-</a>
  409. qh_printhelp_internal(qh, fp )
  410. prints descriptive message for qhull internal error with qh_ERRqhull
  411. notes:
  412. no message if qh_QUICKhelp
  413. */
  414. void qh_printhelp_internal(qhT *qh, FILE *fp) {
  415. if (!qh_QUICKhelp) {
  416. qh_fprintf(qh, fp, 9426, "\n\
  417. A Qhull internal error has occurred. Please send the input and output to\n\
  418. qhull_bug@qhull.org. If you can duplicate the error with logging ('T4z'), please\n\
  419. include the log file.\n");
  420. }
  421. } /* printhelp_internal */
  422. /*-<a href="qh-user_r.htm#TOC"
  423. >-------------------------------</a><a name="printhelp_narrowhull">-</a>
  424. qh_printhelp_narrowhull(qh, minangle )
  425. Warn about a narrow hull
  426. notes:
  427. Alternatively, reduce qh_WARNnarrow in user_r.h
  428. */
  429. void qh_printhelp_narrowhull(qhT *qh, FILE *fp, realT minangle) {
  430. qh_fprintf(qh, fp, 7089, "qhull precision warning: The initial hull is narrow. Is the input lower\n\
  431. dimensional (e.g., a square in 3-d instead of a cube)? Cosine of the minimum\n\
  432. angle is %.16f. If so, Qhull may produce a wide facet.\n\
  433. Options 'Qs' (search all points), 'Qbb' (scale last coordinate), or\n\
  434. 'QbB' (scale to unit box) may remove this warning.\n\
  435. See 'Limitations' in qh-impre.htm. Use 'Pp' to skip this warning.\n",
  436. -minangle); /* convert from angle between normals to angle between facets */
  437. } /* printhelp_narrowhull */
  438. /*-<a href="qh-user_r.htm#TOC"
  439. >-------------------------------</a><a name="printhelp_singular">-</a>
  440. qh_printhelp_singular(qh, fp )
  441. prints descriptive message for singular input
  442. */
  443. void qh_printhelp_singular(qhT *qh, FILE *fp) {
  444. facetT *facet;
  445. vertexT *vertex, **vertexp;
  446. realT min, max, *coord, dist;
  447. int i,k;
  448. qh_fprintf(qh, fp, 9376, "\n\
  449. The input to qhull appears to be less than %d dimensional, or a\n\
  450. computation has overflowed.\n\n\
  451. Qhull could not construct a clearly convex simplex from points:\n",
  452. qh->hull_dim);
  453. qh_printvertexlist(qh, fp, "", qh->facet_list, NULL, qh_ALL);
  454. if (!qh_QUICKhelp)
  455. qh_fprintf(qh, fp, 9377, "\n\
  456. The center point is coplanar with a facet, or a vertex is coplanar\n\
  457. with a neighboring facet. The maximum round off error for\n\
  458. computing distances is %2.2g. The center point, facets and distances\n\
  459. to the center point are as follows:\n\n", qh->DISTround);
  460. qh_printpointid(qh, fp, "center point", qh->hull_dim, qh->interior_point, qh_IDunknown);
  461. qh_fprintf(qh, fp, 9378, "\n");
  462. FORALLfacets {
  463. qh_fprintf(qh, fp, 9379, "facet");
  464. FOREACHvertex_(facet->vertices)
  465. qh_fprintf(qh, fp, 9380, " p%d", qh_pointid(qh, vertex->point));
  466. zinc_(Zdistio);
  467. qh_distplane(qh, qh->interior_point, facet, &dist);
  468. qh_fprintf(qh, fp, 9381, " distance= %4.2g\n", dist);
  469. }
  470. if (!qh_QUICKhelp) {
  471. if (qh->HALFspace)
  472. qh_fprintf(qh, fp, 9382, "\n\
  473. These points are the dual of the given halfspaces. They indicate that\n\
  474. the intersection is degenerate.\n");
  475. qh_fprintf(qh, fp, 9383,"\n\
  476. These points either have a maximum or minimum x-coordinate, or\n\
  477. they maximize the determinant for k coordinates. Trial points\n\
  478. are first selected from points that maximize a coordinate.\n");
  479. if (qh->hull_dim >= qh_INITIALmax)
  480. qh_fprintf(qh, fp, 9384, "\n\
  481. Because of the high dimension, the min x-coordinate and max-coordinate\n\
  482. points are used if the determinant is non-zero. Option 'Qs' will\n\
  483. do a better, though much slower, job. Instead of 'Qs', you can change\n\
  484. the points by randomly rotating the input with 'QR0'.\n");
  485. }
  486. qh_fprintf(qh, fp, 9385, "\nThe min and max coordinates for each dimension are:\n");
  487. for (k=0; k < qh->hull_dim; k++) {
  488. min= REALmax;
  489. max= -REALmin;
  490. for (i=qh->num_points, coord= qh->first_point+k; i--; coord += qh->hull_dim) {
  491. maximize_(max, *coord);
  492. minimize_(min, *coord);
  493. }
  494. qh_fprintf(qh, fp, 9386, " %d: %8.4g %8.4g difference= %4.4g\n", k, min, max, max-min);
  495. }
  496. if (!qh_QUICKhelp) {
  497. qh_fprintf(qh, fp, 9387, "\n\
  498. If the input should be full dimensional, you have several options that\n\
  499. may determine an initial simplex:\n\
  500. - use 'QJ' to joggle the input and make it full dimensional\n\
  501. - use 'QbB' to scale the points to the unit cube\n\
  502. - use 'QR0' to randomly rotate the input for different maximum points\n\
  503. - use 'Qs' to search all points for the initial simplex\n\
  504. - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
  505. - trace execution with 'T3' to see the determinant for each point.\n",
  506. qh->DISTround);
  507. #if REALfloat
  508. qh_fprintf(qh, fp, 9388, "\
  509. - recompile qhull for realT precision(#define REALfloat 0 in libqhull_r.h).\n");
  510. #endif
  511. qh_fprintf(qh, fp, 9389, "\n\
  512. If the input is lower dimensional:\n\
  513. - use 'QJ' to joggle the input and make it full dimensional\n\
  514. - use 'Qbk:0Bk:0' to delete coordinate k from the input. You should\n\
  515. pick the coordinate with the least range. The hull will have the\n\
  516. correct topology.\n\
  517. - determine the flat containing the points, rotate the points\n\
  518. into a coordinate plane, and delete the other coordinates.\n\
  519. - add one or more points to make the input full dimensional.\n\
  520. ");
  521. }
  522. } /* printhelp_singular */
  523. /*-<a href="qh-user_r.htm#TOC"
  524. >-------------------------------</a><a name="printhelp_topology">-</a>
  525. qh_printhelp_topology(qh, fp )
  526. prints descriptive message for qhull topology error with qh_ERRtopology
  527. notes:
  528. no message if qh_QUICKhelp
  529. */
  530. void qh_printhelp_topology(qhT *qh, FILE *fp) {
  531. if (!qh_QUICKhelp) {
  532. qh_fprintf(qh, fp, 9427, "\n\
  533. A Qhull topology error has occurred. Qhull did not recover from facet merges and vertex merges.\n\
  534. This usually occurs when the input is nearly degenerate and substantial merging has occurred.\n\
  535. See http://www.qhull.org/html/qh-impre.htm#limit\n");
  536. }
  537. } /* printhelp_topology */
  538. /*-<a href="qh-user_r.htm#TOC"
  539. >-------------------------------</a><a name="printhelp_wide">-</a>
  540. qh_printhelp_wide(qh, fp )
  541. prints descriptive message for qhull wide facet with qh_ERRwide
  542. notes:
  543. no message if qh_QUICKhelp
  544. */
  545. void qh_printhelp_wide(qhT *qh, FILE *fp) {
  546. if (!qh_QUICKhelp) {
  547. qh_fprintf(qh, fp, 9428, "\n\
  548. A wide merge error has occurred. Qhull has produced a wide facet due to facet merges and vertex merges.\n\
  549. This usually occurs when the input is nearly degenerate and substantial merging has occurred.\n\
  550. See http://www.qhull.org/html/qh-impre.htm#limit\n");
  551. }
  552. } /* printhelp_wide */
  553. /*-<a href="qh-user_r.htm#TOC"
  554. >-------------------------------</a><a name="user_memsizes">-</a>
  555. qh_user_memsizes(qh)
  556. allocate up to 10 additional, quick allocation sizes
  557. notes:
  558. increase maximum number of allocations in qh_initqhull_mem()
  559. */
  560. void qh_user_memsizes(qhT *qh) {
  561. QHULL_UNUSED(qh)
  562. /* qh_memsize(qh, size); */
  563. } /* user_memsizes */