set flags and initialized constants from commandStr
calls qh_exit() if qh->NOerrexit
returns:
sets qh.qhull_command to command if needed
notes:
ignores first word (e.g., "qhull d")
use qh_strtol/strtod since strtol/strtod may or may not skip trailing spaces
see:
qh_initthresholds() continues processing of 'Pdn' and 'PDn'
'prompt' in unix_r.c for documentation
design:
for each space-delimited option group
if top-level option
check syntax
append appropriate option to option string
set appropriate global variable or append printFormat to print options
else
for each sub-option
check syntax
append appropriate option to option string
set appropriate global variable or append printFormat to print options
*/
void qh_initflags(qhT *qh, char *command) {
int k, i, lastproject;
char *s= command, *t, *prev_s, *start, key;
boolT isgeom= False, wasproject;
realT r;
if(qh->NOerrexit){
qh_fprintf(qh, qh->ferr, 6245, "qhull initflags error: qh.NOerrexit was not cleared before calling qh_initflags(). It should be cleared after setjmp(). Exit qhull.");
qh_fprintf(qh, qh->ferr, 6266, "qhull input warning: qh.fout was not set by caller. Cannot use option 'TO' to redirect output. Ignoring option 'TO'\n");
}else if (!freopen(filename, "w", qh->fout)) {
qh_fprintf(qh, qh->ferr, 6044, "qhull error: could not open file \"%s\".", filename);
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}else {
qh_option(qh, "TOutput-file", NULL, NULL);
qh_option(qh, filename, NULL, NULL);
}
}
break;
case 'P':
if (!isdigit(*s))
qh_fprintf(qh, qh->ferr, 7029, "qhull warning: missing point id for trace option 'TPn'. Ignored\n");
if (qh->MERGING && !qh->POSTmerge && qh->premerge_cos > REALmax/2
&& qh->premerge_centrum == 0) {
qh->ZEROcentrum= True;
qh->ZEROall_ok= True;
qh_option(qh, "_zero-centrum", NULL, NULL);
}
if (qh->JOGGLEmax < REALmax/2 && REALepsilon > 2e-8 && qh->PRINTprecision)
qh_fprintf(qh, qh->ferr, 7039, "qhull warning: real epsilon, %2.2g, is probably too large for joggle('QJn')\nRecompile with double precision reals(see user.h).\n",
REALepsilon);
#ifdef qh_NOmerge
if (qh->MERGING) {
qh_fprintf(qh, qh->ferr, 6045, "qhull input error: merging not installed(qh_NOmerge + 'Qx', 'Cn' or 'An')\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
#endif
if (qh->DELAUNAY && qh->KEEPcoplanar && !qh->KEEPinside) {
qh->KEEPinside= True;
qh_option(qh, "Qinterior-keep", NULL, NULL);
}
if (qh->DELAUNAY && qh->HALFspace) {
qh_fprintf(qh, qh->ferr, 6046, "qhull input error: can not use Delaunay('d') or Voronoi('v') with halfspace intersection('H')\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
if (!qh->DELAUNAY && (qh->UPPERdelaunay || qh->ATinfinity)) {
qh_fprintf(qh, qh->ferr, 6047, "qhull input error: use upper-Delaunay('Qu') or infinity-point('Qz') with Delaunay('d') or Voronoi('v')\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
if (qh->UPPERdelaunay && qh->ATinfinity) {
qh_fprintf(qh, qh->ferr, 6048, "qhull input error: can not use infinity-point('Qz') with upper-Delaunay('Qu')\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
if (qh->SCALElast && !qh->DELAUNAY && qh->PRINTprecision)
qh_fprintf(qh, qh->ferr, 7040, "qhull input warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
else if (qh->PRINTout[i] == qh_PRINTmathematica || qh->PRINTout[i] == qh_PRINTmaple)
printmath= True;
else if (qh->PRINTout[i] == qh_PRINTcoplanars)
printcoplanar= True;
else if (qh->PRINTout[i] == qh_PRINTpointnearest)
printcoplanar= True;
else if (qh->PRINTout[i] == qh_PRINTpointintersect && !qh->HALFspace) {
qh_fprintf(qh, qh->ferr, 6053, "qhull input error: option 'Fp' is only used for \nhalfspace intersection('Hn,n,n').\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}else if (qh->PRINTout[i] == qh_PRINTtriangles && (qh->HALFspace || qh->VORONOI)) {
qh_fprintf(qh, qh->ferr, 6054, "qhull input error: option 'Ft' is not available for Voronoi vertices or halfspace intersection\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}else if (qh->PRINTout[i] == qh_PRINTcentrums && qh->VORONOI) {
qh_fprintf(qh, qh->ferr, 6055, "qhull input error: option 'FC' is not available for Voronoi vertices('v')\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}else if (qh->PRINTout[i] == qh_PRINTvertices) {
if (qh->VORONOI)
qh_option(qh, "Fvoronoi", NULL, NULL);
else
qh_option(qh, "Fvertices", NULL, NULL);
}
}
if (printcoplanar && qh->DELAUNAY && qh->JOGGLEmax < REALmax/2) {
if (qh->PRINTprecision)
qh_fprintf(qh, qh->ferr, 7041, "qhull input warning: 'QJ' (joggle) will usually prevent coincident input sites for options 'Fc' and 'FP'\n");
}
if (printmath && (qh->hull_dim > 3 || qh->VORONOI)) {
qh_fprintf(qh, qh->ferr, 6056, "qhull input error: Mathematica and Maple output is only available for 2-d and 3-d convex hulls and 2-d Delaunay triangulations\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
if (printgeom) {
if (qh->hull_dim > 4) {
qh_fprintf(qh, qh->ferr, 6057, "qhull input error: Geomview output is only available for 2-d, 3-d and 4-d\n");
qh_errexit(qh, qh_ERRinput, NULL, NULL);
}
if (qh->PRINTnoplanes && !(qh->PRINTcoplanar + qh->PRINTcentrums
Report error if library does not agree with caller
notes:
NOerrors -- qh_lib_check can not call qh_errexit()
*/
void qh_lib_check(int qhullLibraryType, int qhTsize, int vertexTsize, int ridgeTsize, int facetTsize, int setTsize, int qhmemTsize) {
boolT iserror= False;
if (qhullLibraryType==QHULL_NON_REENTRANT) { /* 0 */
qh_fprintf_stderr(6257, "qh_lib_check: Incorrect qhull library called. Caller uses non-reentrant Qhull with a static qhT. Library is reentrant.\n");
iserror= True;
}else if (qhullLibraryType==QHULL_QH_POINTER) { /* 1 */
qh_fprintf_stderr(6258, "qh_lib_check: Incorrect qhull library called. Caller uses non-reentrant Qhull with a dynamic qhT via qh_QHpointer. Library is reentrant.\n");
iserror= True;
}else if (qhullLibraryType!=QHULL_REENTRANT) { /* 2 */
qh_fprintf_stderr(6249, "qh_lib_check: Incorrect qhull library called. Size of qhT for caller is %d, but for library is %d.\n", qhTsize, sizeof(qhT));
iserror= True;
}
if (vertexTsize != sizeof(vertexT)) {
qh_fprintf_stderr(6250, "qh_lib_check: Incorrect qhull library called. Size of vertexT for caller is %d, but for library is %d.\n", vertexTsize, sizeof(vertexT));
iserror= True;
}
if (ridgeTsize != sizeof(ridgeT)) {
qh_fprintf_stderr(6251, "qh_lib_check: Incorrect qhull library called. Size of ridgeT for caller is %d, but for library is %d.\n", ridgeTsize, sizeof(ridgeT));
iserror= True;
}
if (facetTsize != sizeof(facetT)) {
qh_fprintf_stderr(6252, "qh_lib_check: Incorrect qhull library called. Size of facetT for caller is %d, but for library is %d.\n", facetTsize, sizeof(facetT));
iserror= True;
}
if (setTsize && setTsize != sizeof(setT)) {
qh_fprintf_stderr(6253, "qh_lib_check: Incorrect qhull library called. Size of setT for caller is %d, but for library is %d.\n", setTsize, sizeof(setT));
iserror= True;
}
if (qhmemTsize && qhmemTsize != sizeof(qhmemT)) {
qh_fprintf_stderr(6254, "qh_lib_check: Incorrect qhull library called. Size of qhmemT for caller is %d, but for library is %d.\n", qhmemTsize, sizeof(qhmemT));