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.9 by greg, Fri Apr 9 09:49:36 1993 UTC vs.
Revision 2.10 by greg, Thu Apr 29 14:32:07 1993 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *      1/4/89
11   */
12  
13 < #include <stdio.h>
13 > #include "standard.h"
14  
15 #ifdef MSDOS
16 #include <fcntl.h>
17 #endif
18
19 #include <math.h>
20
21 #include <errno.h>
22
15   #include "color.h"
16  
17   #include "resolu.h"
18  
19   #include "calcomp.h"
20  
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 */
# Line 33 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
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          COLOR   *scan[WINSIZ];  /* input scanline window */
33          COLOR   coef;           /* coefficient */
34          COLOR   expos;          /* recorded exposure */
# Line 48 | Line 44 | char   vbrtout[] = "lo";
44   char    vcolexp[3][4] = {"re", "ge", "be"};
45   char    vbrtexp[] = "le";
46  
47 + char    vray[6][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz"};
48 +
49   char    vnfiles[] = "nfiles";
50   char    vxmax[] = "xmax";
51   char    vymax[] = "ymax";
# Line 66 | Line 64 | int    xres, yres;                     /* output resolution */
64  
65   int     xpos, ypos;                     /* output position */
66  
67 + char    *progname;                      /* global argv[0] */
68 +
69   int     wrongformat = 0;
70 + int     gotview;
71  
72   FILE    *popen();
73  
# Line 86 | Line 87 | char   *argv[];
87          setmode(fileno(stdin), O_BINARY);
88          setmode(fileno(stdout), O_BINARY);
89   #endif
90 +        progname = argv[0];
91                                                  /* scan options */
92          for (a = 1; a < argc; a++) {
93                  if (argv[a][0] == '-')
# Line 108 | Line 110 | char   *argv[];
110          for (nfiles = 0; nfiles < MAXINP; nfiles++) {
111                  setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
112                  setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
113 +                copystruct(&input[nfiles].vw, &stdview);
114          }
115          nfiles = 0;
116          original = 0;
# Line 232 | Line 235 | char   *s;
235          } else if (iscolcor(s)) {               /* color correction */
236                  colcorval(ctmp, s);
237                  multcolor(input[nfiles].expos, ctmp);
238 <        }
238 >        } else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
239 >                gotview++;
240                                                  /* echo line */
241          putchar('\t');
242          fputs(s, stdout);
# Line 241 | Line 245 | char   *s;
245  
246   checkfile()                     /* ready a file */
247   {
244        int     xinp, yinp;
248          register int    i;
249                                          /* process header */
250 +        gotview = 0;
251          fputs(input[nfiles].name, stdout);
252          fputs(":\n", stdout);
253          getheader(input[nfiles].fp, tputs, NULL);
# Line 252 | Line 256 | checkfile()                    /* ready a file */
256                  eputs(": not in Radiance picture format\n");
257                  quit(1);
258          }
259 <        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) {
259 >        if (!gotview || setview(&input[nfiles].vw) != NULL)
260 >                input[nfiles].vw.type = 0;
261 >        if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) {
262                  eputs(input[nfiles].name);
263                  eputs(": bad picture size\n");
264                  quit(1);
265          }
266          if (xmax == 0 && ymax == 0) {
267 <                xmax = xinp;
268 <                ymax = yinp;
269 <        } else if (xinp != xmax || yinp != ymax) {
267 >                xmax = scanlen(&input[nfiles].rs);
268 >                ymax = numscans(&input[nfiles].rs);
269 >        } else if (scanlen(&input[nfiles].rs) != xmax ||
270 >                        numscans(&input[nfiles].rs) != ymax) {
271                  eputs(input[nfiles].name);
272                  eputs(": resolution mismatch\n");
273                  quit(1);
# Line 273 | Line 280 | checkfile()                    /* ready a file */
280  
281   init()                                  /* perform final setup */
282   {
283 <        double  l_colin(), l_expos();
283 >        double  l_colin(), l_expos(), l_ray();
284          register int    i;
285                                                  /* define constants */
286          varset(vnfiles, ':', (double)nfiles);
# Line 286 | Line 293 | init()                                 /* perform final setup */
293          }
294          funset(vbrtexp, 1, ':', l_expos);
295          funset(vbrtin, 1, '=', l_colin);
296 +        for (i = 0; i < 6; i++)
297 +                funset(vray[i], 1, '=', l_ray);
298   }
299  
300  
# Line 448 | Line 457 | register char  *nam;
457              if (nam == vcolin[n])
458                  return(colval(input[fn].scan[MIDSCN+yoff][xscan+xoff],n));
459          eputs("Bad call to l_colin()!\n");
460 +        quit(1);
461 + }
462 +
463 +
464 + double
465 + l_ray(nam)              /* return ray origin or direction */
466 + register char   *nam;
467 + {
468 +        static long     ltick[MAXINP];
469 +        static FVECT    lorg[MAXINP], ldir[MAXINP];
470 +        FLOAT   loc[2];
471 +        double  d;
472 +        int     fn;
473 +        register int    i;
474 +
475 +        d = argument(1);
476 +        if (d > -.5 && d < .5)
477 +                return((double)nfiles);
478 +        fn = d - .5;
479 +        if (fn < 0 || fn >= nfiles) {
480 +                errno = EDOM;
481 +                return(0.0);
482 +        }
483 +        if (ltick[fn] < eclock) {               /* need to compute? */
484 +                lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0;
485 +                ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0;
486 +                if (input[fn].vw.type == 0)
487 +                        errno = ERANGE;
488 +                else {
489 +                        pix2loc(loc, &input[fn].rs, xpos, ypos);
490 +                        if (viewray(lorg[fn], ldir[fn],
491 +                                        &input[fn].vw, loc[0], loc[1]) < 0)
492 +                                errno = ERANGE;
493 +                }
494 +                ltick[fn] = eclock;
495 +        }
496 +        i = 6;
497 +        while (i--)
498 +                if (nam == vray[i])
499 +                        return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]);
500 +        eputs("Bad call to l_ray()!\n");
501          quit(1);
502   }
503  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines