| 8 | 
  | 
 */ | 
| 9 | 
  | 
 | 
| 10 | 
  | 
#include "platform.h" | 
| 11 | 
+ | 
#include "standard.h" | 
| 12 | 
  | 
#include "rtprocess.h" | 
| 12 | 
– | 
#include "rterror.h" | 
| 13 | 
  | 
#include "color.h" | 
| 14 | 
  | 
#include "calcomp.h" | 
| 15 | 
  | 
#include "view.h" | 
| 72 | 
  | 
int     gotview; | 
| 73 | 
  | 
 | 
| 74 | 
  | 
 | 
| 75 | 
– | 
extern char     *emalloc(); | 
| 76 | 
– | 
 | 
| 75 | 
  | 
static gethfunc tabputs; | 
| 76 | 
+ | 
static void checkfile(void); | 
| 77 | 
+ | 
static double rgb_bright(COLOR  clr); | 
| 78 | 
+ | 
static double xyz_bright(COLOR  clr); | 
| 79 | 
+ | 
static void init(void); | 
| 80 | 
+ | 
static void combine(void); | 
| 81 | 
+ | 
static void advance(void); | 
| 82 | 
+ | 
static double l_expos(char      *nam); | 
| 83 | 
+ | 
static double l_pixaspect(char *nm); | 
| 84 | 
+ | 
static double l_colin(char      *nam); | 
| 85 | 
+ | 
static double l_ray(char        *nam); | 
| 86 | 
+ | 
static double l_psize(char *nm); | 
| 87 | 
  | 
 | 
| 88 | 
< | 
main(argc, argv) | 
| 89 | 
< | 
int     argc; | 
| 90 | 
< | 
char    *argv[]; | 
| 88 | 
> | 
 | 
| 89 | 
> | 
int | 
| 90 | 
> | 
main( | 
| 91 | 
> | 
        int     argc, | 
| 92 | 
> | 
        char    *argv[] | 
| 93 | 
> | 
) | 
| 94 | 
  | 
{ | 
| 95 | 
  | 
        int     original; | 
| 96 | 
  | 
        double  f; | 
| 97 | 
< | 
        int     a, i; | 
| 97 | 
> | 
        int     a; | 
| 98 | 
  | 
        SET_DEFAULT_BINARY(); | 
| 99 | 
  | 
        SET_FILE_BINARY(stdin); | 
| 100 | 
  | 
        SET_FILE_BINARY(stdout); | 
| 230 | 
  | 
        eputs( | 
| 231 | 
  | 
" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); | 
| 232 | 
  | 
        quit(1); | 
| 233 | 
+ | 
        return 1; /* pro forma return */ | 
| 234 | 
  | 
} | 
| 235 | 
  | 
 | 
| 236 | 
  | 
 | 
| 270 | 
  | 
} | 
| 271 | 
  | 
 | 
| 272 | 
  | 
 | 
| 273 | 
< | 
checkfile()                     /* ready a file */ | 
| 273 | 
> | 
static void | 
| 274 | 
> | 
checkfile(void)                 /* ready a file */ | 
| 275 | 
  | 
{ | 
| 276 | 
  | 
        register int    i; | 
| 277 | 
  | 
                                        /* process header */ | 
| 310 | 
  | 
} | 
| 311 | 
  | 
 | 
| 312 | 
  | 
 | 
| 313 | 
< | 
double | 
| 314 | 
< | 
rgb_bright(clr) | 
| 315 | 
< | 
COLOR  clr; | 
| 313 | 
> | 
static double | 
| 314 | 
> | 
rgb_bright( | 
| 315 | 
> | 
        COLOR  clr | 
| 316 | 
> | 
) | 
| 317 | 
  | 
{ | 
| 318 | 
  | 
        return(bright(clr)); | 
| 319 | 
  | 
} | 
| 320 | 
  | 
 | 
| 321 | 
  | 
 | 
| 322 | 
< | 
double | 
| 323 | 
< | 
xyz_bright(clr) | 
| 324 | 
< | 
COLOR  clr; | 
| 322 | 
> | 
static double | 
| 323 | 
> | 
xyz_bright( | 
| 324 | 
> | 
        COLOR  clr | 
| 325 | 
> | 
) | 
| 326 | 
  | 
{ | 
| 327 | 
  | 
        return(clr[CIEY]); | 
| 328 | 
  | 
} | 
| 331 | 
  | 
double  (*ourbright)() = rgb_bright; | 
| 332 | 
  | 
 | 
| 333 | 
  | 
 | 
| 334 | 
< | 
init()                                  /* perform final setup */ | 
| 334 | 
> | 
static void | 
| 335 | 
> | 
init(void)                                      /* perform final setup */ | 
| 336 | 
  | 
{ | 
| 320 | 
– | 
        double  l_colin(char *), l_expos(char *), l_pixaspect(char *), | 
| 321 | 
– | 
                        l_ray(char *), l_psize(char *); | 
| 337 | 
  | 
        register int    i; | 
| 338 | 
  | 
                                                /* define constants */ | 
| 339 | 
  | 
        varset("PI", ':', PI); | 
| 360 | 
  | 
} | 
| 361 | 
  | 
 | 
| 362 | 
  | 
 | 
| 363 | 
< | 
combine()                       /* combine pictures */ | 
| 363 | 
> | 
static void | 
| 364 | 
> | 
combine(void)                   /* combine pictures */ | 
| 365 | 
  | 
{ | 
| 366 | 
  | 
        EPNODE  *coldef[3], *brtdef; | 
| 367 | 
  | 
        COLOR   *scanout; | 
| 419 | 
  | 
} | 
| 420 | 
  | 
 | 
| 421 | 
  | 
 | 
| 422 | 
< | 
advance()                       /* read in data for next scanline */ | 
| 422 | 
> | 
static void | 
| 423 | 
> | 
advance(void)                   /* read in data for next scanline */ | 
| 424 | 
  | 
{ | 
| 425 | 
  | 
        int     ytarget; | 
| 426 | 
  | 
        register COLOR  *st; | 
| 448 | 
  | 
} | 
| 449 | 
  | 
 | 
| 450 | 
  | 
 | 
| 451 | 
< | 
double | 
| 452 | 
< | 
l_expos(nam)                    /* return picture exposure */ | 
| 453 | 
< | 
register char   *nam; | 
| 451 | 
> | 
static double | 
| 452 | 
> | 
l_expos(                        /* return picture exposure */ | 
| 453 | 
> | 
        register char   *nam | 
| 454 | 
> | 
) | 
| 455 | 
  | 
{ | 
| 456 | 
  | 
        register int    fn, n; | 
| 457 | 
  | 
 | 
| 466 | 
  | 
                        return(colval(input[fn].expos,n)); | 
| 467 | 
  | 
        eputs("Bad call to l_expos()!\n"); | 
| 468 | 
  | 
        quit(1); | 
| 469 | 
+ | 
        return 1; /* pro forma return */ | 
| 470 | 
  | 
} | 
| 471 | 
  | 
 | 
| 472 | 
  | 
 | 
| 473 | 
< | 
double | 
| 473 | 
> | 
static double | 
| 474 | 
  | 
l_pixaspect(char *nm)           /* return pixel aspect ratio */ | 
| 475 | 
  | 
{ | 
| 476 | 
  | 
        register int    fn; | 
| 482 | 
  | 
} | 
| 483 | 
  | 
 | 
| 484 | 
  | 
 | 
| 485 | 
< | 
double | 
| 486 | 
< | 
l_colin(nam)                    /* return color value for picture */ | 
| 487 | 
< | 
register char   *nam; | 
| 485 | 
> | 
static double | 
| 486 | 
> | 
l_colin(                        /* return color value for picture */ | 
| 487 | 
> | 
        register char   *nam | 
| 488 | 
> | 
) | 
| 489 | 
  | 
{ | 
| 490 | 
  | 
        int     fn; | 
| 491 | 
  | 
        register int    n, xoff, yoff; | 
| 534 | 
  | 
                return(colval(input[fn].scan[MIDSCN+yoff][xscan+xoff],n)); | 
| 535 | 
  | 
        eputs("Bad call to l_colin()!\n"); | 
| 536 | 
  | 
        quit(1); | 
| 537 | 
+ | 
        return 1; /* pro forma return */ | 
| 538 | 
  | 
} | 
| 539 | 
  | 
 | 
| 540 | 
  | 
 | 
| 541 | 
< | 
double | 
| 542 | 
< | 
l_ray(nam)              /* return ray origin or direction */ | 
| 543 | 
< | 
register char   *nam; | 
| 541 | 
> | 
static double | 
| 542 | 
> | 
l_ray(          /* return ray origin or direction */ | 
| 543 | 
> | 
        register char   *nam | 
| 544 | 
> | 
) | 
| 545 | 
  | 
{ | 
| 546 | 
  | 
        static unsigned long    ltick[MAXINP]; | 
| 547 | 
  | 
        static FVECT    lorg[MAXINP], ldir[MAXINP]; | 
| 575 | 
  | 
                        return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]); | 
| 576 | 
  | 
        eputs("Bad call to l_ray()!\n"); | 
| 577 | 
  | 
        quit(1); | 
| 578 | 
+ | 
        return 1; /* pro forma return */ | 
| 579 | 
  | 
} | 
| 580 | 
  | 
 | 
| 581 | 
  | 
 | 
| 582 | 
< | 
double | 
| 582 | 
> | 
static double | 
| 583 | 
  | 
l_psize(char *nm)               /* compute pixel size in steradians */ | 
| 584 | 
  | 
{ | 
| 585 | 
  | 
        static unsigned long    ltick[MAXINP]; | 
| 601 | 
  | 
                if (input[fn].vw.type == 0) | 
| 602 | 
  | 
                        errno = EDOM; | 
| 603 | 
  | 
                else if (input[fn].vw.type != VT_PAR && | 
| 604 | 
< | 
                                funvalue(vray[6], 1, &d) >= 0) { | 
| 604 | 
> | 
                                funvalue(vray[6], 1, &d) > FTINY) { | 
| 605 | 
  | 
                        for (i = 0; i < 3; i++) | 
| 606 | 
  | 
                                dir0[i] = funvalue(vray[3+i], 1, &d); | 
| 607 | 
  | 
                        pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan); | 
| 608 | 
  | 
                        pix2loc(locy, &input[fn].rs, xscan, ymax-yscan); | 
| 609 | 
  | 
                        if (viewray(org, dirx, &input[fn].vw, | 
| 610 | 
< | 
                                        locx[0], locx[1]) >= 0 && | 
| 610 | 
> | 
                                        locx[0], locx[1]) >= -FTINY && | 
| 611 | 
  | 
                                        viewray(org, diry, &input[fn].vw, | 
| 612 | 
< | 
                                        locy[0], locy[1]) >= 0) { | 
| 612 | 
> | 
                                        locy[0], locy[1]) >= -FTINY) { | 
| 613 | 
  | 
                                                /* approximate solid angle */ | 
| 614 | 
  | 
                                for (i = 0; i < 3; i++) { | 
| 615 | 
  | 
                                        dirx[i] -= dir0[i]; | 
| 616 | 
  | 
                                        diry[i] -= dir0[i]; | 
| 617 | 
  | 
                                } | 
| 618 | 
  | 
                                fcross(dir0, dirx, diry); | 
| 619 | 
< | 
                                psize[fn] = sqrt(DOT(dir0,dir0)); | 
| 619 | 
> | 
                                psize[fn] = VLEN(dir0); | 
| 620 | 
  | 
                        } | 
| 621 | 
  | 
                } | 
| 622 | 
  | 
                ltick[fn] = eclock; |