| 9 |
|
|
| 10 |
|
#include "platform.h" |
| 11 |
|
#include "standard.h" |
| 12 |
< |
#include "rtprocess.h" |
| 12 |
> |
#include "paths.h" |
| 13 |
|
#include "color.h" |
| 14 |
|
#include "calcomp.h" |
| 15 |
|
#include "view.h" |
| 16 |
|
|
| 17 |
< |
#define MAXINP 512 /* maximum number of input files */ |
| 18 |
< |
#define WINSIZ 64 /* 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 { |
| 23 |
|
FILE *fp; /* stream pointer */ |
| 24 |
|
VIEW vw; /* view for picture */ |
| 25 |
|
RESOLU rs; /* image resolution and orientation */ |
| 26 |
+ |
int infloat; /* input is floating point (#comp)? */ |
| 27 |
|
float pa; /* pixel aspect ratio */ |
| 28 |
|
COLOR *scan[WINSIZ]; /* input scanline window */ |
| 29 |
|
COLOR coef; /* coefficient */ |
| 32 |
|
|
| 33 |
|
int nfiles; /* number of input files */ |
| 34 |
|
|
| 35 |
< |
char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ |
| 35 |
> |
VIEW *commvp = NULL; /* common view parameters */ |
| 36 |
|
|
| 37 |
+ |
char ourfmt[MAXFMTLEN] = PICFMT; /* input picture format */ |
| 38 |
+ |
int outfloat = 0; /* #component float output? */ |
| 39 |
+ |
|
| 40 |
|
char StandardInput[] = "<stdin>"; |
| 41 |
|
char Command[] = "<Command>"; |
| 42 |
|
char vcolin[3][4] = {"ri", "gi", "bi"}; |
| 70 |
|
|
| 71 |
|
int xpos, ypos; /* output position */ |
| 72 |
|
|
| 69 |
– |
char *progname; /* global argv[0] */ |
| 70 |
– |
|
| 73 |
|
int echoheader = 1; |
| 74 |
|
int wrongformat = 0; |
| 75 |
|
int gotview; |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
static gethfunc headline; |
| 79 |
< |
static void checkfile(void); |
| 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); |
| 98 |
|
int original; |
| 99 |
|
double f; |
| 100 |
|
int a; |
| 101 |
+ |
|
| 102 |
|
SET_DEFAULT_BINARY(); |
| 103 |
|
SET_FILE_BINARY(stdin); |
| 104 |
|
SET_FILE_BINARY(stdout); |
| 105 |
< |
progname = argv[0]; |
| 105 |
> |
fixargv0(argv[0]); /* sets global progname */ |
| 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] == '-') |
| 120 |
|
echoheader = !echoheader; |
| 121 |
|
continue; |
| 122 |
|
case 'f': |
| 123 |
+ |
if (argv[a][2]) { |
| 124 |
+ |
outfloat = (argv[a][2] == 'f'); |
| 125 |
+ |
continue; |
| 126 |
+ |
} |
| 127 |
+ |
/* fall through */ |
| 128 |
|
case 'e': |
| 129 |
|
a++; |
| 130 |
|
continue; |
| 182 |
|
quit(1); |
| 183 |
|
} |
| 184 |
|
} |
| 185 |
< |
checkfile(); |
| 176 |
< |
if (original) { |
| 177 |
< |
colval(input[nfiles].coef,RED) /= |
| 178 |
< |
colval(input[nfiles].expos,RED); |
| 179 |
< |
colval(input[nfiles].coef,GRN) /= |
| 180 |
< |
colval(input[nfiles].expos,GRN); |
| 181 |
< |
colval(input[nfiles].coef,BLU) /= |
| 182 |
< |
colval(input[nfiles].expos,BLU); |
| 183 |
< |
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
| 184 |
< |
} |
| 185 |
> |
checkfile(original); |
| 186 |
|
nfiles++; |
| 187 |
|
original = 0; |
| 188 |
|
} |
| 189 |
|
init(); /* set constants */ |
| 190 |
|
/* go back and get expressions */ |
| 191 |
|
for (a = 1; a < argc; a++) { |
| 192 |
+ |
char *fpath; |
| 193 |
|
if (argv[a][0] == '-') |
| 194 |
|
switch (argv[a][1]) { |
| 195 |
|
case 'x': |
| 203 |
|
case 'h': |
| 204 |
|
continue; |
| 205 |
|
case 'f': |
| 206 |
< |
fcompile(argv[++a]); |
| 206 |
> |
if (argv[a][2]) |
| 207 |
> |
continue; |
| 208 |
> |
fpath = getpath(argv[++a], getrlibpath(), 0); |
| 209 |
> |
if (fpath == NULL) { |
| 210 |
> |
eputs(argv[0]); |
| 211 |
> |
eputs(": cannot find file '"); |
| 212 |
> |
eputs(argv[a]); |
| 213 |
> |
eputs("'\n"); |
| 214 |
> |
quit(1); |
| 215 |
> |
} |
| 216 |
> |
fcompile(fpath); |
| 217 |
|
continue; |
| 218 |
|
case 'e': |
| 219 |
|
scompile(argv[++a], NULL, 0); |
| 221 |
|
} |
| 222 |
|
break; |
| 223 |
|
} |
| 224 |
< |
/* set/get output resolution */ |
| 213 |
< |
if (!vardefined(vxres)) |
| 214 |
< |
varset(vxres, ':', (double)xmax); |
| 215 |
< |
if (!vardefined(vyres)) |
| 216 |
< |
varset(vyres, ':', (double)ymax); |
| 224 |
> |
/* get output resolution */ |
| 225 |
|
xres = varvalue(vxres) + .5; |
| 226 |
|
yres = varvalue(vyres) + .5; |
| 227 |
|
if (xres <= 0 || yres <= 0) { |
| 229 |
|
eputs(": illegal output resolution\n"); |
| 230 |
|
quit(1); |
| 231 |
|
} |
| 232 |
< |
/* complete header */ |
| 233 |
< |
printargs(argc, argv, stdout); |
| 234 |
< |
if (strcmp(ourfmt, PICFMT)) |
| 235 |
< |
fputformat(ourfmt, stdout); /* print format if known */ |
| 236 |
< |
putchar('\n'); |
| 237 |
< |
fprtresolu(xres, yres, stdout); |
| 238 |
< |
/* combine pictures */ |
| 239 |
< |
combine(); |
| 232 |
> |
if (!vardefined(vbrtout)) /* single or 3-channel? */ |
| 233 |
> |
outfloat *= 3; |
| 234 |
> |
|
| 235 |
> |
printargs(argc, argv, stdout); /* complete header */ |
| 236 |
> |
if (commvp != NULL) { |
| 237 |
> |
fputs(VIEWSTR, stdout); |
| 238 |
> |
fprintview(commvp, stdout); |
| 239 |
> |
fputc('\n', stdout); |
| 240 |
> |
} |
| 241 |
> |
if (outfloat) { /* print output format */ |
| 242 |
> |
printf("NROWS=%d\nNCOLS=%d\n", yres, xres); |
| 243 |
> |
fputncomp(outfloat, stdout); |
| 244 |
> |
fputendian(stdout); |
| 245 |
> |
fputformat("float", stdout); |
| 246 |
> |
} else if (strcmp(ourfmt, PICFMT)) |
| 247 |
> |
fputformat(ourfmt, stdout); |
| 248 |
> |
else |
| 249 |
> |
fputformat(COLRFMT, stdout); |
| 250 |
> |
fputc('\n', stdout); /* end header */ |
| 251 |
> |
if (!outfloat) |
| 252 |
> |
fprtresolu(xres, yres, stdout); |
| 253 |
> |
|
| 254 |
> |
doptimize(1); /* optimize definitions */ |
| 255 |
> |
combine(); /* combine pictures */ |
| 256 |
|
quit(0); |
| 257 |
|
usage: |
| 258 |
|
eputs("Usage: "); |
| 259 |
|
eputs(argv[0]); |
| 260 |
|
eputs( |
| 261 |
< |
" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
| 261 |
> |
" [-w][-h][-ff][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] hdr ..]\n"); |
| 262 |
|
quit(1); |
| 263 |
|
return 1; /* pro forma return */ |
| 264 |
|
} |
| 270 |
|
void *p |
| 271 |
|
) |
| 272 |
|
{ |
| 273 |
< |
char fmt[32]; |
| 273 |
> |
int orig = *(int *)p; |
| 274 |
> |
char fmt[MAXFMTLEN]; |
| 275 |
|
double d; |
| 276 |
+ |
int bigend; |
| 277 |
|
COLOR ctmp; |
| 278 |
|
|
| 279 |
|
if (isheadid(s)) /* header id */ |
| 282 |
|
if (globmatch(ourfmt, fmt)) { |
| 283 |
|
wrongformat = 0; |
| 284 |
|
strcpy(ourfmt, fmt); |
| 285 |
< |
} else |
| 285 |
> |
} else if (!strcmp("float", fmt)) |
| 286 |
> |
input[nfiles].infloat *= -1; |
| 287 |
> |
else |
| 288 |
|
wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; |
| 289 |
|
return(0); /* don't echo */ |
| 290 |
|
} |
| 291 |
< |
if (isexpos(s)) { /* exposure */ |
| 291 |
> |
if ((bigend = isbigendian(s)) >= 0) { |
| 292 |
> |
if (bigend != nativebigendian()) { |
| 293 |
> |
eputs(input[nfiles].name); |
| 294 |
> |
eputs(": unsupported input byte ordering\n"); |
| 295 |
> |
quit(1); |
| 296 |
> |
} |
| 297 |
> |
return(0); /* don't echo */ |
| 298 |
> |
} |
| 299 |
> |
if (!strncmp("NROWS=", s, 6)) { /* X-resolution */ |
| 300 |
> |
input[nfiles].rs.yr = atoi(s+6); |
| 301 |
> |
return(0); /* don't echo */ |
| 302 |
> |
} |
| 303 |
> |
if (!strncmp("NCOLS=", s, 6)) { /* Y-resolution */ |
| 304 |
> |
input[nfiles].rs.xr = atoi(s+6); |
| 305 |
> |
return(0); /* don't echo */ |
| 306 |
> |
} |
| 307 |
> |
if (isncomp(s)) /* # components */ |
| 308 |
> |
input[nfiles].infloat *= ncompval(s); |
| 309 |
> |
|
| 310 |
> |
if (orig) { /* undo exposure? */ |
| 311 |
> |
if (isexpos(s)) { |
| 312 |
> |
d = 1./exposval(s); |
| 313 |
> |
scalecolor(input[nfiles].coef, d); |
| 314 |
> |
return(0); /* don't echo */ |
| 315 |
> |
} |
| 316 |
> |
if (iscolcor(s)) { |
| 317 |
> |
int i; |
| 318 |
> |
colcorval(ctmp, s); |
| 319 |
> |
for (i = 3; i--; ) |
| 320 |
> |
colval(input[nfiles].coef,i) /= colval(ctmp,i); |
| 321 |
> |
return(0); /* don't echo */ |
| 322 |
> |
} |
| 323 |
> |
} else if (isexpos(s)) { /* record exposure? */ |
| 324 |
|
d = exposval(s); |
| 325 |
|
scalecolor(input[nfiles].expos, d); |
| 326 |
< |
} else if (iscolcor(s)) { /* color correction */ |
| 326 |
> |
} else if (iscolcor(s)) { |
| 327 |
|
colcorval(ctmp, s); |
| 328 |
|
multcolor(input[nfiles].expos, ctmp); |
| 329 |
< |
} else if (isaspect(s)) |
| 329 |
> |
} |
| 330 |
> |
if (isaspect(s)) |
| 331 |
|
input[nfiles].pa *= aspectval(s); |
| 332 |
|
else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) |
| 333 |
|
gotview++; |
| 341 |
|
|
| 342 |
|
|
| 343 |
|
static void |
| 344 |
< |
checkfile(void) /* ready a file */ |
| 344 |
> |
checkfile(int orig) /* ready a file */ |
| 345 |
|
{ |
| 346 |
< |
register int i; |
| 346 |
> |
int i; |
| 347 |
|
/* process header */ |
| 348 |
|
gotview = 0; |
| 349 |
+ |
input[nfiles].infloat = -1; |
| 350 |
+ |
input[nfiles].rs.rt = PIXSTANDARD; |
| 351 |
+ |
input[nfiles].rs.xr = input[nfiles].rs.yr = 0; |
| 352 |
|
if (echoheader) { |
| 353 |
|
fputs(input[nfiles].name, stdout); |
| 354 |
|
fputs(":\n", stdout); |
| 355 |
|
} |
| 356 |
< |
getheader(input[nfiles].fp, headline, NULL); |
| 356 |
> |
getheader(input[nfiles].fp, headline, &orig); |
| 357 |
> |
|
| 358 |
> |
if (input[nfiles].infloat <= 0) |
| 359 |
> |
input[nfiles].infloat = 0; |
| 360 |
> |
else if ((input[nfiles].infloat != 3) & |
| 361 |
> |
(input[nfiles].infloat != 1)) { |
| 362 |
> |
eputs(input[nfiles].name); |
| 363 |
> |
eputs(": unsupported number of components\n"); |
| 364 |
> |
quit(1); |
| 365 |
> |
} |
| 366 |
|
if (wrongformat < 0) { |
| 367 |
|
eputs(input[nfiles].name); |
| 368 |
< |
eputs(": not a Radiance picture\n"); |
| 368 |
> |
eputs(": not a Radiance picture or float matrix\n"); |
| 369 |
|
quit(1); |
| 370 |
|
} |
| 371 |
|
if (wrongformat > 0) { |
| 374 |
|
} |
| 375 |
|
if (!gotview || setview(&input[nfiles].vw) != NULL) |
| 376 |
|
input[nfiles].vw.type = 0; |
| 377 |
< |
if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
| 377 |
> |
else if (commvp == NULL) |
| 378 |
> |
commvp = &input[nfiles].vw; |
| 379 |
> |
if ((input[nfiles].rs.xr <= 0) | (input[nfiles].rs.yr <= 0) && |
| 380 |
> |
!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
| 381 |
|
eputs(input[nfiles].name); |
| 382 |
|
eputs(": bad picture size\n"); |
| 383 |
|
quit(1); |
| 421 |
|
static void |
| 422 |
|
init(void) /* perform final setup */ |
| 423 |
|
{ |
| 424 |
< |
register int i; |
| 424 |
> |
int i; |
| 425 |
|
/* define constants */ |
| 426 |
|
varset("PI", ':', PI); |
| 427 |
|
varset(vnfiles, ':', (double)nfiles); |
| 444 |
|
ourbright = xyz_bright; |
| 445 |
|
} else |
| 446 |
|
varset(vwhteff, ':', WHTEFFICACY); |
| 447 |
+ |
/* these may be overridden */ |
| 448 |
+ |
varset(vxres, ':', (double)xmax); |
| 449 |
+ |
varset(vyres, ':', (double)ymax); |
| 450 |
|
} |
| 451 |
|
|
| 452 |
|
|
| 454 |
|
combine(void) /* combine pictures */ |
| 455 |
|
{ |
| 456 |
|
EPNODE *coldef[3], *brtdef; |
| 457 |
+ |
int set_x, set_y; |
| 458 |
|
COLOR *scanout; |
| 459 |
|
double d; |
| 460 |
< |
register int i, j; |
| 460 |
> |
int i, j; |
| 461 |
|
/* check defined variables */ |
| 462 |
|
for (j = 0; j < 3; j++) { |
| 463 |
|
if (vardefined(vcolout[j])) |
| 469 |
|
brtdef = eparse(vbrtout); |
| 470 |
|
else |
| 471 |
|
brtdef = NULL; |
| 472 |
+ |
/* what to set */ |
| 473 |
+ |
set_x = varlookup(vxpos) != NULL && !vardefined(vxpos); |
| 474 |
+ |
set_y = varlookup(vypos) != NULL && !vardefined(vypos); |
| 475 |
|
/* allocate scanline */ |
| 476 |
|
scanout = (COLOR *)emalloc(xres*sizeof(COLOR)); |
| 477 |
|
/* set input position */ |
| 479 |
|
/* combine files */ |
| 480 |
|
for (ypos = yres-1; ypos >= 0; ypos--) { |
| 481 |
|
advance(); |
| 482 |
< |
varset(vypos, '=', (double)ypos); |
| 482 |
> |
if (set_y) varset(vypos, '=', (double)ypos); |
| 483 |
|
for (xpos = 0; xpos < xres; xpos++) { |
| 484 |
< |
xscan = (long)xpos*xmax/xres; |
| 485 |
< |
varset(vxpos, '=', (double)xpos); |
| 484 |
> |
xscan = (xpos+.5)*xmax/xres; |
| 485 |
> |
if (set_x) varset(vxpos, '=', (double)xpos); |
| 486 |
|
eclock++; |
| 487 |
|
if (brtdef != NULL) { |
| 488 |
|
d = evalue(brtdef); |
| 489 |
< |
if (d < 0.0) |
| 407 |
< |
d = 0.0; |
| 489 |
> |
d *= (outfloat > 0) | (d >= 0); |
| 490 |
|
setcolor(scanout[xpos], d, d, d); |
| 491 |
|
} else { |
| 492 |
|
for (j = 0; j < 3; j++) { |
| 497 |
|
for (i = 0; i < nfiles; i++) |
| 498 |
|
d += colval(input[i].scan[MIDSCN][xscan],j); |
| 499 |
|
} |
| 500 |
< |
if (d < 0.0) |
| 419 |
< |
d = 0.0; |
| 500 |
> |
d *= (outfloat > 0) | (d >= 0); |
| 501 |
|
colval(scanout[xpos],j) = d; |
| 502 |
|
} |
| 503 |
|
} |
| 504 |
|
} |
| 505 |
< |
if (fwritescan(scanout, xres, stdout) < 0) { |
| 506 |
< |
perror("write error"); |
| 507 |
< |
quit(1); |
| 505 |
> |
switch (outfloat) { |
| 506 |
> |
case 3: /* writing out float triplets */ |
| 507 |
> |
if (fwrite(scanout, sizeof(float)*3, xres, stdout) != xres) |
| 508 |
> |
goto writerr; |
| 509 |
> |
break; |
| 510 |
> |
case 1: /* writing out gray float values */ |
| 511 |
> |
for (xpos = 0; xpos < xres; xpos++) |
| 512 |
> |
if (putbinary(&scanout[xpos][CIEY], |
| 513 |
> |
sizeof(float), 1, stdout) != 1) |
| 514 |
> |
goto writerr; |
| 515 |
> |
break; |
| 516 |
> |
default: /* writing out Radiance picture */ |
| 517 |
> |
if (fwritescan(scanout, xres, stdout) < 0) |
| 518 |
> |
goto writerr; |
| 519 |
> |
break; |
| 520 |
|
} |
| 521 |
|
} |
| 522 |
|
efree((char *)scanout); |
| 523 |
+ |
return; |
| 524 |
+ |
writerr: |
| 525 |
+ |
perror("write error"); |
| 526 |
+ |
quit(1); |
| 527 |
|
} |
| 528 |
|
|
| 529 |
|
|
| 531 |
|
advance(void) /* read in data for next scanline */ |
| 532 |
|
{ |
| 533 |
|
int ytarget; |
| 534 |
< |
register COLOR *st; |
| 535 |
< |
register int i, j; |
| 534 |
> |
COLOR *st; |
| 535 |
> |
int i, j; |
| 536 |
|
|
| 537 |
< |
for (ytarget = (long)ypos*ymax/yres; yscan > ytarget; yscan--) |
| 537 |
> |
for (ytarget = (ypos+.5)*ymax/yres; yscan > ytarget; yscan--) |
| 538 |
|
for (i = 0; i < nfiles; i++) { |
| 539 |
|
st = input[i].scan[WINSIZ-1]; |
| 540 |
|
for (j = WINSIZ-1; j > 0; j--) /* rotate window */ |
| 542 |
|
input[i].scan[0] = st; |
| 543 |
|
if (yscan <= MIDSCN) /* hit bottom? */ |
| 544 |
|
continue; |
| 545 |
< |
if (freadscan(st, xmax, input[i].fp) < 0) { /* read */ |
| 546 |
< |
eputs(input[i].name); |
| 547 |
< |
eputs(": read error\n"); |
| 548 |
< |
quit(1); |
| 549 |
< |
} |
| 545 |
> |
/* read scanline */ |
| 546 |
> |
if (input[i].infloat) { |
| 547 |
> |
if (fread(st, sizeof(float)*input[i].infloat, |
| 548 |
> |
xmax, input[i].fp) != xmax) |
| 549 |
> |
goto readerr; |
| 550 |
> |
if (input[i].infloat == 1) { |
| 551 |
> |
const COLORV *f = st[0] + xmax; |
| 552 |
> |
int x = xmax; |
| 553 |
> |
while (x-- > 0) |
| 554 |
> |
st[x][BLU] = st[x][GRN] = |
| 555 |
> |
st[x][RED] = *--f; |
| 556 |
> |
} |
| 557 |
> |
} else if (freadscan(st, xmax, input[i].fp) < 0) |
| 558 |
> |
goto readerr; |
| 559 |
|
for (j = 0; j < xmax; j++) /* adjust color */ |
| 560 |
|
multcolor(st[j], input[i].coef); |
| 561 |
|
} |
| 562 |
+ |
return; |
| 563 |
+ |
readerr: |
| 564 |
+ |
eputs(input[i].name); |
| 565 |
+ |
eputs(": read error\n"); |
| 566 |
+ |
quit(1); |
| 567 |
|
} |
| 568 |
|
|
| 569 |
|
|
| 570 |
|
static double |
| 571 |
|
l_expos( /* return picture exposure */ |
| 572 |
< |
register char *nam |
| 572 |
> |
char *nam |
| 573 |
|
) |
| 574 |
|
{ |
| 575 |
< |
register int fn, n; |
| 575 |
> |
int fn, n; |
| 576 |
> |
double d; |
| 577 |
|
|
| 578 |
< |
fn = argument(1) - .5; |
| 579 |
< |
if (fn < 0 || fn >= nfiles) |
| 580 |
< |
return(1.0); |
| 578 |
> |
d = argument(1); |
| 579 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 580 |
> |
errno = EDOM; |
| 581 |
> |
return(0.0); |
| 582 |
> |
} |
| 583 |
> |
if (d < 0.5) |
| 584 |
> |
return((double)nfiles); |
| 585 |
> |
fn = d - 0.5; |
| 586 |
|
if (nam == vbrtexp) |
| 587 |
|
return((*ourbright)(input[fn].expos)); |
| 588 |
|
n = 3; |
| 598 |
|
static double |
| 599 |
|
l_pixaspect(char *nm) /* return pixel aspect ratio */ |
| 600 |
|
{ |
| 601 |
< |
register int fn; |
| 601 |
> |
int fn; |
| 602 |
> |
double d; |
| 603 |
|
|
| 604 |
< |
fn = argument(1) - .5; |
| 605 |
< |
if (fn < 0 || fn >= nfiles) |
| 606 |
< |
return(1.0); |
| 604 |
> |
d = argument(1); |
| 605 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 606 |
> |
errno = EDOM; |
| 607 |
> |
return(0.0); |
| 608 |
> |
} |
| 609 |
> |
if (d < 0.5) |
| 610 |
> |
return((double)nfiles); |
| 611 |
> |
fn = d - 0.5; |
| 612 |
|
return(input[fn].pa); |
| 613 |
|
} |
| 614 |
|
|
| 615 |
|
|
| 616 |
|
static double |
| 617 |
|
l_colin( /* return color value for picture */ |
| 618 |
< |
register char *nam |
| 618 |
> |
char *nam |
| 619 |
|
) |
| 620 |
|
{ |
| 621 |
|
int fn; |
| 622 |
< |
register int n, xoff, yoff; |
| 622 |
> |
int n, xoff, yoff; |
| 623 |
|
double d; |
| 624 |
|
|
| 625 |
< |
fn = argument(1) - .5; |
| 626 |
< |
if (fn < 0 || fn >= nfiles) { |
| 625 |
> |
d = argument(1); |
| 626 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 627 |
|
errno = EDOM; |
| 628 |
|
return(0.0); |
| 629 |
|
} |
| 630 |
+ |
if (d < 0.5) |
| 631 |
+ |
return((double)nfiles); |
| 632 |
+ |
fn = d - 0.5; |
| 633 |
|
xoff = yoff = 0; |
| 634 |
|
n = nargum(); |
| 635 |
|
if (n >= 2) { |
| 674 |
|
|
| 675 |
|
static double |
| 676 |
|
l_ray( /* return ray origin or direction */ |
| 677 |
< |
register char *nam |
| 677 |
> |
char *nam |
| 678 |
|
) |
| 679 |
|
{ |
| 680 |
|
static unsigned long ltick[MAXINP]; |
| 681 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
| 682 |
|
static double ldist[MAXINP]; |
| 683 |
|
RREAL loc[2]; |
| 684 |
+ |
double d; |
| 685 |
|
int fn; |
| 686 |
< |
register int i; |
| 686 |
> |
int i; |
| 687 |
|
|
| 688 |
< |
fn = argument(1) - .5; |
| 689 |
< |
if (fn < 0 || fn >= nfiles) { |
| 688 |
> |
d = argument(1); |
| 689 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 690 |
|
errno = EDOM; |
| 691 |
|
return(0.0); |
| 692 |
|
} |
| 693 |
+ |
if (d < 0.5) |
| 694 |
+ |
return((double)nfiles); |
| 695 |
+ |
fn = d - 0.5; |
| 696 |
|
if (ltick[fn] != eclock) { /* need to compute? */ |
| 697 |
< |
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
| 698 |
< |
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
| 699 |
< |
ldist[fn] = -1.0; |
| 700 |
< |
if (input[fn].vw.type == 0) |
| 697 |
> |
if (input[fn].vw.type == 0) { |
| 698 |
> |
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
| 699 |
> |
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
| 700 |
> |
ldist[fn] = -1.0; |
| 701 |
|
errno = EDOM; |
| 702 |
< |
else { |
| 702 |
> |
} else { |
| 703 |
|
pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan); |
| 704 |
|
ldist[fn] = viewray(lorg[fn], ldir[fn], |
| 705 |
|
&input[fn].vw, loc[0], loc[1]); |
| 706 |
+ |
if (ldist[fn] < -FTINY) |
| 707 |
+ |
errno = EDOM; |
| 708 |
|
} |
| 709 |
|
ltick[fn] = eclock; |
| 710 |
|
} |
| 728 |
|
RREAL locx[2], locy[2]; |
| 729 |
|
double d; |
| 730 |
|
int fn; |
| 731 |
< |
register int i; |
| 731 |
> |
int i; |
| 732 |
|
|
| 733 |
|
d = argument(1); |
| 734 |
< |
if (d < .5 || d >= nfiles+.5) { |
| 734 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 735 |
|
errno = EDOM; |
| 736 |
|
return(0.0); |
| 737 |
|
} |
| 738 |
< |
fn = d - .5; |
| 738 |
> |
if (d < 0.5) |
| 739 |
> |
return((double)nfiles); |
| 740 |
> |
fn = d - 0.5; |
| 741 |
|
if (ltick[fn] != eclock) { /* need to compute? */ |
| 742 |
|
psize[fn] = 0.0; |
| 743 |
|
if (input[fn].vw.type == 0) |
| 768 |
|
|
| 769 |
|
|
| 770 |
|
extern void |
| 771 |
< |
wputs(char *msg) |
| 771 |
> |
wputs(const char *msg) |
| 772 |
|
{ |
| 773 |
|
if (!nowarn) |
| 774 |
|
eputs(msg); |
| 776 |
|
|
| 777 |
|
|
| 778 |
|
extern void |
| 779 |
< |
eputs(char *msg) |
| 779 |
> |
eputs(const char *msg) |
| 780 |
|
{ |
| 781 |
|
fputs(msg, stderr); |
| 782 |
|
} |
| 785 |
|
extern void |
| 786 |
|
quit(int code) /* exit gracefully */ |
| 787 |
|
{ |
| 788 |
< |
register int i; |
| 788 |
> |
int i; |
| 789 |
|
/* close input files */ |
| 790 |
|
for (i = 0; i < nfiles; i++) |
| 791 |
|
if (input[i].name == Command) |