📄 qhull_global.cxx
字号:
qh NOpremerge= True;
break;
case '1':
qh_option ("Q1-no-angle-sort", NULL, NULL);
qh ANGLEmerge= False;
goto LABELcheckdigit;
break; /* no warnings */
case '2':
qh_option ("Q2-no-merge-independent", NULL, NULL);
qh MERGEindependent= False;
goto LABELcheckdigit;
break; /* no warnings */
case '3':
qh_option ("Q3-no-merge-vertices", NULL, NULL);
qh MERGEvertices= False;
LABELcheckdigit:
if (isdigit(*s))
ivp_message( "qhull warning: can not follow '1', '2', or '3' with a digit. '%c' skipped.\n",
*s++);
break;
case '4':
qh_option ("Q4-avoid-old-into-new", NULL, NULL);
qh AVOIDold= True;
break;
case '5':
qh_option ("Q5-no-check-outer", NULL, NULL);
qh SKIPcheckmax= True;
break;
case '6':
qh_option ("Q6-no-concave-merge", NULL, NULL);
qh SKIPconvex= True;
break;
case '7':
qh_option ("Q7-no-breadth-first", NULL, NULL);
qh VIRTUALmemory= True;
break;
case '8':
qh_option ("Q8-no-near-inside", NULL, NULL);
qh NOnearinside= True;
break;
case '9':
qh_option ("Q9-pick-furthest", NULL, NULL);
qh PICKfurthest= True;
break;
case 'G':
i= qh_strtol (s, &t);
if (qh GOODpoint)
ivp_message( "qhull warning: good point already defined for option 'QGn'. Ignored\n");
else if (s == t)
ivp_message( "qhull warning: missing good point id for option 'QGn'. Ignored\n");
else if (i < 0 || *s == '-') {
qh GOODpoint= i-1;
qh_option ("QGood-if-dont-see-point", &i, NULL);
}else {
qh GOODpoint= i+1;
qh_option ("QGood-if-see-point", &i, NULL);
}
s= t;
break;
case 'J':
if (!isdigit(*s) && *s != '-')
qh JOGGLEmax= 0.0;
else {
qh JOGGLEmax= (realT) qh_strtod (s, &s);
qh_option ("QJoggle", NULL, &qh JOGGLEmax);
}
break;
case 'R':
if (!isdigit(*s) && *s != '-')
ivp_message( "qhull warning: missing random seed for option 'QRn'. Ignored\n");
else {
qh ROTATErandom= i= qh_strtol(s, &s);
if (i > 0)
qh_option ("QRotate-id", &i, NULL );
else if (i < -1)
qh_option ("QRandom-seed", &i, NULL );
}
break;
case 'V':
i= qh_strtol (s, &t);
if (qh GOODvertex)
ivp_message( "qhull warning: good vertex already defined for option 'QVn'. Ignored\n");
else if (s == t)
ivp_message( "qhull warning: no good point id given for option 'QVn'. Ignored\n");
else if (i < 0) {
qh GOODvertex= i - 1;
qh_option ("QV-good-facets-not-point", &i, NULL);
}else {
qh_option ("QV-good-facets-point", &i, NULL);
qh GOODvertex= i + 1;
}
s= t;
break;
default:
s--;
ivp_message( "qhull warning: unknown 'Q' qhull option %c, rest ignored\n", (int)s[0]);
while (*++s && !isspace(*s));
break;
}
}
break;
case 'T':
while (*s && !isspace(*s)) {
if (isdigit(*s) || *s == '-')
qh IStracing= qh_strtol(s, &s);
else switch(*s++) {
case 'c':
qh_option ("Tcheck-frequently", NULL, NULL);
qh CHECKfrequently= True;
break;
case 's':
qh_option ("Tstatistics", NULL, NULL);
qh PRINTstatistics= True;
break;
case 'v':
qh_option ("Tverify", NULL, NULL);
qh VERIFYoutput= True;
break;
case 'z':
if (!qh fout)
ivp_message( "qhull warning: output file undefined (stdout). Option 'Tz' ignored.\n");
else {
qh_option ("Tz-stdout", NULL, NULL);
qh ferr= qh fout;
qhmem.ferr= qh fout;
}
break;
case 'C':
if (!isdigit(*s))
ivp_message( "qhull warning: missing point id for cone for trace option 'TCn'. Ignored\n");
else {
i= qh_strtol (s, &s);
qh_option ("TCone-stop", &i, NULL);
qh STOPcone= i + 1;
}
break;
case 'F':
if (!isdigit(*s))
ivp_message( "qhull warning: missing frequency count for trace option 'TFn'. Ignored\n");
else {
qh REPORTfreq= qh_strtol (s, &s);
qh_option ("TFacet-log", &qh REPORTfreq, NULL);
qh REPORTfreq2= qh REPORTfreq/2; /* for tracemerging() */
}
break;
case 'O':
if (s[0] != ' ' || s[1] == '\"' || isspace (s[1])) {
s++;
ivp_message( "qhull warning: option 'TO' mistyped.\nUse 'TO', one space, file name, and space or end-of-line.\nThe file name may be enclosed in single quotes.\nDo not use double quotes. Option 'FO' ignored.\n");
}else { /* not a procedure because of qh_option (filename, NULL, NULL); */
char filename[500], *t= filename;
boolT isquote= False;
s++;
if (*s == '\'') {
isquote= True;
s++;
}
while (*s) {
if (t - filename >= (int)(sizeof (filename)-2)) {
ivp_message( "qhull error: filename for 'TO' too long.\n");
qh_errexit (qh_ERRinput, NULL, NULL);
}
if (isquote) {
if (*s == '\'') {
s++;
isquote= False;
break;
}
}else if (isspace (*s))
break;
*(t++)= *s++;
}
*t= '\0';
#if defined(PSXII) || defined(GEKKO)
#else
if (isquote)
ivp_message( "qhull error: missing end quote for option 'TO'. Rest of line ignored.\n");
else if (!freopen (filename, "w", 0 /*stdout*/)) {
ivp_message( "qhull error: could not open file \"%s\".", filename);
qh_errexit (qh_ERRinput, NULL, NULL);
}else {
qh_option ("TOutput-file", NULL, NULL);
qh_option (filename, NULL, NULL);
}
#endif
}
break;
case 'P':
if (!isdigit(*s))
ivp_message( "qhull warning: missing point id for trace option 'TPn'. Ignored\n");
else {
qh TRACEpoint= qh_strtol (s, &s);
qh_option ("Trace-point", &qh TRACEpoint, NULL);
}
break;
case 'M':
if (!isdigit(*s))
ivp_message( "qhull warning: missing merge id for trace option 'TMn'. Ignored\n");
else {
qh TRACEmerge= qh_strtol (s, &s);
qh_option ("Trace-merge", &qh TRACEmerge, NULL);
}
break;
case 'R':
if (!isdigit(*s))
ivp_message( "qhull warning: missing rerun count for trace option 'TRn'. Ignored\n");
else {
qh RERUN= qh_strtol (s, &s);
qh_option ("TRerun", &qh RERUN, NULL);
}
break;
case 'V':
i= qh_strtol (s, &t);
if (s == t)
ivp_message( "qhull warning: missing furthest point id for trace option 'TVn'. Ignored\n");
else if (i < 0) {
qh STOPpoint= i - 1;
qh_option ("TV-stop-before-point", &i, NULL);
}else {
qh STOPpoint= i + 1;
qh_option ("TV-stop-after-point", &i, NULL);
}
s= t;
break;
case 'W':
if (!isdigit(*s))
ivp_message( "qhull warning: missing max width for trace option 'TWn'. Ignored\n");
else {
qh TRACEdist= (realT) qh_strtod (s, &s);
qh_option ("TWide-trace", NULL, &qh TRACEdist);
}
break;
default:
s--;
ivp_message( "qhull warning: unknown 'T' trace option %c, rest ignored\n", (int)s[0]);
while (*++s && !isspace(*s));
break;
}
}
break;
default:
ivp_message( "qhull warning: unknown flag %c (%x)\n", (int)s[-1],
(int)s[-1]);
break;
}
if (s-1 == prev_s && *s && !isspace(*s)) {
ivp_message( "qhull warning: missing space after flag %c (%x); reserved for menu. Skipped.\n",
(int)*prev_s, (int)*prev_s);
while (*s && !isspace(*s))
s++;
}
}
if (isgeom && !qh FORCEoutput && qh PRINTout[1])
ivp_message( "qhull warning: additional output formats are not compatible with Geomview\n");
/* set derived values in qh_initqhull_globals */
} /* initflags */
/*-<a href="qh-c.htm#global"
>-------------------------------</a><a name="initqhull_buffers">-</a>
qh_initqhull_buffers()
initialize global memory buffers
notes:
must match qh_freebuffers()
*/
void qh_initqhull_buffers (void) {
int k;
qh TEMPsize= (qhmem.LASTsize - sizeof (setT))/SETelemsize;
if (qh TEMPsize <= 0 || qh TEMPsize > qhmem.LASTsize)
qh TEMPsize= 8; /* e.g., if qh_NOmem */
qh other_points= qh_setnew (qh TEMPsize);
qh del_vertices= qh_setnew (qh TEMPsize);
qh searchset= qh_setnew (qh TEMPsize);
qh NEARzero= (realT *)qh_memalloc(qh hull_dim * sizeof(realT));
qh lower_threshold= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
qh upper_threshold= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
qh lower_bound= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
qh upper_bound= (realT *)qh_memalloc((qh input_dim+1) * sizeof(realT));
for(k= qh input_dim+1; k--; ) {
qh lower_threshold[k]= -REALmax;
qh upper_threshold[k]= REALmax;
qh lower_bound[k]= -REALmax;
qh upper_bound[k]= REALmax;
}
qh gm_matrix= (coordT *)qh_memalloc((qh hull_dim+1) * qh hull_dim * sizeof(coordT));
qh gm_row= (coordT **)qh_memalloc((qh hull_dim+1) * sizeof(coordT *));
} /* initqhull_buffers */
/*-<a href="qh-c.htm#global"
>-------------------------------</a><a name="initqhull_globals">-</a>
qh_initqhull_globals( points, numpoints, dim, ismalloc )
initialize globals
if ismalloc
points were malloc'd and qhull should free at end
returns:
sets qh.first_point, num_points, input_dim, hull_dim and others
seeds random number generator (seed=1 if tracing)
modifies qh.hull_dim if ((qh.DELAUNAY and qh.PROJECTdelaunay) or qh.PROJECTinput)
adjust user flags as needed
also checks DIM3 dependencies and constants
notes:
do not use qh_point() since an input transformation may move them elsewhere
see:
qh_initqhull_start() sets default values for non-zero globals
design:
initialize points array from input arguments
test for qh.ZEROcentrum
(i.e., use opposite vertex instead of cetrum for convexity testing)
test for qh.PRINTgood (i.e., only print 'good' facets)
initialize qh.CENTERtype, qh.normal_size,
qh.center_size, qh.TRACEpoint/level,
initialize and test random numbers
check for conflicting print output options
*/
void qh_initqhull_globals (coordT *points, int numpoints, int dim, boolT ismalloc) {
int seed, pointsneeded, extra= 0, i, randi, k;
boolT printgeom= False, printmath= False, printcoplanar= False;
realT randr;
realT factorial;
#if !defined(PSXII) && !defined(GEKKO)
time_t timedata;
#endif
trace0((qh ferr, "qh_initqhull_globals: for %s | %s\n", qh rbox_command,
qh qhull_command));
qh POINTSmalloc= ismalloc;
qh first_point= points;
qh num_points= numpoints;
qh hull_dim= qh input_dim= dim;
if (!qh NOpremerge && !qh MERGEexact && !qh PREmerge && qh JOGGLEmax > REALmax/2) {
qh MERGING= True;
if (qh hull_dim <= 4) {
qh PREmerge= True;
qh_option ("_pre-merge", NULL, NULL);
}else {
qh MERGEexact= True;
qh_option ("_merge-exact", NULL, NULL);
}
}
if (!qh NOpremerge && qh JOGGLEmax > REALmax/2) {
#ifdef qh_NOmerge
qh JOGGLEmax= 0.0;
#endif
}
if (qh JOGGLEmax < REALmax/2 && qh DELAUNAY && !qh SCALEinput && !qh SCALElast) {
qh SCALElast= True;
qh_option ("Qbbound-last-qj", NULL, NULL);
}
if (qh MERGING && !qh POSTmerge && qh premerge_cos > REALmax/2
&& qh premerge_centrum == 0) {
qh ZEROcentrum= True;
qh ZEROall_ok= True;
qh_option ("_zero-centrum", NULL, NULL);
}
if (qh JOGGLEmax < REALmax/2 && REALepsilon > 2e-8 && qh PRINTprecision)
fprintf(qh ferr, "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) {
ivp_message( "qhull input error: merging not installed (qh_NOmerge + 'Qx', 'Cn' or 'An')\n");
qh_errexit (qh_ERRinput, NULL, NULL);
}
#endif
if ((qh KEEParea || qh KEEPminArea < REALmax/2 || qh KEEPmerge || qh DELAUNAY)
&& !(qh PRINTgood || qh PRINTneighbors)) {
qh PRINTgood= True;
qh_option ("Pgood", NULL, NULL);
}
if (qh DELAUNAY && qh KEEPcoplanar && !qh KEEPinside) {
qh KEEPinside= True;
qh_option ("Qinterior-keep", NULL, NULL);
}
if (qh DELAUNAY && qh HALFspace) {
ivp_message( "qhull input error: can not use Delaunay ('d') or Voronoi ('v') with halfspace intersection ('H')\n");
qh_errexit (qh_ERRinput, NULL, NULL);
}
if (!qh DELAUNAY && (qh UPPERdelaunay || qh ATinfinity)) {
ivp_message( "qhull input error: use upper-Delaunay ('Qu') or infinity-point ('Qz') with Delaunay ('d') or Voronoi ('v')\n");
qh_errexit (qh_ERRinput, NULL, NULL);
}
if (qh UPPERdelaunay && qh ATinfinity) {
ivp_message( "qhull input error: can not use infinity-point ('Qz') with upper-Delaunay ('Qu')\n");
qh_errexit (qh_ERRinput, NULL, NULL);
}
if (qh SCALElast && !qh DELAUNAY)
ivp_message( "qhull input warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
qh DOcheckmax= (!qh FORCEoutput && !qh SKIPcheckmax && qh MERGING );
qh KEEPnearinside= (qh DOcheckmax && !(qh KEEPinside && qh KEEPcoplanar)
&& !qh NOnearinside);
if (qh MERGING)
qh CENTERtype= qh_AScentrum;
else if (qh VORONOI)
qh CENTERtype= qh_ASvoronoi;
if (qh TESTvneighbors && !qh MERGING) {
fprintf(qh ferr, "qhull input error: test vertex neighbors ('Qv') needs a merge option\n");
qh_errexit (qh_ERRinput, NULL ,NULL);
}
if (qh PROJECTinput || (qh DELAUNAY && qh PROJECTdelaunay)) {
qh hull_dim -= qh PROJECTinput;
if (qh DELAUNAY) {
qh hull_dim++;
extra= 1;
}
}
if (qh hull_dim <= 1) {
fprintf(qh ferr, "qhull error: dimension %d must be > 1\n", qh hull_dim);
qh_errexit (qh_ERRinput, NULL, NULL);
}
for (k= 2, factorial=1.0; k < qh hull_dim; k++)
factorial *= k;
qh AREAfactor= 1.0 / factorial;
trace2((qh ferr, "qh_initqhull_globals: initialize globals. dim %d numpoints %d malloc? %d projected %d to hull_dim %d\n",
dim, numpoints, ismalloc, qh PROJECTinput, qh hull_dim));
qh normal_size= qh hull_dim * sizeof(coordT);
qh center_size= qh normal_size - sizeof(coordT);
pointsneeded= qh hull_dim+1;
if (qh hull_dim > qh_DIMmergeVertex) {
qh MERGEvertices= False;
qh_option ("Q3-no-merge-vertices-dim-high", NULL, NULL);
}
if (qh GOODpoint)
pointsneeded++;
#ifdef qh_NOtrace
if (qh IStracing) {
ivp_message( "qhull input error: tracing is not installed (qh_NOtrace in user.h)");
qh_errexit (qh_ERRqhull, NULL, NULL);
}
#endif
if (qh RERUN > 1) {
qh TRACElastrun= qh IStracing; /* qh_build_withrestart duplicates next conditional */
if (qh IStracing != -1)
qh IStracing= 0;
}else if (qh TRACEpoint != -1 || qh TRACEdist < REALmax/2 || qh TRACEmerge) {
qh TRACElevel= (qh IStracing? qh IStracing : 3);
qh IStracing= 0;
}
if (qh ROTATErandom == 0 || qh ROTATErandom == -1) {
#if !defined(PSXII) && !defined(GEKKO)
seed= time (&timedata);
#endif
if (qh ROTATErandom == -1) {
seed= -seed;
qh_option ("QRandom-seed", &seed, NULL );
}else
qh_option ("QRotate-random", &seed, NULL);
qh ROTATErandom= seed;
}
seed= qh ROTATErandom;
if (seed == INT_MIN) /* default value */
seed= 1;
else if (seed < 0)
seed= -seed;
qh_RANDOMseed_(seed);
randr= 0.0;
for (i= 1000; i--; ) {
randi= qh_RANDOMint;
randr += randi;
if (randi > qh_RANDOMmax) {
ivp_message( "\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -