1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Get general information on holodeck file |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <stdio.h> |
9 |
+ |
|
10 |
+ |
#include "platform.h" |
11 |
+ |
#include "resolu.h" |
12 |
|
#include "holo.h" |
13 |
|
|
14 |
|
#ifndef NHBINS |
17 |
|
|
18 |
|
char *progname; /* global argv[0] */ |
19 |
|
|
20 |
+ |
long beamtot, samptot; /* total beams and samples */ |
21 |
|
|
22 |
< |
main(argc, argv) |
23 |
< |
int argc; |
22 |
< |
char *argv[]; |
23 |
< |
{ |
24 |
< |
int sect; |
22 |
> |
static void gethdinfo(char *fname, FILE *fout); |
23 |
> |
static void psectstats(HOLO *hp, FILE *fp); |
24 |
|
|
25 |
+ |
|
26 |
+ |
int |
27 |
+ |
main( |
28 |
+ |
int argc, |
29 |
+ |
char *argv[] |
30 |
+ |
) |
31 |
+ |
{ |
32 |
|
progname = argv[0]; |
33 |
|
if (argc != 2) |
34 |
|
goto userr; |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
< |
gethdinfo(fname, fout) /* get information on holodeck */ |
44 |
< |
char *fname; |
45 |
< |
FILE *fout; |
43 |
> |
static void |
44 |
> |
gethdinfo( /* get information on holodeck */ |
45 |
> |
char *fname, |
46 |
> |
FILE *fout |
47 |
> |
) |
48 |
|
{ |
41 |
– |
extern long ftell(); |
49 |
|
FILE *fp; |
50 |
|
HOLO *hdsect; |
51 |
|
int fd; |
52 |
< |
int4 nextloc; |
52 |
> |
off_t nextloc, fsiz; |
53 |
|
int n; |
54 |
|
/* open holodeck file */ |
55 |
|
if ((fp = fopen(fname, "r")) == NULL) { |
64 |
|
fd = dup(fileno(fp)); /* dup file handle */ |
65 |
|
nextloc = ftell(fp); /* get stdio position */ |
66 |
|
fclose(fp); /* done with stdio */ |
67 |
< |
for (n = 0; nextloc > 0L; n++) { /* get the section(s) */ |
68 |
< |
lseek(fd, (long)nextloc, 0); |
67 |
> |
for (n = 0; nextloc > 0; n++) { /* get the section(s) */ |
68 |
> |
lseek(fd, nextloc, SEEK_SET); |
69 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
70 |
|
fprintf(fout, "Section %d:\n", n); |
71 |
|
hdsect = hdinit(fd, NULL); /* load section directory */ |
72 |
|
psectstats(hdsect, fout); /* print section statistics */ |
73 |
|
} |
74 |
< |
nextloc = hdfilen(fd); /* print global statistics */ |
74 |
> |
fsiz = hdfilen(fd); /* print global statistics */ |
75 |
> |
fputs("=====================================================\n", fout); |
76 |
> |
fprintf(fout, "Total samples/beams: %ld/%ld (%.2f samples/beam)\n", |
77 |
> |
samptot, beamtot, (double)samptot/beamtot); |
78 |
|
fprintf(fout, "%.1f Mbyte file, %.1f%% fragmentation\n", |
79 |
< |
nextloc/(1024.*1024.), |
80 |
< |
100.*(nextloc-hdfiluse(fd,1))/nextloc); |
79 |
> |
fsiz/(1024.*1024.), |
80 |
> |
100.*(fsiz-hdfiluse(fd))/fsiz); |
81 |
|
/* don't bother with cleanup */ |
82 |
|
#if 0 |
83 |
|
hddone(NULL); /* free sections */ |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
< |
psectstats(hp, fp) /* print statistical information for section */ |
90 |
< |
register HOLO *hp; |
91 |
< |
FILE *fp; |
89 |
> |
static void |
90 |
> |
psectstats( /* print statistical information for section */ |
91 |
> |
HOLO *hp, |
92 |
> |
FILE *fp |
93 |
> |
) |
94 |
|
{ |
95 |
|
int scount[NHBINS]; |
96 |
|
int minsamp = 10000, maxsamp = 0; |
97 |
+ |
FVECT vt; |
98 |
|
double sqrtmaxp; |
99 |
|
int bmin, bmax, cnt; |
100 |
< |
register int i; |
100 |
> |
int i; |
101 |
|
|
102 |
+ |
fcross(vt, hp->xv[0], hp->xv[1]); |
103 |
+ |
fprintf(fp, "\tWorld volume: %g\n", fabs(DOT(vt,hp->xv[2]))); |
104 |
|
fprintf(fp, "\tGrid resolution: %d x %d x %d\n", |
105 |
|
hp->grid[0], hp->grid[1], hp->grid[2]); |
106 |
< |
fprintf(fp, "\tNumber of beams: %d\n", nbeams(hp)); |
107 |
< |
fprintf(fp, "\tNumber of ray samples: %d\n", biglob(hp)->nrd); |
106 |
> |
fprintf(fp, "\tNumber of beams: %ld\n", (long)nbeams(hp)); |
107 |
> |
beamtot += nbeams(hp); |
108 |
> |
fprintf(fp, "\tNumber of ray samples: %ld\n", (long)biglob(hp)->nrd); |
109 |
> |
samptot += biglob(hp)->nrd; |
110 |
|
if (biglob(hp)->nrd <= 0) |
111 |
|
return; /* no samples to stat! */ |
112 |
|
for (i = nbeams(hp); i > 0; i--) { |