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.10 by greg, Thu Apr 29 14:32:07 1993 UTC vs.
Revision 2.17 by greg, Fri Aug 30 17:39:39 1996 UTC

# Line 21 | Line 21 | static char SCCSid[] = "$SunId$ LBL";
21   #include "view.h"
22  
23   #define MAXINP          32              /* maximum number of input files */
24 < #define WINSIZ          9               /* scanline window size */
25 < #define MIDSCN          4               /* current scan position */
24 > #define WINSIZ          17              /* scanline window size */
25 > #define MIDSCN          ((WINSIZ-1)/2+1)
26  
27   struct {
28          char    *name;          /* file or command name */
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 36 | Line 37 | struct {
37  
38   int     nfiles;                         /* number of input files */
39  
40 + char    ourfmt[LPICFMT+1] = PICFMT;     /* input picture format */
41 +
42   char    Command[] = "<Command>";
43   char    vcolin[3][4] = {"ri", "gi", "bi"};
44   char    vcolout[3][4] = {"ro", "go", "bo"};
# Line 46 | Line 49 | char   vbrtexp[] = "le";
49  
50   char    vray[6][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz"};
51  
52 + char    vpsize[] = "S";
53 +
54   char    vnfiles[] = "nfiles";
55   char    vxmax[] = "xmax";
56   char    vymax[] = "ymax";
# Line 106 | Line 111 | char   *argv[];
111                          }
112                  break;
113          }
114 +        newheader("RADIANCE", stdout);  /* start header */
115                                          /* process files */
116          for (nfiles = 0; nfiles < MAXINP; nfiles++) {
117                  setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
118                  setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
119                  copystruct(&input[nfiles].vw, &stdview);
120 +                input[nfiles].pa = 1.0;
121          }
122          nfiles = 0;
123          original = 0;
# Line 202 | Line 209 | char   *argv[];
209          }
210                                                  /* complete header */
211          printargs(argc, argv, stdout);
212 <        fputformat(COLRFMT, stdout);
212 >        if (strcmp(ourfmt, PICFMT))
213 >                fputformat(ourfmt, stdout);     /* print format if known */
214          putchar('\n');
215          fprtresolu(xres, yres, stdout);
216                                                  /* combine pictures */
# Line 224 | Line 232 | char   *s;
232          double  d;
233          COLOR   ctmp;
234  
235 <        if (isformat(s)) {                      /* check format */
228 <                formatval(fmt, s);
229 <                wrongformat = strcmp(fmt, COLRFMT);
235 >        if (isheadid(s))                        /* header id */
236                  return;         /* don't echo */
237 +        if (formatval(fmt, s)) {                /* check format */
238 +                if (globmatch(ourfmt, fmt)) {
239 +                        wrongformat = 0;
240 +                        strcpy(ourfmt, fmt);
241 +                } else
242 +                        wrongformat = 1;
243 +                return;         /* don't echo */
244          }
245          if (isexpos(s)) {                       /* exposure */
246                  d = exposval(s);
# Line 235 | Line 248 | char   *s;
248          } else if (iscolcor(s)) {               /* color correction */
249                  colcorval(ctmp, s);
250                  multcolor(input[nfiles].expos, ctmp);
251 +        } else if (isaspect(s)) {
252 +                input[nfiles].pa *= aspectval(s);
253          } else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
254                  gotview++;
255                                                  /* echo line */
# Line 278 | Line 293 | checkfile()                    /* ready a file */
293   }
294  
295  
296 + double
297 + rgb_bright(clr)
298 + COLOR  clr;
299 + {
300 +        return(bright(clr));
301 + }
302 +
303 +
304 + double
305 + xyz_bright(clr)
306 + COLOR  clr;
307 + {
308 +        return(clr[CIEY]);
309 + }
310 +
311 +
312 + double  (*ourbright)() = rgb_bright;
313 +
314 +
315   init()                                  /* perform final setup */
316   {
317 <        double  l_colin(), l_expos(), l_ray();
317 >        double  l_colin(), l_expos(), l_ray(), l_psize();
318          register int    i;
319                                                  /* define constants */
320          varset(vnfiles, ':', (double)nfiles);
# Line 295 | Line 329 | init()                                 /* perform final setup */
329          funset(vbrtin, 1, '=', l_colin);
330          for (i = 0; i < 6; i++)
331                  funset(vray[i], 1, '=', l_ray);
332 +        funset(vpsize, 1, '=', l_psize);
333 +                                                /* set brightness function */
334 +        if (!strcmp(ourfmt, CIEFMT))
335 +                ourbright = xyz_bright;
336   }
337  
338  
# Line 394 | Line 432 | register char  *nam;
432          if (fn < 0 || fn >= nfiles)
433                  return(1.0);
434          if (nam == vbrtexp)
435 <                return(bright(input[fn].expos));
435 >                return((*ourbright)(input[fn].expos));
436          n = 3;
437          while (n--)
438                  if (nam == vcolexp[n])
# Line 451 | Line 489 | register char  *nam;
489                  }
490          }
491          if (nam == vbrtin)
492 <                return(bright(input[fn].scan[MIDSCN+yoff][xscan+xoff]));
492 >                return((*ourbright)(input[fn].scan[MIDSCN+yoff][xscan+xoff]));
493          n = 3;
494          while (n--)
495              if (nam == vcolin[n])
# Line 465 | Line 503 | double
503   l_ray(nam)              /* return ray origin or direction */
504   register char   *nam;
505   {
506 <        static long     ltick[MAXINP];
506 >        static unsigned long    ltick[MAXINP];
507          static FVECT    lorg[MAXINP], ldir[MAXINP];
508          FLOAT   loc[2];
509          double  d;
# Line 484 | Line 522 | register char  *nam;
522                  lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0;
523                  ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0;
524                  if (input[fn].vw.type == 0)
525 <                        errno = ERANGE;
525 >                        errno = EDOM;
526                  else {
527 <                        pix2loc(loc, &input[fn].rs, xpos, ypos);
527 >                        pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan);
528                          if (viewray(lorg[fn], ldir[fn],
529                                          &input[fn].vw, loc[0], loc[1]) < 0)
530                                  errno = ERANGE;
531 +                        ltick[fn] = eclock;
532                  }
494                ltick[fn] = eclock;
533          }
534          i = 6;
535          while (i--)
# Line 499 | Line 537 | register char  *nam;
537                          return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]);
538          eputs("Bad call to l_ray()!\n");
539          quit(1);
540 + }
541 +
542 +
543 + double
544 + l_psize()                       /* compute pixel size in steradians */
545 + {
546 +        static unsigned long    ltick[MAXINP];
547 +        static double   psize[MAXINP];
548 +        FVECT   dir0, org1, dir1;
549 +        FLOAT   loc[2];
550 +        double  d;
551 +        int     fn;
552 +
553 +        d = argument(1);
554 +        if (d > -.5 && d < .5)
555 +                return((double)nfiles);
556 +        fn = d - .5;
557 +        if (fn < 0 || fn >= nfiles) {
558 +                errno = EDOM;
559 +                return(0.0);
560 +        }
561 +        if (ltick[fn] < eclock)                 /* need to compute? */
562 +                if (input[fn].vw.type == 0 || input[fn].vw.type == VT_PAR)
563 +                        errno = EDOM;
564 +                else {
565 +                        errno = 0;
566 +                        dir0[0] = funvalue(vray[3], 1, &d);
567 +                        if (errno)
568 +                                return(0.0);
569 +                        dir0[1] = funvalue(vray[4], 1, &d);
570 +                        if (errno)
571 +                                return(0.0);
572 +                        dir0[2] = funvalue(vray[5], 1, &d);
573 +                        if (errno)
574 +                                return(0.0);
575 +                        pix2loc(loc, &input[fn].rs, xscan+1, ymax-yscan);
576 +                        psize[fn] = 0.0;
577 +                        if (viewray(org1, dir1,
578 +                                        &input[fn].vw, loc[0], loc[1]) < 0)
579 +                                errno = ERANGE;
580 +                        else {
581 +                                                /* approximate solid angle */
582 +                                psize[fn] = dist2(dir0, dir1) * input[fn].pa /
583 +                                        (1.0 + input[fn].pa*input[fn].pa);
584 +                                ltick[fn] = eclock;
585 +                        }
586 +                }
587 +        return(psize[fn]);
588   }
589  
590  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines