8 |
|
*/ |
9 |
|
|
10 |
|
#include "platform.h" |
11 |
+ |
#include "standard.h" |
12 |
|
#include "rtprocess.h" |
12 |
– |
#include "rterror.h" |
13 |
– |
#include "rtmisc.h" |
13 |
|
#include "color.h" |
14 |
|
#include "calcomp.h" |
15 |
|
#include "view.h" |
16 |
|
|
17 |
< |
#define MAXINP 32 /* maximum number of input files */ |
17 |
> |
#define MAXINP 512 /* maximum number of input files */ |
18 |
|
#define WINSIZ 64 /* scanline window size */ |
19 |
|
#define MIDSCN ((WINSIZ-1)/2+1) |
20 |
|
|
68 |
|
|
69 |
|
char *progname; /* global argv[0] */ |
70 |
|
|
71 |
+ |
int echoheader = 1; |
72 |
|
int wrongformat = 0; |
73 |
|
int gotview; |
74 |
|
|
75 |
|
|
76 |
< |
static gethfunc tabputs; |
76 |
> |
static gethfunc headline; |
77 |
|
static void checkfile(void); |
78 |
|
static double rgb_bright(COLOR clr); |
79 |
|
static double xyz_bright(COLOR clr); |
111 |
|
case 'w': |
112 |
|
nowarn = !nowarn; |
113 |
|
continue; |
114 |
+ |
case 'h': |
115 |
+ |
echoheader = !echoheader; |
116 |
+ |
continue; |
117 |
|
case 'f': |
118 |
|
case 'e': |
119 |
|
a++; |
232 |
|
eputs("Usage: "); |
233 |
|
eputs(argv[0]); |
234 |
|
eputs( |
235 |
< |
" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
235 |
> |
" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
236 |
|
quit(1); |
237 |
|
return 1; /* pro forma return */ |
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
|
static int |
242 |
< |
tabputs( /* put out string preceded by a tab */ |
242 |
> |
headline( /* check header line & echo if requested */ |
243 |
|
char *s, |
244 |
|
void *p |
245 |
|
) |
268 |
|
input[nfiles].pa *= aspectval(s); |
269 |
|
else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) |
270 |
|
gotview++; |
271 |
< |
/* echo line */ |
272 |
< |
putchar('\t'); |
273 |
< |
return(fputs(s, stdout)); |
271 |
> |
|
272 |
> |
if (echoheader) { /* echo line */ |
273 |
> |
putchar('\t'); |
274 |
> |
return(fputs(s, stdout)); |
275 |
> |
} |
276 |
> |
return(0); |
277 |
|
} |
278 |
|
|
279 |
|
|
283 |
|
register int i; |
284 |
|
/* process header */ |
285 |
|
gotview = 0; |
286 |
< |
fputs(input[nfiles].name, stdout); |
287 |
< |
fputs(":\n", stdout); |
288 |
< |
getheader(input[nfiles].fp, tabputs, NULL); |
286 |
> |
if (echoheader) { |
287 |
> |
fputs(input[nfiles].name, stdout); |
288 |
> |
fputs(":\n", stdout); |
289 |
> |
} |
290 |
> |
getheader(input[nfiles].fp, headline, NULL); |
291 |
|
if (wrongformat < 0) { |
292 |
|
eputs(input[nfiles].name); |
293 |
|
eputs(": not a Radiance picture\n"); |
343 |
|
static void |
344 |
|
init(void) /* perform final setup */ |
345 |
|
{ |
338 |
– |
double l_colin(char *), l_expos(char *), l_pixaspect(char *), |
339 |
– |
l_ray(char *), l_psize(char *); |
346 |
|
register int i; |
347 |
|
/* define constants */ |
348 |
|
varset("PI", ':', PI); |
448 |
|
eputs(": read error\n"); |
449 |
|
quit(1); |
450 |
|
} |
451 |
< |
if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || |
452 |
< |
fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || |
447 |
< |
fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) |
448 |
< |
for (j = 0; j < xmax; j++) /* adjust color */ |
449 |
< |
multcolor(st[j], input[i].coef); |
451 |
> |
for (j = 0; j < xmax; j++) /* adjust color */ |
452 |
> |
multcolor(st[j], input[i].coef); |
453 |
|
} |
454 |
|
} |
455 |
|
|
607 |
|
if (input[fn].vw.type == 0) |
608 |
|
errno = EDOM; |
609 |
|
else if (input[fn].vw.type != VT_PAR && |
610 |
< |
funvalue(vray[6], 1, &d) >= 0) { |
610 |
> |
funvalue(vray[6], 1, &d) >= -FTINY) { |
611 |
|
for (i = 0; i < 3; i++) |
612 |
|
dir0[i] = funvalue(vray[3+i], 1, &d); |
613 |
|
pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan); |
614 |
|
pix2loc(locy, &input[fn].rs, xscan, ymax-yscan); |
615 |
|
if (viewray(org, dirx, &input[fn].vw, |
616 |
< |
locx[0], locx[1]) >= 0 && |
616 |
> |
locx[0], locx[1]) >= -FTINY && |
617 |
|
viewray(org, diry, &input[fn].vw, |
618 |
< |
locy[0], locy[1]) >= 0) { |
618 |
> |
locy[0], locy[1]) >= -FTINY) { |
619 |
|
/* approximate solid angle */ |
620 |
|
for (i = 0; i < 3; i++) { |
621 |
|
dirx[i] -= dir0[i]; |
622 |
|
diry[i] -= dir0[i]; |
623 |
|
} |
624 |
|
fcross(dir0, dirx, diry); |
625 |
< |
psize[fn] = sqrt(DOT(dir0,dir0)); |
625 |
> |
psize[fn] = VLEN(dir0); |
626 |
|
} |
627 |
|
} |
628 |
|
ltick[fn] = eclock; |