1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
12 |
|
#include "view.h" |
13 |
|
#include "resolu.h" |
14 |
|
|
15 |
< |
#ifndef BLOADSIZE |
16 |
< |
#define BLOADSIZE 1024 /* number of input beams to load at a time */ |
15 |
> |
#ifndef BKBSIZE |
16 |
> |
#define BKBSIZE 256 /* beam clump size (kilobytes) */ |
17 |
|
#endif |
18 |
|
|
19 |
|
int checkdepth = 1; /* check depth (!-f option)? */ |
55 |
|
if (frompicz && (argc-i)%2) |
56 |
|
goto userr; |
57 |
|
noutsects = openholo(argv[1], 1); |
58 |
< |
if (frompicz) |
58 |
> |
if (frompicz) { |
59 |
|
for ( ; i < argc; i += 2) |
60 |
|
addpicz(argv[i], argv[i+1]); |
61 |
< |
else |
61 |
> |
} else { |
62 |
> |
if (BKBSIZE*1024*1.5 > hdcachesize) |
63 |
> |
hdcachesize = BKBSIZE*1024*1.5; |
64 |
|
for ( ; i < argc; i++) |
65 |
|
addholo(argv[i]); |
66 |
+ |
} |
67 |
|
quit(0); |
68 |
|
userr: |
69 |
|
fprintf(stderr, "Usage: %s output.hdk [-u][-d] -h inp1.hdk ..\n", |
70 |
|
progname); |
71 |
< |
fprintf(stderr, " Or: %s output.hdk [-u][-d] -pz inp1.pic inp1.zbf ..\n", |
71 |
> |
fprintf(stderr, " Or: %s output.hdk [-u][-d] -p inp1.pic inp1.zbf ..\n", |
72 |
|
progname); |
73 |
|
exit(1); |
74 |
|
} |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
< |
addholo(hdf) /* add a holodeck file */ |
197 |
< |
char *hdf; |
196 |
> |
addbeam(bp, hb) /* add a beam to our output holodeck */ |
197 |
> |
register BEAM *bp; |
198 |
> |
register HDBEAMI *hb; |
199 |
|
{ |
196 |
– |
HDBEAMI hbl[BLOADSIZE]; |
197 |
– |
int fd; |
198 |
– |
register HOLO *hp; |
199 |
– |
register BEAM *bp; |
200 |
|
GCOORD gc[2]; |
201 |
|
FVECT ro, rd; |
202 |
|
double d; |
203 |
– |
int i, j, n, li; |
203 |
|
register int k; |
204 |
+ |
/* get beam coordinates */ |
205 |
+ |
hdbcoord(gc, hb->h, hb->b); |
206 |
+ |
/* add each ray to output */ |
207 |
+ |
for (k = bp->nrm; k--; ) { |
208 |
+ |
d = hdray(ro, rd, hb->h, gc, hdbray(bp)[k].r); |
209 |
+ |
if (hb->h->priv == &unobstr) |
210 |
+ |
VSUM(ro, ro, rd, d); |
211 |
+ |
else |
212 |
+ |
d = 0.; |
213 |
+ |
d = hddepth(hb->h, hdbray(bp)[k].d) - d; |
214 |
+ |
addray(ro, rd, d, hdbray(bp)[k].v); |
215 |
+ |
} |
216 |
+ |
hdfreebeam(hb->h, hb->b); /* free the beam */ |
217 |
+ |
} |
218 |
+ |
|
219 |
+ |
|
220 |
+ |
addholo(hdf) /* add a holodeck file */ |
221 |
+ |
char *hdf; |
222 |
+ |
{ |
223 |
+ |
int fd; |
224 |
|
/* open the holodeck for reading */ |
225 |
|
openholo(hdf, 0); |
226 |
|
fd = hdlist[noutsects]->fd; /* remember the file handle */ |
227 |
< |
while ((hp = hdlist[noutsects]) != NULL) { /* load each section */ |
228 |
< |
for (j = 0; j < nbeams(hp); j++) { /* load each beam */ |
229 |
< |
if (!(li = j % BLOADSIZE)) { /* optimize order */ |
230 |
< |
if (j+BLOADSIZE > nbeams(hp)) |
212 |
< |
k = n = nbeams(hp) - j; |
213 |
< |
else |
214 |
< |
k = n = BLOADSIZE; |
215 |
< |
while (k--) { |
216 |
< |
hbl[k].h = hp; |
217 |
< |
hbl[k].b = j+k+1; |
218 |
< |
} |
219 |
< |
qsort((char *)hbl, n, |
220 |
< |
sizeof(HDBEAMI), hdfilord); |
221 |
< |
} |
222 |
< |
if ((bp = hdgetbeam(hp, hbl[li].b)) != NULL) { |
223 |
< |
hdbcoord(gc, hp, hbl[li].b); |
224 |
< |
for (k = bp->nrm; k--; ) { |
225 |
< |
d = hdray(ro, rd, |
226 |
< |
hp, gc, hdbray(bp)[k].r); |
227 |
< |
if (hp->priv == &unobstr) |
228 |
< |
VSUM(ro, ro, rd, d); |
229 |
< |
else |
230 |
< |
d = 0.; |
231 |
< |
d = hddepth(hp, hdbray(bp)[k].d) - d; |
232 |
< |
addray(ro, rd, d, hdbray(bp)[k].v); |
233 |
< |
} |
234 |
< |
hdfreebeam(hp, hbl[li].b); /* free beam */ |
235 |
< |
} |
236 |
< |
} |
237 |
< |
hddone(hp); /* free the section */ |
227 |
> |
while (hdlist[noutsects] != NULL) { /* load each section */ |
228 |
> |
/* clump the beams */ |
229 |
> |
clumpbeams(hdlist[noutsects], 0, BKBSIZE*1024, addbeam); |
230 |
> |
hddone(hdlist[noutsects]); /* free the section */ |
231 |
|
} |
232 |
< |
close(fd); /* close the file */ |
232 |
> |
close(fd); /* close input file */ |
233 |
|
} |
234 |
|
|
235 |
|
|
364 |
|
addray(ro, rd, (double)zscn[i], cscn[i]); |
365 |
|
} |
366 |
|
} |
367 |
+ |
/* write output */ |
368 |
+ |
hdsync(NULL, 1); |
369 |
|
/* clean up */ |
370 |
|
free((char *)cscn); |
371 |
|
free((char *)zscn); |