1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
|
/*<html><pre> -<a href="qh-stat_r.htm"
>-------------------------------</a><a name="TOP">-</a>
stat_r.h
contains all statistics that are collected for qhull
see qh-stat_r.htm and stat_r.c
Copyright (c) 1993-2020 The Geometry Center.
$Id: //main/2019/qhull/src/libqhull_r/stat_r.h#4 $$Change: 2953 $
$DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
recompile qhull if you change this file
Integer statistics are Z* while real statistics are W*.
define MAYdebugx to call a routine at every statistic event
*/
#ifndef qhDEFstat
#define qhDEFstat 1
/* Depends on realT. Do not include "libqhull_r" to avoid circular dependency */
#ifndef DEFqhT
#define DEFqhT 1
typedef struct qhT qhT; /* Defined by libqhull_r.h */
#endif
#ifndef DEFqhstatT
#define DEFqhstatT 1
typedef struct qhstatT qhstatT; /* Defined here */
#endif
/*-<a href="qh-stat_r.htm#TOC"
>-------------------------------</a><a name="KEEPstatistics">-</a>
qh_KEEPstatistics
0 turns off statistic reporting and gathering (except zzdef/zzinc/zzadd/zzval/wwval)
set qh_KEEPstatistics in user_r.h to 0 to turn off statistics
*/
#ifndef qh_KEEPstatistics
#define qh_KEEPstatistics 1
#endif
/*-<a href="qh-stat_r.htm#TOC"
>-------------------------------</a><a name="statistics">-</a>
Zxxx for integers, Wxxx for reals
notes:
be sure that all statistics are defined in stat_r.c
otherwise initialization may core dump
can pick up all statistics by:
grep '[zw].*_[(][ZW]' *.c >z.x
remove trailers with query">-</a>
remove leaders with query-replace-regexp [ ^I]+ (
*/
#if qh_KEEPstatistics
enum qh_statistics { /* alphabetical after Z/W */
Zacoplanar,
Wacoplanarmax,
Wacoplanartot,
Zangle,
Wangle,
Wanglemax,
Wanglemin,
Zangletests,
Wareatot,
Wareamax,
Wareamin,
Zavoidold,
Wavoidoldmax,
Wavoidoldtot,
Zback0,
Zbestcentrum,
Zbestdist,
Zbestlower,
Zbestlowerall,
Zbestloweralln,
Zbestlowerv,
Zcentrumtests,
Zcheckpart,
Zcomputefurthest,
Zconcave,
Wconcavemax,
Wconcavetot,
Zconcavecoplanar,
Wconcavecoplanarmax,
Wconcavecoplanartot,
Zconcavecoplanarridge,
Zconcaveridge,
Zconcaveridges,
Zcoplanar,
Wcoplanarmax,
Wcoplanartot,
Zcoplanarangle,
Zcoplanarcentrum,
Zcoplanarhorizon,
Zcoplanarinside,
Zcoplanarpart,
Zcoplanarridges,
Wcpu,
Zcyclefacetmax,
Zcyclefacettot,
Zcyclehorizon,
Zcyclevertex,
Zdegen,
Wdegenmax,
Wdegentot,
Zdegenvertex,
Zdelfacetdup,
Zdelridge,
Zdelvertextot,
Zdelvertexmax,
Zdetfacetarea,
Zdetsimplex,
Zdistcheck,
Zdistconvex,
Zdistgood,
Zdistio,
Zdistplane,
Zdiststat,
Zdistvertex,
Zdistzero,
Zdoc1,
Zdoc2,
Zdoc3,
Zdoc4,
Zdoc5,
Zdoc6,
Zdoc7,
Zdoc8,
Zdoc9,
Zdoc10,
Zdoc11,
Zdoc12,
Zdropdegen,
Zdropneighbor,
Zdupflip,
Zduplicate,
Wduplicatemax,
Wduplicatetot,
Zdupsame,
Zflipped,
Wflippedmax,
Wflippedtot,
Zflippedfacets,
Zflipridge,
Zflipridge2,
Zfindbest,
Zfindbestmax,
Zfindbesttot,
Zfindcoplanar,
Zfindfail,
Zfindhorizon,
Zfindhorizonmax,
Zfindhorizontot,
Zfindjump,
Zfindnew,
Zfindnewmax,
Zfindnewtot,
Zfindnewjump,
Zfindnewsharp,
Zgauss0,
Zgoodfacet,
Zhashlookup,
Zhashridge,
Zhashridgetest,
Zhashtests,
Zinsidevisible,
Zintersect,
Zintersectfail,
Zintersectmax,
Zintersectnum,
Zintersecttot,
Zmaxneighbors,
Wmaxout,
Wmaxoutside,
Zmaxridges,
Zmaxvertex,
Zmaxvertices,
Zmaxvneighbors,
Zmemfacets,
Zmempoints,
Zmemridges,
Zmemvertices,
Zmergeflipdup,
Zmergehorizon,
Zmergeinittot,
Zmergeinitmax,
Zmergeinittot2,
Zmergeintocoplanar,
Zmergeintohorizon,
Zmergenew,
Zmergesettot,
Zmergesetmax,
Zmergesettot2,
Zmergesimplex,
Zmergevertex,
Wmindenom,
Wminvertex,
Zminnorm,
Zmultiridge,
Znearlysingular,
Zredundant,
Wnewbalance,
Wnewbalance2,
Znewbesthorizon,
Znewfacettot,
Znewfacetmax,
Znewvertex,
Wnewvertex,
Wnewvertexmax,
Znewvertexridge,
Znoarea,
Znonsimplicial,
Znowsimplicial,
Znotgood,
Znotgoodnew,
Znotmax,
Znumfacets,
Znummergemax,
Znummergetot,
Znumneighbors,
Znumridges,
Znumvertices,
Znumvisibility,
Znumvneighbors,
Zonehorizon,
Zpartangle,
Zpartcoplanar,
Zpartcorner,
Zparthidden,
Zpartinside,
Zpartition,
Zpartitionall,
Zpartnear,
Zparttwisted,
Zpbalance,
Wpbalance,
Wpbalance2,
Zpinchduplicate,
Zpinchedapex,
Zpinchedvertex,
Zpostfacets,
Zpremergetot,
Zprocessed,
Zremvertex,
Zremvertexdel,
Zredundantmerge,
Zrenameall,
Zrenamepinch,
Zrenameshare,
Zretry,
Wretrymax,
Zretryadd,
Zretryaddmax,
Zretryaddtot,
Zridge,
Wridge,
Wridgemax,
Zridge0,
Wridge0,
Wridge0max,
Zridgemid,
Wridgemid,
Wridgemidmax,
Zridgeok,
Wridgeok,
Wridgeokmax,
Zsearchpoints,
Zsetplane,
Ztestvneighbor,
Ztotcheck,
Ztothorizon,
Ztotmerge,
Ztotpartcoplanar,
Ztotpartition,
Ztotridges,
Ztotvertices,
Ztotvisible,
Ztricoplanar,
Ztricoplanarmax,
Ztricoplanartot,
Ztridegen,
Ztrimirror,
Ztrinull,
Ztwisted,
Wtwistedtot,
Wtwistedmax,
Ztwistedridge,
Zvertextests,
Wvertexmax,
Wvertexmin,
Zvertexridge,
Zvertexridgetot,
Zvertexridgemax,
Zvertices,
Zvisfacettot,
Zvisfacetmax,
Zvisit,
Zvisit2max,
Zvisvertextot,
Zvisvertexmax,
Zvvisit,
Zvvisit2max,
Zwidefacet,
Zwidevertices,
ZEND};
/*-<a href="qh-stat_r.htm#TOC"
>-------------------------------</a><a name="ZZstat">-</a>
Zxxx/Wxxx statistics that remain defined if qh_KEEPstatistics=0
notes:
be sure to use zzdef, zzinc, etc. with these statistics (no double checking!)
*/
#else
enum qh_statistics { /* for zzdef etc. macros */
Zback0,
Zbestdist,
Zcentrumtests,
Zcheckpart,
Zconcaveridges,
Zcoplanarhorizon,
Zcoplanarpart,
Zcoplanarridges,
Zcyclefacettot,
Zcyclehorizon,
Zdelvertextot,
Zdistcheck,
Zdistconvex,
Zdistplane,
Zdistzero,
Zdoc1,
Zdoc2,
Zdoc3,
Zdoc11,
Zflippedfacets,
Zflipridge,
Zflipridge2,
Zgauss0,
Zminnorm,
Zmultiridge,
Znearlysingular,
Wnewvertexmax,
Znumvisibility,
Zpartcoplanar,
Zpartition,
Zpartitionall,
Zpinchduplicate,
Zpinchedvertex,
Zprocessed,
Zretry,
Zridge,
Wridge,
Wridgemax,
Zridge0,
Wridge0,
Wridge0max,
Zridgemid,
Wridgemid,
Wridgemidmax,
Zridgeok,
Wridgeok,
Wridgeokmax,
Zsetplane,
Ztotcheck,
Ztotmerge,
Zvertextests,
ZEND};
#endif
/*-<a href="qh-stat_r.htm#TOC"
>-------------------------------</a><a name="ztype">-</a>
ztype
the type of a statistic sets its initial value.
notes:
The type should be the same as the macro for collecting the statistic
*/
enum ztypes {zdoc,zinc,zadd,zmax,zmin,ZTYPEreal,wadd,wmax,wmin,ZTYPEend};
/*========== macros and constants =============*/
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="MAYdebugx">-</a>
MAYdebugx
define as maydebug() to be called frequently for error trapping
*/
#define MAYdebugx
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zdef_">-</a>
zzdef_, zdef_( type, name, doc, -1)
define a statistic (assumes 'qhstat.next= 0;')
zdef_( type, name, doc, count)
define an averaged statistic
printed as name/count
*/
#define zzdef_(stype,name,string,cnt) qh->qhstat.id[qh->qhstat.next++]=name; \
qh->qhstat.doc[name]= string; qh->qhstat.count[name]= cnt; qh->qhstat.type[name]= stype
#if qh_KEEPstatistics
#define zdef_(stype,name,string,cnt) qh->qhstat.id[qh->qhstat.next++]=name; \
qh->qhstat.doc[name]= string; qh->qhstat.count[name]= cnt; qh->qhstat.type[name]= stype
#else
#define zdef_(type,name,doc,count)
#endif
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zinc_">-</a>
zzinc_( name ), zinc_( name)
increment an integer statistic
*/
#define zzinc_(id) {MAYdebugx; qh->qhstat.stats[id].i++;}
#if qh_KEEPstatistics
#define zinc_(id) {MAYdebugx; qh->qhstat.stats[id].i++;}
#else
#define zinc_(id) {}
#endif
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zadd_">-</a>
zzadd_( name, value ), zadd_( name, value ), wadd_( name, value )
add value to an integer or real statistic
*/
#define zzadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].i += (val);}
#define wwadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].r += (val);}
#if qh_KEEPstatistics
#define zadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].i += (val);}
#define wadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].r += (val);}
#else
#define zadd_(id, val) {}
#define wadd_(id, val) {}
#endif
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zval_">-</a>
zzval_( name ), zval_( name ), wwval_( name )
set or return value of a statistic
*/
#define zzval_(id) ((qh->qhstat.stats[id]).i)
#define wwval_(id) ((qh->qhstat.stats[id]).r)
#if qh_KEEPstatistics
#define zval_(id) ((qh->qhstat.stats[id]).i)
#define wval_(id) ((qh->qhstat.stats[id]).r)
#else
#define zval_(id) qh->qhstat.tempi
#define wval_(id) qh->qhstat.tempr
#endif
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zmax_">-</a>
zmax_( id, val ), wmax_( id, value )
maximize id with val
*/
#define wwmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].r,(val));}
#if qh_KEEPstatistics
#define zmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].i,(val));}
#define wmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].r,(val));}
#else
#define zmax_(id, val) {}
#define wmax_(id, val) {}
#endif
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="zmin_">-</a>
zmin_( id, val ), wmin_( id, value )
minimize id with val
*/
#if qh_KEEPstatistics
#define zmin_(id, val) {MAYdebugx; minimize_(qh->qhstat.stats[id].i,(val));}
#define wmin_(id, val) {MAYdebugx; minimize_(qh->qhstat.stats[id].r,(val));}
#else
#define zmin_(id, val) {}
#define wmin_(id, val) {}
#endif
/*================== stat_r.h types ==============*/
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="intrealT">-</a>
intrealT
union of integer and real, used for statistics
*/
typedef union intrealT intrealT; /* union of int and realT */
union intrealT {
int i;
realT r;
};
/*-<a href="qh-stat_r.htm#TOC"
>--------------------------------</a><a name="qhstat">-</a>
qhstat
Data structure for statistics, similar to qh and qhrbox
Allocated as part of qhT (libqhull_r.h)
*/
struct qhstatT {
intrealT stats[ZEND]; /* integer and real statistics */
unsigned char id[ZEND+10]; /* id's in print order */
const char *doc[ZEND]; /* array of documentation strings */
short int count[ZEND]; /* -1 if none, else index of count to use */
char type[ZEND]; /* type, see ztypes above */
char printed[ZEND]; /* true, if statistic has been printed */
intrealT init[ZTYPEend]; /* initial values by types, set initstatistics */
int next; /* next index for zdef_ */
int precision; /* index for precision problems, printed on qh_errexit and qh_produce_output2/Q0/QJn */
int vridges; /* index for Voronoi ridges, printed on qh_produce_output2 */
int tempi;
realT tempr;
};
/*========== function prototypes ===========*/
#ifdef __cplusplus
extern "C" {
#endif
void qh_allstatA(qhT *qh);
void qh_allstatB(qhT *qh);
void qh_allstatC(qhT *qh);
void qh_allstatD(qhT *qh);
void qh_allstatE(qhT *qh);
void qh_allstatE2(qhT *qh);
void qh_allstatF(qhT *qh);
void qh_allstatG(qhT *qh);
void qh_allstatH(qhT *qh);
void qh_allstatI(qhT *qh);
void qh_allstatistics(qhT *qh);
void qh_collectstatistics(qhT *qh);
void qh_initstatistics(qhT *qh);
boolT qh_newstats(qhT *qh, int idx, int *nextindex);
boolT qh_nostatistic(qhT *qh, int i);
void qh_printallstatistics(qhT *qh, FILE *fp, const char *string);
void qh_printstatistics(qhT *qh, FILE *fp, const char *string);
void qh_printstatlevel(qhT *qh, FILE *fp, int id);
void qh_printstats(qhT *qh, FILE *fp, int idx, int *nextindex);
realT qh_stddev(qhT *qh, int num, realT tot, realT tot2, realT *ave);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* qhDEFstat */
|