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.15 by greg, Fri Feb 17 18:37:20 1995 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 */
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          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 104 | Line 106 | char   *argv[];
106                          }
107                  break;
108          }
109 +        newheader("RADIANCE", stdout);  /* start header */
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 +                copystruct(&input[nfiles].vw, &stdview);
115          }
116          nfiles = 0;
117          original = 0;
# Line 221 | Line 225 | char   *s;
225          double  d;
226          COLOR   ctmp;
227  
228 <        if (isformat(s)) {                      /* check format */
229 <                formatval(fmt, s);
228 >        if (isheadid(s))                        /* header id */
229 >                return;         /* don't echo */
230 >        if (formatval(fmt, s)) {                /* check format */
231                  wrongformat = strcmp(fmt, COLRFMT);
232                  return;         /* don't echo */
233          }
# Line 232 | Line 237 | char   *s;
237          } else if (iscolcor(s)) {               /* color correction */
238                  colcorval(ctmp, s);
239                  multcolor(input[nfiles].expos, ctmp);
240 <        }
240 >        } else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
241 >                gotview++;
242                                                  /* echo line */
243          putchar('\t');
244          fputs(s, stdout);
# Line 241 | Line 247 | char   *s;
247  
248   checkfile()                     /* ready a file */
249   {
244        int     xinp, yinp;
250          register int    i;
251                                          /* process header */
252 +        gotview = 0;
253          fputs(input[nfiles].name, stdout);
254          fputs(":\n", stdout);
255          getheader(input[nfiles].fp, tputs, NULL);
# Line 252 | Line 258 | checkfile()                    /* ready a file */
258                  eputs(": not in Radiance picture format\n");
259                  quit(1);
260          }
261 <        if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) {
261 >        if (!gotview || setview(&input[nfiles].vw) != NULL)
262 >                input[nfiles].vw.type = 0;
263 >        if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) {
264                  eputs(input[nfiles].name);
265                  eputs(": bad picture size\n");
266                  quit(1);
267          }
268          if (xmax == 0 && ymax == 0) {
269 <                xmax = xinp;
270 <                ymax = yinp;
271 <        } else if (xinp != xmax || yinp != ymax) {
269 >                xmax = scanlen(&input[nfiles].rs);
270 >                ymax = numscans(&input[nfiles].rs);
271 >        } else if (scanlen(&input[nfiles].rs) != xmax ||
272 >                        numscans(&input[nfiles].rs) != ymax) {
273                  eputs(input[nfiles].name);
274                  eputs(": resolution mismatch\n");
275                  quit(1);
# Line 273 | Line 282 | checkfile()                    /* ready a file */
282  
283   init()                                  /* perform final setup */
284   {
285 <        double  l_colin(), l_expos();
285 >        double  l_colin(), l_expos(), l_ray();
286          register int    i;
287                                                  /* define constants */
288          varset(vnfiles, ':', (double)nfiles);
# Line 286 | Line 295 | init()                                 /* perform final setup */
295          }
296          funset(vbrtexp, 1, ':', l_expos);
297          funset(vbrtin, 1, '=', l_colin);
298 +        for (i = 0; i < 6; i++)
299 +                funset(vray[i], 1, '=', l_ray);
300   }
301  
302  
# Line 448 | Line 459 | register char  *nam;
459              if (nam == vcolin[n])
460                  return(colval(input[fn].scan[MIDSCN+yoff][xscan+xoff],n));
461          eputs("Bad call to l_colin()!\n");
462 +        quit(1);
463 + }
464 +
465 +
466 + double
467 + l_ray(nam)              /* return ray origin or direction */
468 + register char   *nam;
469 + {
470 +        static unsigned long    ltick[MAXINP];
471 +        static FVECT    lorg[MAXINP], ldir[MAXINP];
472 +        FLOAT   loc[2];
473 +        double  d;
474 +        int     fn;
475 +        register int    i;
476 +
477 +        d = argument(1);
478 +        if (d > -.5 && d < .5)
479 +                return((double)nfiles);
480 +        fn = d - .5;
481 +        if (fn < 0 || fn >= nfiles) {
482 +                errno = EDOM;
483 +                return(0.0);
484 +        }
485 +        if (ltick[fn] < eclock) {               /* need to compute? */
486 +                lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0;
487 +                ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0;
488 +                if (input[fn].vw.type == 0)
489 +                        errno = EDOM;
490 +                else {
491 +                        pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan);
492 +                        if (viewray(lorg[fn], ldir[fn],
493 +                                        &input[fn].vw, loc[0], loc[1]) < 0)
494 +                                errno = ERANGE;
495 +                }
496 +                ltick[fn] = eclock;
497 +        }
498 +        i = 6;
499 +        while (i--)
500 +                if (nam == vray[i])
501 +                        return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]);
502 +        eputs("Bad call to l_ray()!\n");
503          quit(1);
504   }
505  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines