| 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 <stdio.h> | 
| 11 | 
< | 
 | 
| 12 | 
< | 
#include <errno.h> | 
| 16 | 
< | 
 | 
| 10 | 
> | 
#include "platform.h" | 
| 11 | 
> | 
#include "rtprocess.h" | 
| 12 | 
> | 
#include "rterror.h" | 
| 13 | 
  | 
#include "color.h" | 
| 18 | 
– | 
 | 
| 19 | 
– | 
#include  "resolu.h" | 
| 20 | 
– | 
 | 
| 14 | 
  | 
#include "calcomp.h" | 
| 15 | 
+ | 
#include "view.h" | 
| 16 | 
  | 
 | 
| 17 | 
  | 
#define MAXINP          32              /* maximum number of input files */ | 
| 18 | 
< | 
#define WINSIZ          9               /* scanline window size */ | 
| 19 | 
< | 
#define MIDSCN          4               /* current scan position */ | 
| 18 | 
> | 
#define WINSIZ          64              /* scanline window size */ | 
| 19 | 
> | 
#define MIDSCN          ((WINSIZ-1)/2+1) | 
| 20 | 
  | 
 | 
| 21 | 
  | 
struct { | 
| 22 | 
  | 
        char    *name;          /* file or command name */ | 
| 23 | 
  | 
        FILE    *fp;            /* stream pointer */ | 
| 24 | 
+ | 
        VIEW    vw;             /* view for picture */ | 
| 25 | 
+ | 
        RESOLU  rs;             /* image resolution and orientation */ | 
| 26 | 
+ | 
        float   pa;             /* pixel aspect ratio */ | 
| 27 | 
  | 
        COLOR   *scan[WINSIZ];  /* input scanline window */ | 
| 28 | 
  | 
        COLOR   coef;           /* coefficient */ | 
| 29 | 
  | 
        COLOR   expos;          /* recorded exposure */ | 
| 31 | 
  | 
 | 
| 32 | 
  | 
int     nfiles;                         /* number of input files */ | 
| 33 | 
  | 
 | 
| 34 | 
+ | 
char    ourfmt[LPICFMT+1] = PICFMT;     /* input picture format */ | 
| 35 | 
+ | 
 | 
| 36 | 
+ | 
char    StandardInput[] = "<stdin>"; | 
| 37 | 
  | 
char    Command[] = "<Command>"; | 
| 38 | 
  | 
char    vcolin[3][4] = {"ri", "gi", "bi"}; | 
| 39 | 
  | 
char    vcolout[3][4] = {"ro", "go", "bo"}; | 
| 41 | 
  | 
char    vbrtout[] = "lo"; | 
| 42 | 
  | 
char    vcolexp[3][4] = {"re", "ge", "be"}; | 
| 43 | 
  | 
char    vbrtexp[] = "le"; | 
| 44 | 
+ | 
char    vpixaspect[] = "pa"; | 
| 45 | 
  | 
 | 
| 46 | 
+ | 
char    vray[7][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz", "T"}; | 
| 47 | 
+ | 
 | 
| 48 | 
+ | 
char    vpsize[] = "S"; | 
| 49 | 
+ | 
 | 
| 50 | 
  | 
char    vnfiles[] = "nfiles"; | 
| 51 | 
+ | 
char    vwhteff[] = "WE"; | 
| 52 | 
  | 
char    vxmax[] = "xmax"; | 
| 53 | 
  | 
char    vymax[] = "ymax"; | 
| 54 | 
  | 
char    vxres[] = "xres"; | 
| 66 | 
  | 
 | 
| 67 | 
  | 
int     xpos, ypos;                     /* output position */ | 
| 68 | 
  | 
 | 
| 69 | 
+ | 
char    *progname;                      /* global argv[0] */ | 
| 70 | 
+ | 
 | 
| 71 | 
  | 
int     wrongformat = 0; | 
| 72 | 
+ | 
int     gotview; | 
| 73 | 
  | 
 | 
| 65 | 
– | 
FILE    *popen(); | 
| 74 | 
  | 
 | 
| 75 | 
+ | 
extern char     *emalloc(); | 
| 76 | 
  | 
 | 
| 77 | 
+ | 
static gethfunc tabputs; | 
| 78 | 
+ | 
 | 
| 79 | 
  | 
main(argc, argv) | 
| 80 | 
  | 
int     argc; | 
| 81 | 
  | 
char    *argv[]; | 
| 83 | 
  | 
        int     original; | 
| 84 | 
  | 
        double  f; | 
| 85 | 
  | 
        int     a, i; | 
| 86 | 
+ | 
        SET_DEFAULT_BINARY(); | 
| 87 | 
+ | 
        SET_FILE_BINARY(stdin); | 
| 88 | 
+ | 
        SET_FILE_BINARY(stdout); | 
| 89 | 
+ | 
        progname = argv[0]; | 
| 90 | 
  | 
                                                /* scan options */ | 
| 91 | 
  | 
        for (a = 1; a < argc; a++) { | 
| 92 | 
  | 
                if (argv[a][0] == '-') | 
| 105 | 
  | 
                        } | 
| 106 | 
  | 
                break; | 
| 107 | 
  | 
        } | 
| 108 | 
+ | 
        newheader("RADIANCE", stdout);  /* start header */ | 
| 109 | 
+ | 
        fputnow(stdout); | 
| 110 | 
  | 
                                        /* process files */ | 
| 111 | 
  | 
        for (nfiles = 0; nfiles < MAXINP; nfiles++) { | 
| 112 | 
  | 
                setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); | 
| 113 | 
  | 
                setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); | 
| 114 | 
+ | 
                input[nfiles].vw = stdview; | 
| 115 | 
+ | 
                input[nfiles].pa = 1.0; | 
| 116 | 
  | 
        } | 
| 117 | 
  | 
        nfiles = 0; | 
| 118 | 
  | 
        original = 0; | 
| 125 | 
  | 
                if (argv[a][0] == '-') | 
| 126 | 
  | 
                        switch (argv[a][1]) { | 
| 127 | 
  | 
                        case '\0': | 
| 128 | 
< | 
                                input[nfiles].name = "<stdin>"; | 
| 128 | 
> | 
                                input[nfiles].name = StandardInput; | 
| 129 | 
  | 
                                input[nfiles].fp = stdin; | 
| 130 | 
  | 
                                break; | 
| 131 | 
  | 
                        case 'o': | 
| 164 | 
  | 
                                        colval(input[nfiles].expos,GRN); | 
| 165 | 
  | 
                        colval(input[nfiles].coef,BLU) /= | 
| 166 | 
  | 
                                        colval(input[nfiles].expos,BLU); | 
| 167 | 
+ | 
                        setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); | 
| 168 | 
  | 
                } | 
| 169 | 
  | 
                nfiles++; | 
| 170 | 
  | 
                original = 0; | 
| 205 | 
  | 
        } | 
| 206 | 
  | 
                                                /* complete header */ | 
| 207 | 
  | 
        printargs(argc, argv, stdout); | 
| 208 | 
< | 
        fputformat(COLRFMT, stdout); | 
| 208 | 
> | 
        if (strcmp(ourfmt, PICFMT)) | 
| 209 | 
> | 
                fputformat(ourfmt, stdout);     /* print format if known */ | 
| 210 | 
  | 
        putchar('\n'); | 
| 211 | 
  | 
        fprtresolu(xres, yres, stdout); | 
| 212 | 
  | 
                                                /* combine pictures */ | 
| 216 | 
  | 
        eputs("Usage: "); | 
| 217 | 
  | 
        eputs(argv[0]); | 
| 218 | 
  | 
        eputs( | 
| 219 | 
< | 
" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n"); | 
| 219 | 
> | 
" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); | 
| 220 | 
  | 
        quit(1); | 
| 221 | 
  | 
} | 
| 222 | 
  | 
 | 
| 223 | 
  | 
 | 
| 224 | 
< | 
tputs(s)                        /* put out string preceded by a tab */ | 
| 225 | 
< | 
char    *s; | 
| 224 | 
> | 
static int | 
| 225 | 
> | 
tabputs(                        /* put out string preceded by a tab */ | 
| 226 | 
> | 
        char    *s, | 
| 227 | 
> | 
        void    *p | 
| 228 | 
> | 
) | 
| 229 | 
  | 
{ | 
| 230 | 
  | 
        char    fmt[32]; | 
| 231 | 
  | 
        double  d; | 
| 232 | 
  | 
        COLOR   ctmp; | 
| 233 | 
  | 
 | 
| 234 | 
< | 
        if (isformat(s)) {                      /* check format */ | 
| 235 | 
< | 
                formatval(fmt, s); | 
| 236 | 
< | 
                wrongformat = strcmp(fmt, COLRFMT); | 
| 237 | 
< | 
                return;         /* don't echo */ | 
| 234 | 
> | 
        if (isheadid(s))                        /* header id */ | 
| 235 | 
> | 
                return(0);      /* don't echo */ | 
| 236 | 
> | 
        if (formatval(fmt, s)) {                /* check format */ | 
| 237 | 
> | 
                if (globmatch(ourfmt, fmt)) { | 
| 238 | 
> | 
                        wrongformat = 0; | 
| 239 | 
> | 
                        strcpy(ourfmt, fmt); | 
| 240 | 
> | 
                } else | 
| 241 | 
> | 
                        wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; | 
| 242 | 
> | 
                return(0);      /* don't echo */ | 
| 243 | 
  | 
        } | 
| 244 | 
  | 
        if (isexpos(s)) {                       /* exposure */ | 
| 245 | 
  | 
                d = exposval(s); | 
| 247 | 
  | 
        } else if (iscolcor(s)) {               /* color correction */ | 
| 248 | 
  | 
                colcorval(ctmp, s); | 
| 249 | 
  | 
                multcolor(input[nfiles].expos, ctmp); | 
| 250 | 
< | 
        } | 
| 250 | 
> | 
        } else if (isaspect(s)) | 
| 251 | 
> | 
                input[nfiles].pa *= aspectval(s); | 
| 252 | 
> | 
        else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) | 
| 253 | 
> | 
                gotview++; | 
| 254 | 
  | 
                                                /* echo line */ | 
| 255 | 
  | 
        putchar('\t'); | 
| 256 | 
< | 
        fputs(s, stdout); | 
| 256 | 
> | 
        return(fputs(s, stdout)); | 
| 257 | 
  | 
} | 
| 258 | 
  | 
 | 
| 259 | 
  | 
 | 
| 260 | 
  | 
checkfile()                     /* ready a file */ | 
| 261 | 
  | 
{ | 
| 230 | 
– | 
        int     xinp, yinp; | 
| 262 | 
  | 
        register int    i; | 
| 263 | 
  | 
                                        /* process header */ | 
| 264 | 
+ | 
        gotview = 0; | 
| 265 | 
  | 
        fputs(input[nfiles].name, stdout); | 
| 266 | 
  | 
        fputs(":\n", stdout); | 
| 267 | 
< | 
        getheader(input[nfiles].fp, tputs, NULL); | 
| 268 | 
< | 
        if (wrongformat) { | 
| 267 | 
> | 
        getheader(input[nfiles].fp, tabputs, NULL); | 
| 268 | 
> | 
        if (wrongformat < 0) { | 
| 269 | 
  | 
                eputs(input[nfiles].name); | 
| 270 | 
< | 
                eputs(": not in Radiance picture format\n"); | 
| 270 | 
> | 
                eputs(": not a Radiance picture\n"); | 
| 271 | 
  | 
                quit(1); | 
| 272 | 
  | 
        } | 
| 273 | 
< | 
        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) { | 
| 273 | 
> | 
        if (wrongformat > 0) { | 
| 274 | 
> | 
                wputs(input[nfiles].name); | 
| 275 | 
> | 
                wputs(": warning -- incompatible picture format\n"); | 
| 276 | 
> | 
        } | 
| 277 | 
> | 
        if (!gotview || setview(&input[nfiles].vw) != NULL) | 
| 278 | 
> | 
                input[nfiles].vw.type = 0; | 
| 279 | 
> | 
        if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { | 
| 280 | 
  | 
                eputs(input[nfiles].name); | 
| 281 | 
  | 
                eputs(": bad picture size\n"); | 
| 282 | 
  | 
                quit(1); | 
| 283 | 
  | 
        } | 
| 284 | 
  | 
        if (xmax == 0 && ymax == 0) { | 
| 285 | 
< | 
                xmax = xinp; | 
| 286 | 
< | 
                ymax = yinp; | 
| 287 | 
< | 
        } else if (xinp != xmax || yinp != ymax) { | 
| 285 | 
> | 
                xmax = scanlen(&input[nfiles].rs); | 
| 286 | 
> | 
                ymax = numscans(&input[nfiles].rs); | 
| 287 | 
> | 
        } else if (scanlen(&input[nfiles].rs) != xmax || | 
| 288 | 
> | 
                        numscans(&input[nfiles].rs) != ymax) { | 
| 289 | 
  | 
                eputs(input[nfiles].name); | 
| 290 | 
  | 
                eputs(": resolution mismatch\n"); | 
| 291 | 
  | 
                quit(1); | 
| 296 | 
  | 
} | 
| 297 | 
  | 
 | 
| 298 | 
  | 
 | 
| 299 | 
+ | 
double | 
| 300 | 
+ | 
rgb_bright(clr) | 
| 301 | 
+ | 
COLOR  clr; | 
| 302 | 
+ | 
{ | 
| 303 | 
+ | 
        return(bright(clr)); | 
| 304 | 
+ | 
} | 
| 305 | 
+ | 
 | 
| 306 | 
+ | 
 | 
| 307 | 
+ | 
double | 
| 308 | 
+ | 
xyz_bright(clr) | 
| 309 | 
+ | 
COLOR  clr; | 
| 310 | 
+ | 
{ | 
| 311 | 
+ | 
        return(clr[CIEY]); | 
| 312 | 
+ | 
} | 
| 313 | 
+ | 
 | 
| 314 | 
+ | 
 | 
| 315 | 
+ | 
double  (*ourbright)() = rgb_bright; | 
| 316 | 
+ | 
 | 
| 317 | 
+ | 
 | 
| 318 | 
  | 
init()                                  /* perform final setup */ | 
| 319 | 
  | 
{ | 
| 320 | 
< | 
        double  l_colin(), l_expos(); | 
| 320 | 
> | 
        double  l_colin(char *), l_expos(char *), l_pixaspect(char *), | 
| 321 | 
> | 
                        l_ray(char *), l_psize(char *); | 
| 322 | 
  | 
        register int    i; | 
| 323 | 
  | 
                                                /* define constants */ | 
| 324 | 
+ | 
        varset("PI", ':', PI); | 
| 325 | 
  | 
        varset(vnfiles, ':', (double)nfiles); | 
| 326 | 
  | 
        varset(vxmax, ':', (double)xmax); | 
| 327 | 
  | 
        varset(vymax, ':', (double)ymax); | 
| 332 | 
  | 
        } | 
| 333 | 
  | 
        funset(vbrtexp, 1, ':', l_expos); | 
| 334 | 
  | 
        funset(vbrtin, 1, '=', l_colin); | 
| 335 | 
+ | 
        funset(vpixaspect, 1, ':', l_pixaspect); | 
| 336 | 
+ | 
        for (i = 0; i < 7; i++) | 
| 337 | 
+ | 
                funset(vray[i], 1, '=', l_ray); | 
| 338 | 
+ | 
        funset(vpsize, 1, '=', l_psize); | 
| 339 | 
+ | 
                                                /* set brightness function */ | 
| 340 | 
+ | 
        if (!strcmp(ourfmt, CIEFMT)) { | 
| 341 | 
+ | 
                varset(vwhteff, ':', 1.0); | 
| 342 | 
+ | 
                ourbright = xyz_bright; | 
| 343 | 
+ | 
        } else | 
| 344 | 
+ | 
                varset(vwhteff, ':', WHTEFFICACY); | 
| 345 | 
  | 
} | 
| 346 | 
  | 
 | 
| 347 | 
  | 
 | 
| 399 | 
  | 
                    quit(1); | 
| 400 | 
  | 
            } | 
| 401 | 
  | 
        } | 
| 402 | 
< | 
        efree(scanout); | 
| 402 | 
> | 
        efree((char *)scanout); | 
| 403 | 
  | 
} | 
| 404 | 
  | 
 | 
| 405 | 
  | 
 | 
| 406 | 
  | 
advance()                       /* read in data for next scanline */ | 
| 407 | 
  | 
{ | 
| 338 | 
– | 
        extern double  fabs(); | 
| 408 | 
  | 
        int     ytarget; | 
| 409 | 
  | 
        register COLOR  *st; | 
| 410 | 
  | 
        register int    i, j; | 
| 441 | 
  | 
        if (fn < 0 || fn >= nfiles) | 
| 442 | 
  | 
                return(1.0); | 
| 443 | 
  | 
        if (nam == vbrtexp) | 
| 444 | 
< | 
                return(bright(input[fn].expos)); | 
| 444 | 
> | 
                return((*ourbright)(input[fn].expos)); | 
| 445 | 
  | 
        n = 3; | 
| 446 | 
  | 
        while (n--) | 
| 447 | 
  | 
                if (nam == vcolexp[n]) | 
| 452 | 
  | 
 | 
| 453 | 
  | 
 | 
| 454 | 
  | 
double | 
| 455 | 
+ | 
l_pixaspect(char *nm)           /* return pixel aspect ratio */ | 
| 456 | 
+ | 
{ | 
| 457 | 
+ | 
        register int    fn; | 
| 458 | 
+ | 
 | 
| 459 | 
+ | 
        fn = argument(1) - .5; | 
| 460 | 
+ | 
        if (fn < 0 || fn >= nfiles) | 
| 461 | 
+ | 
                return(1.0); | 
| 462 | 
+ | 
        return(input[fn].pa); | 
| 463 | 
+ | 
} | 
| 464 | 
+ | 
 | 
| 465 | 
+ | 
 | 
| 466 | 
+ | 
double | 
| 467 | 
  | 
l_colin(nam)                    /* return color value for picture */ | 
| 468 | 
  | 
register char   *nam; | 
| 469 | 
  | 
{ | 
| 471 | 
  | 
        register int    n, xoff, yoff; | 
| 472 | 
  | 
        double  d; | 
| 473 | 
  | 
 | 
| 474 | 
< | 
        d = argument(1); | 
| 394 | 
< | 
        if (d > -.5 && d < .5) | 
| 395 | 
< | 
                return((double)nfiles); | 
| 396 | 
< | 
        fn = d - .5; | 
| 474 | 
> | 
        fn = argument(1) - .5; | 
| 475 | 
  | 
        if (fn < 0 || fn >= nfiles) { | 
| 476 | 
  | 
                errno = EDOM; | 
| 477 | 
  | 
                return(0.0); | 
| 507 | 
  | 
                } | 
| 508 | 
  | 
        } | 
| 509 | 
  | 
        if (nam == vbrtin) | 
| 510 | 
< | 
                return(bright(input[fn].scan[MIDSCN+yoff][xscan+xoff])); | 
| 510 | 
> | 
                return((*ourbright)(input[fn].scan[MIDSCN+yoff][xscan+xoff])); | 
| 511 | 
  | 
        n = 3; | 
| 512 | 
  | 
        while (n--) | 
| 513 | 
  | 
            if (nam == vcolin[n]) | 
| 517 | 
  | 
} | 
| 518 | 
  | 
 | 
| 519 | 
  | 
 | 
| 520 | 
< | 
wputs(msg) | 
| 521 | 
< | 
char    *msg; | 
| 520 | 
> | 
double | 
| 521 | 
> | 
l_ray(nam)              /* return ray origin or direction */ | 
| 522 | 
> | 
register char   *nam; | 
| 523 | 
  | 
{ | 
| 524 | 
+ | 
        static unsigned long    ltick[MAXINP]; | 
| 525 | 
+ | 
        static FVECT    lorg[MAXINP], ldir[MAXINP]; | 
| 526 | 
+ | 
        static double   ldist[MAXINP]; | 
| 527 | 
+ | 
        RREAL   loc[2]; | 
| 528 | 
+ | 
        int     fn; | 
| 529 | 
+ | 
        register int    i; | 
| 530 | 
+ | 
 | 
| 531 | 
+ | 
        fn = argument(1) - .5; | 
| 532 | 
+ | 
        if (fn < 0 || fn >= nfiles) { | 
| 533 | 
+ | 
                errno = EDOM; | 
| 534 | 
+ | 
                return(0.0); | 
| 535 | 
+ | 
        } | 
| 536 | 
+ | 
        if (ltick[fn] != eclock) {              /* need to compute? */ | 
| 537 | 
+ | 
                lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; | 
| 538 | 
+ | 
                ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; | 
| 539 | 
+ | 
                ldist[fn] = -1.0; | 
| 540 | 
+ | 
                if (input[fn].vw.type == 0) | 
| 541 | 
+ | 
                        errno = EDOM; | 
| 542 | 
+ | 
                else { | 
| 543 | 
+ | 
                        pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan); | 
| 544 | 
+ | 
                        ldist[fn] = viewray(lorg[fn], ldir[fn], | 
| 545 | 
+ | 
                                        &input[fn].vw, loc[0], loc[1]); | 
| 546 | 
+ | 
                } | 
| 547 | 
+ | 
                ltick[fn] = eclock; | 
| 548 | 
+ | 
        } | 
| 549 | 
+ | 
        if (nam == vray[i=6]) | 
| 550 | 
+ | 
                return(ldist[fn]); | 
| 551 | 
+ | 
        while (i--) | 
| 552 | 
+ | 
                if (nam == vray[i]) | 
| 553 | 
+ | 
                        return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]); | 
| 554 | 
+ | 
        eputs("Bad call to l_ray()!\n"); | 
| 555 | 
+ | 
        quit(1); | 
| 556 | 
+ | 
} | 
| 557 | 
+ | 
 | 
| 558 | 
+ | 
 | 
| 559 | 
+ | 
double | 
| 560 | 
+ | 
l_psize(char *nm)               /* compute pixel size in steradians */ | 
| 561 | 
+ | 
{ | 
| 562 | 
+ | 
        static unsigned long    ltick[MAXINP]; | 
| 563 | 
+ | 
        static double   psize[MAXINP]; | 
| 564 | 
+ | 
        FVECT   dir0, org, dirx, diry; | 
| 565 | 
+ | 
        RREAL   locx[2], locy[2]; | 
| 566 | 
+ | 
        double  d; | 
| 567 | 
+ | 
        int     fn; | 
| 568 | 
+ | 
        register int    i; | 
| 569 | 
+ | 
 | 
| 570 | 
+ | 
        d = argument(1); | 
| 571 | 
+ | 
        if (d < .5 || d >= nfiles+.5) { | 
| 572 | 
+ | 
                errno = EDOM; | 
| 573 | 
+ | 
                return(0.0); | 
| 574 | 
+ | 
        } | 
| 575 | 
+ | 
        fn = d - .5; | 
| 576 | 
+ | 
        if (ltick[fn] != eclock) {              /* need to compute? */ | 
| 577 | 
+ | 
                psize[fn] = 0.0; | 
| 578 | 
+ | 
                if (input[fn].vw.type == 0) | 
| 579 | 
+ | 
                        errno = EDOM; | 
| 580 | 
+ | 
                else if (input[fn].vw.type != VT_PAR && | 
| 581 | 
+ | 
                                funvalue(vray[6], 1, &d) >= 0) { | 
| 582 | 
+ | 
                        for (i = 0; i < 3; i++) | 
| 583 | 
+ | 
                                dir0[i] = funvalue(vray[3+i], 1, &d); | 
| 584 | 
+ | 
                        pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan); | 
| 585 | 
+ | 
                        pix2loc(locy, &input[fn].rs, xscan, ymax-yscan); | 
| 586 | 
+ | 
                        if (viewray(org, dirx, &input[fn].vw, | 
| 587 | 
+ | 
                                        locx[0], locx[1]) >= 0 && | 
| 588 | 
+ | 
                                        viewray(org, diry, &input[fn].vw, | 
| 589 | 
+ | 
                                        locy[0], locy[1]) >= 0) { | 
| 590 | 
+ | 
                                                /* approximate solid angle */ | 
| 591 | 
+ | 
                                for (i = 0; i < 3; i++) { | 
| 592 | 
+ | 
                                        dirx[i] -= dir0[i]; | 
| 593 | 
+ | 
                                        diry[i] -= dir0[i]; | 
| 594 | 
+ | 
                                } | 
| 595 | 
+ | 
                                fcross(dir0, dirx, diry); | 
| 596 | 
+ | 
                                psize[fn] = sqrt(DOT(dir0,dir0)); | 
| 597 | 
+ | 
                        } | 
| 598 | 
+ | 
                } | 
| 599 | 
+ | 
                ltick[fn] = eclock; | 
| 600 | 
+ | 
        } | 
| 601 | 
+ | 
        return(psize[fn]); | 
| 602 | 
+ | 
} | 
| 603 | 
+ | 
 | 
| 604 | 
+ | 
 | 
| 605 | 
+ | 
extern void | 
| 606 | 
+ | 
wputs(char      *msg) | 
| 607 | 
+ | 
{ | 
| 608 | 
  | 
        if (!nowarn) | 
| 609 | 
  | 
                eputs(msg); | 
| 610 | 
  | 
} | 
| 611 | 
  | 
 | 
| 612 | 
  | 
 | 
| 613 | 
< | 
eputs(msg) | 
| 614 | 
< | 
char    *msg; | 
| 613 | 
> | 
extern void | 
| 614 | 
> | 
eputs(char *msg) | 
| 615 | 
  | 
{ | 
| 616 | 
  | 
        fputs(msg, stderr); | 
| 617 | 
  | 
} | 
| 618 | 
  | 
 | 
| 619 | 
  | 
 | 
| 620 | 
< | 
quit(code)              /* exit gracefully */ | 
| 621 | 
< | 
int  code; | 
| 620 | 
> | 
extern void | 
| 621 | 
> | 
quit(int code)          /* exit gracefully */ | 
| 622 | 
  | 
{ | 
| 623 | 
  | 
        register int  i; | 
| 624 | 
  | 
                                /* close input files */ |