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)? */ |
35 |
|
frompicz = -1; |
36 |
|
for (i = 2; i < argc && argv[i][0] == '-'; i++) |
37 |
|
switch (argv[i][1]) { |
38 |
< |
case 'c': |
38 |
> |
case 'u': |
39 |
|
checkrepeats = 1; |
40 |
|
break; |
41 |
< |
case 'f': |
41 |
> |
case 'd': |
42 |
|
checkdepth = 0; |
43 |
|
break; |
44 |
|
case 'h': |
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 [-c][-f] -h inp1.hdk ..\n", |
69 |
> |
fprintf(stderr, "Usage: %s output.hdk [-u][-d] -h inp1.hdk ..\n", |
70 |
|
progname); |
71 |
< |
fprintf(stderr, " Or: %s output.hdk [-c][-f] -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 |
|
} |
78 |
|
#define H_OBST 02 |
79 |
|
#define H_OBSF 04 |
80 |
|
|
81 |
+ |
int |
82 |
|
holheadline(s, hf) /* check holodeck header line */ |
83 |
|
register char *s; |
84 |
|
int *hf; |
90 |
|
*hf |= H_BADF; |
91 |
|
else |
92 |
|
*hf &= ~H_BADF; |
93 |
< |
return; |
93 |
> |
return(0); |
94 |
|
} |
95 |
|
if (!strncmp(s, "OBSTRUCTIONS=", 13)) { |
96 |
|
s += 13; |
101 |
|
*hf |= H_OBSF; |
102 |
|
else |
103 |
|
error(WARNING, "bad OBSTRUCTIONS value in holodeck"); |
104 |
< |
return; |
104 |
> |
return(0); |
105 |
|
} |
106 |
+ |
return(0); |
107 |
|
} |
108 |
|
|
109 |
|
int |
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 |
|
{ |
194 |
– |
HDBEAMI hbl[BLOADSIZE]; |
195 |
– |
int fd; |
196 |
– |
register HOLO *hp; |
197 |
– |
register BEAM *bp; |
200 |
|
GCOORD gc[2]; |
201 |
|
FVECT ro, rd; |
202 |
|
double d; |
201 |
– |
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)) |
210 |
< |
k = n = nbeams(hp) - j; |
211 |
< |
else |
212 |
< |
k = n = BLOADSIZE; |
213 |
< |
while (k--) { |
214 |
< |
hbl[k].h = hp; |
215 |
< |
hbl[k].b = j+k+1; |
216 |
< |
} |
217 |
< |
qsort((char *)hbl, n, |
218 |
< |
sizeof(HDBEAMI), hdfilord); |
219 |
< |
} |
220 |
< |
if ((bp = hdgetbeam(hp, hbl[li].b)) != NULL) { |
221 |
< |
hdbcoord(gc, hp, hbl[li].b); |
222 |
< |
for (k = bp->nrm; k--; ) { |
223 |
< |
d = hdray(ro, rd, |
224 |
< |
hp, gc, hdbray(bp)[k].r); |
225 |
< |
if (hp->priv == &unobstr) |
226 |
< |
VSUM(ro, ro, rd, d); |
227 |
< |
else |
228 |
< |
d = 0.; |
229 |
< |
d = hddepth(hp, hdbray(bp)[k].d) - d; |
230 |
< |
addray(ro, rd, d, hdbray(bp)[k].v); |
231 |
< |
} |
232 |
< |
hdfreebeam(hp, hbl[li].b); /* free beam */ |
233 |
< |
} |
234 |
< |
} |
235 |
< |
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 |
|
|
242 |
|
}; |
243 |
|
|
244 |
|
|
245 |
+ |
int |
246 |
|
picheadline(s, ph) /* process picture header line */ |
247 |
|
char *s; |
248 |
|
struct phead *ph; |
251 |
|
|
252 |
|
if (formatval(fmt, s)) { |
253 |
|
ph->badfmt = strcmp(fmt, COLRFMT); |
254 |
< |
return; |
254 |
> |
return(0); |
255 |
|
} |
256 |
|
if (isprims(s)) { |
257 |
|
ph->altprims++; /* don't want to deal with this */ |
258 |
< |
return; |
258 |
> |
return(0); |
259 |
|
} |
260 |
|
if (isexpos(s)) { |
261 |
|
ph->expos *= exposval(s); |
262 |
< |
return; |
262 |
> |
return(0); |
263 |
|
} |
264 |
|
if (isview(s)) { |
265 |
|
ph->gotview += sscanview(&ph->vw, s); |
266 |
< |
return; |
266 |
> |
return(0); |
267 |
|
} |
268 |
+ |
return(0); |
269 |
|
} |
270 |
|
|
271 |
|
|
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); |