001-qh-new-qhull-feaspoint.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --- contrib/libs/qhull/libqhull_r/user_r.c (index)
  2. +++ contrib/libs/qhull/libqhull_r/user_r.c (working tree)
  3. @@ -123,6 +123,12 @@
  4. */
  5. int qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  6. char *qhull_cmd, FILE *outfile, FILE *errfile) {
  7. + return qh_new_qhull_feaspoint(qh, dim, numpoints, points, ismalloc,
  8. + qhull_cmd, outfile, errfile, NULL);
  9. +}
  10. +
  11. +int qh_new_qhull_feaspoint(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  12. + char *qhull_cmd, FILE *outfile, FILE *errfile, coordT* feaspoint) {
  13. /* gcc may issue a "might be clobbered" warning for dim, points, and ismalloc [-Wclobbered].
  14. These parameters are not referenced after a longjmp() and hence not clobbered.
  15. See http://stackoverflow.com/questions/7721854/what-sense-do-these-clobbered-variable-warnings-make */
  16. @@ -158,7 +164,24 @@ int qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc
  17. /* points is an array of halfspaces,
  18. the last coordinate of each halfspace is its offset */
  19. hulldim= dim-1;
  20. - qh_setfeasible(qh, hulldim);
  21. + if(feaspoint)
  22. + {
  23. + if (!(qh->feasible_point= (pointT*)qh_malloc(hulldim * sizeof(coordT)))) {
  24. + qh_fprintf(qh, qh->ferr, 6079, "qhull error: insufficient memory for 'Hn,n,n'\n");
  25. + qh_errexit(qh, qh_ERRmem, NULL, NULL);
  26. + }
  27. + coordT* coords = qh->feasible_point;
  28. + coordT* value = feaspoint;
  29. + int i;
  30. + for(i = 0; i < hulldim; ++i)
  31. + {
  32. + *(coords++) = *(value++);
  33. + }
  34. + }
  35. + else
  36. + {
  37. + qh_setfeasible(qh, hulldim);
  38. + }
  39. new_points= qh_sethalfspace_all(qh, dim, numpoints, points, qh->feasible_point);
  40. new_ismalloc= True;
  41. if (ismalloc)
  42. --- contrib/libs/qhull/libqhull_r/libqhull_r.h (index)
  43. +++ contrib/libs/qhull/libqhull_r/libqhull_r.h (working tree)
  44. @@ -1029,6 +1029,8 @@ void qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge);
  45. void qh_errprint(qhT *qh, const char* string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex);
  46. int qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  47. char *qhull_cmd, FILE *outfile, FILE *errfile);
  48. +int qh_new_qhull_feaspoint(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
  49. + char *qhull_cmd, FILE *outfile, FILE *errfile, coordT* feaspoint);
  50. void qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall);
  51. void qh_printhelp_degenerate(qhT *qh, FILE *fp);
  52. void qh_printhelp_internal(qhT *qh, FILE *fp);