ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcomb.c
(Generate patch)

Comparing ray/src/px/pcomb.c (file contents):
Revision 2.16 by greg, Mon Oct 16 12:04:33 1995 UTC vs.
Revision 2.18 by greg, Tue Sep 3 11:30:37 1996 UTC

# Line 29 | Line 29 | struct {
29          FILE    *fp;            /* stream pointer */
30          VIEW    vw;             /* view for picture */
31          RESOLU  rs;             /* image resolution and orientation */
32 +        float   pa;             /* pixel aspect ratio */
33          COLOR   *scan[WINSIZ];  /* input scanline window */
34          COLOR   coef;           /* coefficient */
35          COLOR   expos;          /* recorded exposure */
# Line 45 | Line 46 | char   vbrtin[] = "li";
46   char    vbrtout[] = "lo";
47   char    vcolexp[3][4] = {"re", "ge", "be"};
48   char    vbrtexp[] = "le";
49 + char    vpixaspect[] = "pa";
50  
51 < char    vray[6][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz"};
51 > char    vray[7][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz", "T"};
52  
53 + char    vpsize[] = "S";
54 +
55   char    vnfiles[] = "nfiles";
56 + char    vwhteff[] = "WE";
57   char    vxmax[] = "xmax";
58   char    vymax[] = "ymax";
59   char    vxres[] = "xres";
# Line 114 | Line 119 | char   *argv[];
119                  setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
120                  setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
121                  copystruct(&input[nfiles].vw, &stdview);
122 +                input[nfiles].pa = 1.0;
123          }
124          nfiles = 0;
125          original = 0;
# Line 244 | Line 250 | char   *s;
250          } else if (iscolcor(s)) {               /* color correction */
251                  colcorval(ctmp, s);
252                  multcolor(input[nfiles].expos, ctmp);
253 <        } else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
253 >        } else if (isaspect(s))
254 >                input[nfiles].pa *= aspectval(s);
255 >        else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
256                  gotview++;
257                                                  /* echo line */
258          putchar('\t');
# Line 308 | Line 316 | double (*ourbright)() = rgb_bright;
316  
317   init()                                  /* perform final setup */
318   {
319 <        double  l_colin(), l_expos(), l_ray();
319 >        double  l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize();
320          register int    i;
321                                                  /* define constants */
322          varset(vnfiles, ':', (double)nfiles);
# Line 321 | Line 329 | init()                                 /* perform final setup */
329          }
330          funset(vbrtexp, 1, ':', l_expos);
331          funset(vbrtin, 1, '=', l_colin);
332 <        for (i = 0; i < 6; i++)
332 >        funset(vpixaspect, 1, ':', l_pixaspect);
333 >        for (i = 0; i < 7; i++)
334                  funset(vray[i], 1, '=', l_ray);
335 +        funset(vpsize, 1, '=', l_psize);
336                                                  /* set brightness function */
337 <        if (!strcmp(ourfmt, CIEFMT))
337 >        if (!strcmp(ourfmt, CIEFMT)) {
338 >                varset(vwhteff, ':', 1.0);
339                  ourbright = xyz_bright;
340 +        } else
341 +                varset(vwhteff, ':', WHTEFFICACY);
342   }
343  
344  
# Line 436 | Line 449 | register char  *nam;
449  
450  
451   double
452 + l_pixaspect()                   /* return pixel aspect ratio */
453 + {
454 +        register int    fn;
455 +
456 +        fn = argument(1) - .5;
457 +        if (fn < 0 || fn >= nfiles)
458 +                return(1.0);
459 +        return(input[fn].pa);
460 + }
461 +
462 +
463 + double
464   l_colin(nam)                    /* return color value for picture */
465   register char   *nam;
466   {
# Line 443 | Line 468 | register char  *nam;
468          register int    n, xoff, yoff;
469          double  d;
470  
471 <        d = argument(1);
447 <        if (d > -.5 && d < .5)
448 <                return((double)nfiles);
449 <        fn = d - .5;
471 >        fn = argument(1) - .5;
472          if (fn < 0 || fn >= nfiles) {
473                  errno = EDOM;
474                  return(0.0);
# Line 498 | Line 520 | register char  *nam;
520   {
521          static unsigned long    ltick[MAXINP];
522          static FVECT    lorg[MAXINP], ldir[MAXINP];
523 +        static double   ldist[MAXINP];
524          FLOAT   loc[2];
502        double  d;
525          int     fn;
526          register int    i;
527  
528 <        d = argument(1);
507 <        if (d > -.5 && d < .5)
508 <                return((double)nfiles);
509 <        fn = d - .5;
528 >        fn = argument(1) - .5;
529          if (fn < 0 || fn >= nfiles) {
530                  errno = EDOM;
531                  return(0.0);
# Line 518 | Line 537 | register char  *nam;
537                          errno = EDOM;
538                  else {
539                          pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan);
540 <                        if (viewray(lorg[fn], ldir[fn],
541 <                                        &input[fn].vw, loc[0], loc[1]) < 0)
523 <                                errno = ERANGE;
540 >                        ldist[fn] = viewray(lorg[fn], ldir[fn],
541 >                                        &input[fn].vw, loc[0], loc[1]);
542                  }
543                  ltick[fn] = eclock;
544          }
545 <        i = 6;
545 >        if (nam == vray[i=6])
546 >                return(ldist[fn]);
547          while (i--)
548                  if (nam == vray[i])
549                          return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]);
550          eputs("Bad call to l_ray()!\n");
551          quit(1);
552 + }
553 +
554 +
555 + double
556 + l_psize()                       /* compute pixel size in steradians */
557 + {
558 +        static unsigned long    ltick[MAXINP];
559 +        static double   psize[MAXINP];
560 +        FVECT   dir0, org, dirx, diry;
561 +        FLOAT   locx[2], locy[2];
562 +        double  d;
563 +        int     fn;
564 +        register int    i;
565 +
566 +        d = argument(1);
567 +        if (d < .5 || d >= nfiles+.5) {
568 +                errno = EDOM;
569 +                return(0.0);
570 +        }
571 +        fn = d - .5;
572 +        if (ltick[fn] < eclock) {               /* need to compute? */
573 +                psize[fn] = 0.0;
574 +                if (input[fn].vw.type == 0)
575 +                        errno = EDOM;
576 +                else if (input[fn].vw.type != VT_PAR &&
577 +                                funvalue(vray[6], 1, &d) >= 0) {
578 +                        for (i = 0; i < 3; i++)
579 +                                dir0[i] = funvalue(vray[3+i], 1, &d);
580 +                        pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan);
581 +                        pix2loc(locy, &input[fn].rs, xscan, ymax-yscan);
582 +                        if (viewray(org, dirx, &input[fn].vw,
583 +                                        locx[0], locx[1]) >= 0 &&
584 +                                        viewray(org, diry, &input[fn].vw,
585 +                                        locy[0], locy[1]) >= 0) {
586 +                                                /* approximate solid angle */
587 +                                for (i = 0; i < 3; i++) {
588 +                                        dirx[i] -= dir0[i];
589 +                                        diry[i] -= dir0[i];
590 +                                }
591 +                                fcross(dir0, dirx, diry);
592 +                                psize[fn] = 0.5 * sqrt(DOT(dir0,dir0));
593 +                        }
594 +                }
595 +                ltick[fn] = eclock;
596 +        }
597 +        return(psize[fn]);
598   }
599  
600  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines