1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Combine picture files according to calcomp functions. |
6 |
|
* |
7 |
|
* 1/4/89 |
8 |
|
*/ |
9 |
|
|
10 |
+ |
#include "platform.h" |
11 |
|
#include "standard.h" |
12 |
< |
|
12 |
> |
#include "paths.h" |
13 |
|
#include "color.h" |
16 |
– |
|
17 |
– |
#include "resolu.h" |
18 |
– |
|
14 |
|
#include "calcomp.h" |
20 |
– |
|
15 |
|
#include "view.h" |
16 |
|
|
17 |
< |
#define MAXINP 32 /* maximum number of input files */ |
18 |
< |
#define WINSIZ 17 /* scanline window size */ |
17 |
> |
#define MAXINP 1024 /* maximum number of input files */ |
18 |
> |
#define WINSIZ 127 /* scanline window size */ |
19 |
|
#define MIDSCN ((WINSIZ-1)/2+1) |
20 |
|
|
21 |
|
struct { |
31 |
|
|
32 |
|
int nfiles; /* number of input files */ |
33 |
|
|
34 |
+ |
VIEW *commvp = NULL; /* common view parameters */ |
35 |
+ |
|
36 |
|
char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ |
37 |
|
|
38 |
+ |
char StandardInput[] = "<stdin>"; |
39 |
|
char Command[] = "<Command>"; |
40 |
|
char vcolin[3][4] = {"ri", "gi", "bi"}; |
41 |
|
char vcolout[3][4] = {"ro", "go", "bo"}; |
70 |
|
|
71 |
|
char *progname; /* global argv[0] */ |
72 |
|
|
73 |
+ |
int echoheader = 1; |
74 |
|
int wrongformat = 0; |
75 |
|
int gotview; |
76 |
|
|
79 |
– |
FILE *popen(); |
77 |
|
|
78 |
< |
extern char *emalloc(); |
78 |
> |
static gethfunc headline; |
79 |
> |
static void checkfile(int orig); |
80 |
> |
static double rgb_bright(COLOR clr); |
81 |
> |
static double xyz_bright(COLOR clr); |
82 |
> |
static void init(void); |
83 |
> |
static void combine(void); |
84 |
> |
static void advance(void); |
85 |
> |
static double l_expos(char *nam); |
86 |
> |
static double l_pixaspect(char *nm); |
87 |
> |
static double l_colin(char *nam); |
88 |
> |
static double l_ray(char *nam); |
89 |
> |
static double l_psize(char *nm); |
90 |
|
|
91 |
|
|
92 |
< |
main(argc, argv) |
93 |
< |
int argc; |
94 |
< |
char *argv[]; |
92 |
> |
int |
93 |
> |
main( |
94 |
> |
int argc, |
95 |
> |
char *argv[] |
96 |
> |
) |
97 |
|
{ |
98 |
|
int original; |
99 |
|
double f; |
100 |
< |
int a, i; |
101 |
< |
#ifdef MSDOS |
102 |
< |
extern int _fmode; |
103 |
< |
_fmode = O_BINARY; |
104 |
< |
setmode(fileno(stdin), O_BINARY); |
95 |
< |
setmode(fileno(stdout), O_BINARY); |
96 |
< |
#endif |
100 |
> |
int a; |
101 |
> |
|
102 |
> |
SET_DEFAULT_BINARY(); |
103 |
> |
SET_FILE_BINARY(stdin); |
104 |
> |
SET_FILE_BINARY(stdout); |
105 |
|
progname = argv[0]; |
106 |
+ |
esupport |= E_VARIABLE|E_FUNCTION|E_RCONST; |
107 |
+ |
esupport &= ~(E_OUTCHAN|E_INCHAN); |
108 |
|
/* scan options */ |
109 |
|
for (a = 1; a < argc; a++) { |
110 |
|
if (argv[a][0] == '-') |
116 |
|
case 'w': |
117 |
|
nowarn = !nowarn; |
118 |
|
continue; |
119 |
+ |
case 'h': |
120 |
+ |
echoheader = !echoheader; |
121 |
+ |
continue; |
122 |
|
case 'f': |
123 |
|
case 'e': |
124 |
|
a++; |
127 |
|
break; |
128 |
|
} |
129 |
|
newheader("RADIANCE", stdout); /* start header */ |
130 |
+ |
fputnow(stdout); |
131 |
|
/* process files */ |
132 |
|
for (nfiles = 0; nfiles < MAXINP; nfiles++) { |
133 |
|
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
134 |
|
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
135 |
< |
copystruct(&input[nfiles].vw, &stdview); |
135 |
> |
input[nfiles].vw = stdview; |
136 |
|
input[nfiles].pa = 1.0; |
137 |
|
} |
138 |
|
nfiles = 0; |
146 |
|
if (argv[a][0] == '-') |
147 |
|
switch (argv[a][1]) { |
148 |
|
case '\0': |
149 |
< |
input[nfiles].name = "<stdin>"; |
149 |
> |
input[nfiles].name = StandardInput; |
150 |
|
input[nfiles].fp = stdin; |
151 |
|
break; |
152 |
|
case 'o': |
177 |
|
quit(1); |
178 |
|
} |
179 |
|
} |
180 |
< |
checkfile(); |
167 |
< |
if (original) { |
168 |
< |
colval(input[nfiles].coef,RED) /= |
169 |
< |
colval(input[nfiles].expos,RED); |
170 |
< |
colval(input[nfiles].coef,GRN) /= |
171 |
< |
colval(input[nfiles].expos,GRN); |
172 |
< |
colval(input[nfiles].coef,BLU) /= |
173 |
< |
colval(input[nfiles].expos,BLU); |
174 |
< |
} |
180 |
> |
checkfile(original); |
181 |
|
nfiles++; |
182 |
|
original = 0; |
183 |
|
} |
184 |
|
init(); /* set constants */ |
185 |
|
/* go back and get expressions */ |
186 |
|
for (a = 1; a < argc; a++) { |
187 |
+ |
char *fpath; |
188 |
|
if (argv[a][0] == '-') |
189 |
|
switch (argv[a][1]) { |
190 |
|
case 'x': |
195 |
|
continue; |
196 |
|
case 'w': |
197 |
|
continue; |
198 |
+ |
case 'h': |
199 |
+ |
continue; |
200 |
|
case 'f': |
201 |
< |
fcompile(argv[++a]); |
201 |
> |
fpath = getpath(argv[++a], getrlibpath(), 0); |
202 |
> |
if (fpath == NULL) { |
203 |
> |
eputs(argv[0]); |
204 |
> |
eputs(": cannot find file '"); |
205 |
> |
eputs(argv[a]); |
206 |
> |
eputs("'\n"); |
207 |
> |
quit(1); |
208 |
> |
} |
209 |
> |
fcompile(fpath); |
210 |
|
continue; |
211 |
|
case 'e': |
212 |
|
scompile(argv[++a], NULL, 0); |
214 |
|
} |
215 |
|
break; |
216 |
|
} |
217 |
< |
/* set/get output resolution */ |
201 |
< |
if (!vardefined(vxres)) |
202 |
< |
varset(vxres, ':', (double)xmax); |
203 |
< |
if (!vardefined(vyres)) |
204 |
< |
varset(vyres, ':', (double)ymax); |
217 |
> |
/* get output resolution */ |
218 |
|
xres = varvalue(vxres) + .5; |
219 |
|
yres = varvalue(vyres) + .5; |
220 |
|
if (xres <= 0 || yres <= 0) { |
224 |
|
} |
225 |
|
/* complete header */ |
226 |
|
printargs(argc, argv, stdout); |
227 |
+ |
if (commvp != NULL) { |
228 |
+ |
fputs(VIEWSTR, stdout); |
229 |
+ |
fprintview(commvp, stdout); |
230 |
+ |
fputc('\n', stdout); |
231 |
+ |
} |
232 |
|
if (strcmp(ourfmt, PICFMT)) |
233 |
|
fputformat(ourfmt, stdout); /* print format if known */ |
234 |
|
putchar('\n'); |
240 |
|
eputs("Usage: "); |
241 |
|
eputs(argv[0]); |
242 |
|
eputs( |
243 |
< |
" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
243 |
> |
" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] hdr ..]\n"); |
244 |
|
quit(1); |
245 |
+ |
return 1; /* pro forma return */ |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
< |
tputs(s) /* put out string preceded by a tab */ |
250 |
< |
char *s; |
249 |
> |
static int |
250 |
> |
headline( /* check header line & echo if requested */ |
251 |
> |
char *s, |
252 |
> |
void *p |
253 |
> |
) |
254 |
|
{ |
255 |
< |
char fmt[32]; |
255 |
> |
int orig = *(int *)p; |
256 |
> |
char fmt[MAXFMTLEN]; |
257 |
|
double d; |
258 |
|
COLOR ctmp; |
259 |
|
|
260 |
|
if (isheadid(s)) /* header id */ |
261 |
< |
return; /* don't echo */ |
261 |
> |
return(0); /* don't echo */ |
262 |
|
if (formatval(fmt, s)) { /* check format */ |
263 |
|
if (globmatch(ourfmt, fmt)) { |
264 |
|
wrongformat = 0; |
265 |
|
strcpy(ourfmt, fmt); |
266 |
|
} else |
267 |
< |
wrongformat = 1; |
268 |
< |
return; /* don't echo */ |
267 |
> |
wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; |
268 |
> |
return(0); /* don't echo */ |
269 |
|
} |
270 |
< |
if (isexpos(s)) { /* exposure */ |
270 |
> |
if (orig) { /* undo exposure? */ |
271 |
> |
if (isexpos(s)) { |
272 |
> |
d = 1./exposval(s); |
273 |
> |
scalecolor(input[nfiles].coef, d); |
274 |
> |
return(0); /* don't echo */ |
275 |
> |
} |
276 |
> |
if (iscolcor(s)) { |
277 |
> |
int i; |
278 |
> |
colcorval(ctmp, s); |
279 |
> |
for (i = 3; i--; ) |
280 |
> |
colval(input[nfiles].coef,i) /= colval(ctmp,i); |
281 |
> |
return(0); /* don't echo */ |
282 |
> |
} |
283 |
> |
} else if (isexpos(s)) { /* record exposure? */ |
284 |
|
d = exposval(s); |
285 |
|
scalecolor(input[nfiles].expos, d); |
286 |
< |
} else if (iscolcor(s)) { /* color correction */ |
286 |
> |
} else if (iscolcor(s)) { |
287 |
|
colcorval(ctmp, s); |
288 |
|
multcolor(input[nfiles].expos, ctmp); |
289 |
|
} else if (isaspect(s)) |
290 |
|
input[nfiles].pa *= aspectval(s); |
291 |
|
else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) |
292 |
|
gotview++; |
293 |
< |
/* echo line */ |
294 |
< |
putchar('\t'); |
295 |
< |
fputs(s, stdout); |
293 |
> |
|
294 |
> |
if (echoheader) { /* echo line */ |
295 |
> |
putchar('\t'); |
296 |
> |
return(fputs(s, stdout)); |
297 |
> |
} |
298 |
> |
return(0); |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
< |
checkfile() /* ready a file */ |
302 |
> |
static void |
303 |
> |
checkfile(int orig) /* ready a file */ |
304 |
|
{ |
305 |
< |
register int i; |
305 |
> |
int i; |
306 |
|
/* process header */ |
307 |
|
gotview = 0; |
308 |
< |
fputs(input[nfiles].name, stdout); |
309 |
< |
fputs(":\n", stdout); |
310 |
< |
getheader(input[nfiles].fp, tputs, NULL); |
311 |
< |
if (wrongformat) { |
308 |
> |
if (echoheader) { |
309 |
> |
fputs(input[nfiles].name, stdout); |
310 |
> |
fputs(":\n", stdout); |
311 |
> |
} |
312 |
> |
getheader(input[nfiles].fp, headline, &orig); |
313 |
> |
if (wrongformat < 0) { |
314 |
|
eputs(input[nfiles].name); |
315 |
< |
eputs(": not in Radiance picture format\n"); |
315 |
> |
eputs(": not a Radiance picture\n"); |
316 |
|
quit(1); |
317 |
|
} |
318 |
+ |
if (wrongformat > 0) { |
319 |
+ |
wputs(input[nfiles].name); |
320 |
+ |
wputs(": warning -- incompatible picture format\n"); |
321 |
+ |
} |
322 |
|
if (!gotview || setview(&input[nfiles].vw) != NULL) |
323 |
|
input[nfiles].vw.type = 0; |
324 |
+ |
else if (commvp == NULL) |
325 |
+ |
commvp = &input[nfiles].vw; |
326 |
|
if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
327 |
|
eputs(input[nfiles].name); |
328 |
|
eputs(": bad picture size\n"); |
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
< |
double |
347 |
< |
rgb_bright(clr) |
348 |
< |
COLOR clr; |
346 |
> |
static double |
347 |
> |
rgb_bright( |
348 |
> |
COLOR clr |
349 |
> |
) |
350 |
|
{ |
351 |
|
return(bright(clr)); |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
< |
double |
356 |
< |
xyz_bright(clr) |
357 |
< |
COLOR clr; |
355 |
> |
static double |
356 |
> |
xyz_bright( |
357 |
> |
COLOR clr |
358 |
> |
) |
359 |
|
{ |
360 |
|
return(clr[CIEY]); |
361 |
|
} |
364 |
|
double (*ourbright)() = rgb_bright; |
365 |
|
|
366 |
|
|
367 |
< |
init() /* perform final setup */ |
367 |
> |
static void |
368 |
> |
init(void) /* perform final setup */ |
369 |
|
{ |
370 |
< |
double l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize(); |
320 |
< |
register int i; |
370 |
> |
int i; |
371 |
|
/* define constants */ |
372 |
|
varset("PI", ':', PI); |
373 |
|
varset(vnfiles, ':', (double)nfiles); |
390 |
|
ourbright = xyz_bright; |
391 |
|
} else |
392 |
|
varset(vwhteff, ':', WHTEFFICACY); |
393 |
+ |
/* these may be overridden */ |
394 |
+ |
varset(vxres, ':', (double)xmax); |
395 |
+ |
varset(vyres, ':', (double)ymax); |
396 |
|
} |
397 |
|
|
398 |
|
|
399 |
< |
combine() /* combine pictures */ |
399 |
> |
static void |
400 |
> |
combine(void) /* combine pictures */ |
401 |
|
{ |
402 |
|
EPNODE *coldef[3], *brtdef; |
403 |
|
COLOR *scanout; |
404 |
|
double d; |
405 |
< |
register int i, j; |
405 |
> |
int i, j; |
406 |
|
/* check defined variables */ |
407 |
|
for (j = 0; j < 3; j++) { |
408 |
|
if (vardefined(vcolout[j])) |
423 |
|
advance(); |
424 |
|
varset(vypos, '=', (double)ypos); |
425 |
|
for (xpos = 0; xpos < xres; xpos++) { |
426 |
< |
xscan = (long)xpos*xmax/xres; |
426 |
> |
xscan = (xpos+.5)*xmax/xres; |
427 |
|
varset(vxpos, '=', (double)xpos); |
428 |
|
eclock++; |
429 |
|
if (brtdef != NULL) { |
451 |
|
quit(1); |
452 |
|
} |
453 |
|
} |
454 |
< |
efree(scanout); |
454 |
> |
efree((char *)scanout); |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
< |
advance() /* read in data for next scanline */ |
458 |
> |
static void |
459 |
> |
advance(void) /* read in data for next scanline */ |
460 |
|
{ |
461 |
|
int ytarget; |
462 |
< |
register COLOR *st; |
463 |
< |
register int i, j; |
462 |
> |
COLOR *st; |
463 |
> |
int i, j; |
464 |
|
|
465 |
< |
for (ytarget = (long)ypos*ymax/yres; yscan > ytarget; yscan--) |
465 |
> |
for (ytarget = (ypos+.5)*ymax/yres; yscan > ytarget; yscan--) |
466 |
|
for (i = 0; i < nfiles; i++) { |
467 |
|
st = input[i].scan[WINSIZ-1]; |
468 |
|
for (j = WINSIZ-1; j > 0; j--) /* rotate window */ |
475 |
|
eputs(": read error\n"); |
476 |
|
quit(1); |
477 |
|
} |
478 |
< |
if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || |
479 |
< |
fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || |
425 |
< |
fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) |
426 |
< |
for (j = 0; j < xmax; j++) /* adjust color */ |
427 |
< |
multcolor(st[j], input[i].coef); |
478 |
> |
for (j = 0; j < xmax; j++) /* adjust color */ |
479 |
> |
multcolor(st[j], input[i].coef); |
480 |
|
} |
481 |
|
} |
482 |
|
|
483 |
|
|
484 |
< |
double |
485 |
< |
l_expos(nam) /* return picture exposure */ |
486 |
< |
register char *nam; |
484 |
> |
static double |
485 |
> |
l_expos( /* return picture exposure */ |
486 |
> |
char *nam |
487 |
> |
) |
488 |
|
{ |
489 |
< |
register int fn, n; |
489 |
> |
int fn, n; |
490 |
> |
double d; |
491 |
|
|
492 |
< |
fn = argument(1) - .5; |
493 |
< |
if (fn < 0 || fn >= nfiles) |
494 |
< |
return(1.0); |
492 |
> |
d = argument(1); |
493 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
494 |
> |
errno = EDOM; |
495 |
> |
return(0.0); |
496 |
> |
} |
497 |
> |
if (d < 0.5) |
498 |
> |
return((double)nfiles); |
499 |
> |
fn = d - 0.5; |
500 |
|
if (nam == vbrtexp) |
501 |
|
return((*ourbright)(input[fn].expos)); |
502 |
|
n = 3; |
505 |
|
return(colval(input[fn].expos,n)); |
506 |
|
eputs("Bad call to l_expos()!\n"); |
507 |
|
quit(1); |
508 |
+ |
return 1; /* pro forma return */ |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
< |
double |
513 |
< |
l_pixaspect() /* return pixel aspect ratio */ |
512 |
> |
static double |
513 |
> |
l_pixaspect(char *nm) /* return pixel aspect ratio */ |
514 |
|
{ |
515 |
< |
register int fn; |
515 |
> |
int fn; |
516 |
> |
double d; |
517 |
|
|
518 |
< |
fn = argument(1) - .5; |
519 |
< |
if (fn < 0 || fn >= nfiles) |
520 |
< |
return(1.0); |
518 |
> |
d = argument(1); |
519 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
520 |
> |
errno = EDOM; |
521 |
> |
return(0.0); |
522 |
> |
} |
523 |
> |
if (d < 0.5) |
524 |
> |
return((double)nfiles); |
525 |
> |
fn = d - 0.5; |
526 |
|
return(input[fn].pa); |
527 |
|
} |
528 |
|
|
529 |
|
|
530 |
< |
double |
531 |
< |
l_colin(nam) /* return color value for picture */ |
532 |
< |
register char *nam; |
530 |
> |
static double |
531 |
> |
l_colin( /* return color value for picture */ |
532 |
> |
char *nam |
533 |
> |
) |
534 |
|
{ |
535 |
|
int fn; |
536 |
< |
register int n, xoff, yoff; |
536 |
> |
int n, xoff, yoff; |
537 |
|
double d; |
538 |
|
|
539 |
< |
fn = argument(1) - .5; |
540 |
< |
if (fn < 0 || fn >= nfiles) { |
539 |
> |
d = argument(1); |
540 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
541 |
|
errno = EDOM; |
542 |
|
return(0.0); |
543 |
|
} |
544 |
+ |
if (d < 0.5) |
545 |
+ |
return((double)nfiles); |
546 |
+ |
fn = d - 0.5; |
547 |
|
xoff = yoff = 0; |
548 |
|
n = nargum(); |
549 |
|
if (n >= 2) { |
582 |
|
return(colval(input[fn].scan[MIDSCN+yoff][xscan+xoff],n)); |
583 |
|
eputs("Bad call to l_colin()!\n"); |
584 |
|
quit(1); |
585 |
+ |
return 1; /* pro forma return */ |
586 |
|
} |
587 |
|
|
588 |
|
|
589 |
< |
double |
590 |
< |
l_ray(nam) /* return ray origin or direction */ |
591 |
< |
register char *nam; |
589 |
> |
static double |
590 |
> |
l_ray( /* return ray origin or direction */ |
591 |
> |
char *nam |
592 |
> |
) |
593 |
|
{ |
594 |
|
static unsigned long ltick[MAXINP]; |
595 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
596 |
|
static double ldist[MAXINP]; |
597 |
< |
FLOAT loc[2]; |
597 |
> |
RREAL loc[2]; |
598 |
> |
double d; |
599 |
|
int fn; |
600 |
< |
register int i; |
600 |
> |
int i; |
601 |
|
|
602 |
< |
fn = argument(1) - .5; |
603 |
< |
if (fn < 0 || fn >= nfiles) { |
602 |
> |
d = argument(1); |
603 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
604 |
|
errno = EDOM; |
605 |
|
return(0.0); |
606 |
|
} |
607 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
607 |
> |
if (d < 0.5) |
608 |
> |
return((double)nfiles); |
609 |
> |
fn = d - 0.5; |
610 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
611 |
|
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
612 |
|
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
613 |
|
ldist[fn] = -1.0; |
627 |
|
return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]); |
628 |
|
eputs("Bad call to l_ray()!\n"); |
629 |
|
quit(1); |
630 |
+ |
return 1; /* pro forma return */ |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
< |
double |
635 |
< |
l_psize() /* compute pixel size in steradians */ |
634 |
> |
static double |
635 |
> |
l_psize(char *nm) /* compute pixel size in steradians */ |
636 |
|
{ |
637 |
|
static unsigned long ltick[MAXINP]; |
638 |
|
static double psize[MAXINP]; |
639 |
|
FVECT dir0, org, dirx, diry; |
640 |
< |
FLOAT locx[2], locy[2]; |
640 |
> |
RREAL locx[2], locy[2]; |
641 |
|
double d; |
642 |
|
int fn; |
643 |
< |
register int i; |
643 |
> |
int i; |
644 |
|
|
645 |
|
d = argument(1); |
646 |
< |
if (d < .5 || d >= nfiles+.5) { |
646 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
647 |
|
errno = EDOM; |
648 |
|
return(0.0); |
649 |
|
} |
650 |
< |
fn = d - .5; |
651 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
650 |
> |
if (d < 0.5) |
651 |
> |
return((double)nfiles); |
652 |
> |
fn = d - 0.5; |
653 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
654 |
|
psize[fn] = 0.0; |
655 |
|
if (input[fn].vw.type == 0) |
656 |
|
errno = EDOM; |
657 |
|
else if (input[fn].vw.type != VT_PAR && |
658 |
< |
funvalue(vray[6], 1, &d) >= 0) { |
658 |
> |
funvalue(vray[6], 1, &d) >= -FTINY) { |
659 |
|
for (i = 0; i < 3; i++) |
660 |
|
dir0[i] = funvalue(vray[3+i], 1, &d); |
661 |
|
pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan); |
662 |
|
pix2loc(locy, &input[fn].rs, xscan, ymax-yscan); |
663 |
|
if (viewray(org, dirx, &input[fn].vw, |
664 |
< |
locx[0], locx[1]) >= 0 && |
664 |
> |
locx[0], locx[1]) >= -FTINY && |
665 |
|
viewray(org, diry, &input[fn].vw, |
666 |
< |
locy[0], locy[1]) >= 0) { |
666 |
> |
locy[0], locy[1]) >= -FTINY) { |
667 |
|
/* approximate solid angle */ |
668 |
|
for (i = 0; i < 3; i++) { |
669 |
|
dirx[i] -= dir0[i]; |
670 |
|
diry[i] -= dir0[i]; |
671 |
|
} |
672 |
|
fcross(dir0, dirx, diry); |
673 |
< |
psize[fn] = 0.5 * sqrt(DOT(dir0,dir0)); |
673 |
> |
psize[fn] = VLEN(dir0); |
674 |
|
} |
675 |
|
} |
676 |
|
ltick[fn] = eclock; |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
< |
wputs(msg) |
683 |
< |
char *msg; |
682 |
> |
extern void |
683 |
> |
wputs(char *msg) |
684 |
|
{ |
685 |
|
if (!nowarn) |
686 |
|
eputs(msg); |
687 |
|
} |
688 |
|
|
689 |
|
|
690 |
< |
eputs(msg) |
691 |
< |
char *msg; |
690 |
> |
extern void |
691 |
> |
eputs(char *msg) |
692 |
|
{ |
693 |
|
fputs(msg, stderr); |
694 |
|
} |
695 |
|
|
696 |
|
|
697 |
< |
quit(code) /* exit gracefully */ |
698 |
< |
int code; |
697 |
> |
extern void |
698 |
> |
quit(int code) /* exit gracefully */ |
699 |
|
{ |
700 |
< |
register int i; |
700 |
> |
int i; |
701 |
|
/* close input files */ |
702 |
|
for (i = 0; i < nfiles; i++) |
703 |
|
if (input[i].name == Command) |