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

Comparing ray/src/util/rad.c (file contents):
Revision 2.27 by greg, Sat Sep 25 13:21:35 1993 UTC vs.
Revision 2.36 by greg, Thu Dec 30 08:20:45 1993 UTC

# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   #include "standard.h"
12   #include "paths.h"
13   #include <ctype.h>
14 + #include <sys/types.h>
15  
16  
17   typedef struct {
# Line 21 | Line 22 | typedef struct {
22          int     (*fixval)();    /* assignment checking function */
23   } VARIABLE;
24  
25 < int     onevalue(), catvalues();
25 > int     onevalue(), catvalues(), boolvalue(),
26 >        qualvalue(), fltvalue(), intvalue();
27  
28                                  /* variables */
29   #define OBJECT          0               /* object files */
# Line 61 | Line 63 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
63          {"pfilt",       2,      0,      NULL,   catvalues},
64          {"view",        2,      0,      NULL,   NULL},
65          {"ZONE",        2,      0,      NULL,   onevalue},
66 <        {"QUALITY",     3,      0,      NULL,   onevalue},
66 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
67          {"OCTREE",      3,      0,      NULL,   onevalue},
68          {"PICTURE",     3,      0,      NULL,   onevalue},
69          {"AMBFILE",     3,      0,      NULL,   onevalue},
70          {"OPTFILE",     3,      0,      NULL,   onevalue},
71 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
71 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
72          {"RESOLUTION",  3,      0,      NULL,   onevalue},
73          {"UP",          2,      0,      NULL,   onevalue},
74 <        {"INDIRECT",    3,      0,      NULL,   onevalue},
75 <        {"DETAIL",      3,      0,      NULL,   onevalue},
76 <        {"PENUMBRAS",   3,      0,      NULL,   onevalue},
77 <        {"VARIABILITY", 3,      0,      NULL,   onevalue},
74 >        {"INDIRECT",    3,      0,      NULL,   intvalue},
75 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
76 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
77 >        {"VARIABILITY", 3,      0,      NULL,   qualvalue},
78          {"REPORT",      3,      0,      NULL,   onevalue},
79   };
80  
81   VARIABLE        *matchvar();
82   char    *nvalue();
81 int     vscale();
83  
84   #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
85  
# Line 87 | Line 88 | int    vscale();
88   #define vval(vc)        (vv[vc].value)
89   #define vint(vc)        atoi(vval(vc))
90   #define vlet(vc)        UPPER(vval(vc)[0])
91 + #define vscale          vlet
92   #define vbool(vc)       (vlet(vc)=='T')
93  
94 < #define HIGH            2
95 < #define MEDIUM          1
96 < #define LOW             0
94 > #define HIGH            'H'
95 > #define MEDIUM          'M'
96 > #define LOW             'L'
97  
96 int     lowqopts(), medqopts(), hiqopts();
97 int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
98
99 #define renderopts      (*setqopts[vscale(QUALITY)])
100
98                                  /* overture calculation file */
99   #ifdef NIX
100   char    overfile[] = "overture.raw";
# Line 105 | Line 102 | char   overfile[] = "overture.raw";
102   char    overfile[] = "/dev/null";
103   #endif
104  
105 < extern unsigned long    fdate(), time();
105 > extern time_t   fdate(), time();
106  
107 < unsigned long   scenedate;      /* date of latest scene or object file */
108 < unsigned long   octreedate;     /* date of octree */
109 < unsigned long   matdate;        /* date of latest material file */
110 < unsigned long   illumdate;      /* date of last illum file */
107 > time_t  scenedate;              /* date of latest scene or object file */
108 > time_t  octreedate;             /* date of octree */
109 > time_t  matdate;                /* date of latest material file */
110 > time_t  illumdate;              /* date of last illum file */
111  
112   char    *oct0name;              /* name of pre-mkillum octree */
113 < unsigned long   oct0date;       /* date of pre-mkillum octree */
113 > time_t  oct0date;               /* date of pre-mkillum octree */
114   char    *oct1name;              /* name of post-mkillum octree */
115 < unsigned long   oct1date;       /* date of post-mkillum octree (>= matdate) */
115 > time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
116  
117   int     explicate = 0;          /* explicate variables */
118   int     silent = 0;             /* do work silently */
# Line 256 | Line 253 | setvariable(ass)               /* assign variable according to stri
253   register char   *ass;
254   {
255          char    varname[32];
259        char    varval[512];
256          int     n;
257          register char   *cp;
258          register VARIABLE       *vp;
# Line 348 | Line 344 | register int   n;
344   }
345  
346  
351 int
352 vscale(vc)                      /* return scale for variable vc */
353 int     vc;
354 {
355        switch(vlet(vc)) {
356        case 'H':
357                return(HIGH);
358        case 'M':
359                return(MEDIUM);
360        case 'L':
361                return(LOW);
362        }
363        badvalue(vc);
364 }
365
366
347   checkvalues()                   /* check assignments */
348   {
349          register int    i;
# Line 402 | Line 382 | register VARIABLE      *vp;
382   }
383  
384  
385 < unsigned long
385 > int
386 > badmatch(tv, cv)                /* case insensitive truncated comparison */
387 > register char   *tv, *cv;
388 > {
389 >        if (!*tv) return(1);            /* null string cannot match */
390 >        do
391 >                if (UPPER(*tv) != *cv++)
392 >                        return(1);
393 >        while (*++tv);
394 >        return(0);              /* OK */
395 > }
396 >
397 >
398 > boolvalue(vp)                   /* check boolean for legal values */
399 > register VARIABLE       *vp;
400 > {
401 >        if (!vp->nass) return;
402 >        onevalue(vp);
403 >        switch (UPPER(vp->value[0])) {
404 >        case 'T':
405 >                if (badmatch(vp->value, "TRUE")) break;
406 >                return;
407 >        case 'F':
408 >                if (badmatch(vp->value, "FALSE")) break;
409 >                return;
410 >        }
411 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
412 >                        progname, vp->name);
413 >        exit(1);
414 > }
415 >
416 >
417 > qualvalue(vp)                   /* check qualitative var. for legal values */
418 > register VARIABLE       *vp;
419 > {
420 >        if (!vp->nass) return;
421 >        onevalue(vp);
422 >        switch (UPPER(vp->value[0])) {
423 >        case 'L':
424 >                if (badmatch(vp->value, "LOW")) break;
425 >                return;
426 >        case 'M':
427 >                if (badmatch(vp->value, "MEDIUM")) break;
428 >                return;
429 >        case 'H':
430 >                if (badmatch(vp->value, "HIGH")) break;
431 >                return;
432 >        }
433 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
434 >                        progname, vp->name);
435 >        exit(1);
436 > }
437 >
438 >
439 > intvalue(vp)                    /* check integer variable for legal values */
440 > register VARIABLE       *vp;
441 > {
442 >        if (!vp->nass) return;
443 >        onevalue(vp);
444 >        if (isint(vp->value)) return;
445 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
446 >                        progname, vp->name);
447 >        exit(1);
448 > }
449 >
450 >
451 > fltvalue(vp)                    /* check float variable for legal values */
452 > register VARIABLE       *vp;
453 > {
454 >        if (!vp->nass) return;
455 >        onevalue(vp);
456 >        if (isflt(vp->value)) return;
457 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
458 >                        progname, vp->name);
459 >        exit(1);
460 > }
461 >
462 >
463 > time_t
464   checklast(fnames)                       /* check files and find most recent */
465   register char   *fnames;
466   {
467          char    thisfile[MAXPATH];
468 <        unsigned long   thisdate, lastdate = 0;
468 >        time_t  thisdate, lastdate = 0;
469          register char   *cp;
470  
471          if (fnames == NULL)
# Line 455 | Line 513 | int    pred;
513  
514   checkfiles()                    /* check for existence and modified times */
515   {
516 <        unsigned long   objdate;
516 >        time_t  objdate;
517  
518          if (!vdef(OCTREE)) {
519                  if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
# Line 583 | Line 641 | setdefaults()                  /* set default values for unassigned v
641  
642   printvals()                     /* print variable values */
643   {
644 <        register int    i, j;
644 >        int     i, j, clipline;
645 >        register char   *cp;
646 >        register int    k;
647  
648 <        for (i = 0; i < NVARS; i++)
649 <                for (j = 0; j < vdef(i); j++)
650 <                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
648 >        for (i = 0; i < NVARS; i++)             /* print each variable */
649 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
650 >                fputs(vnam(i), stdout);
651 >                fputs("= ", stdout);
652 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
653 >                                - strlen(vnam(i)) ;
654 >                cp = nvalue(vv+i, j);
655 >                while (*cp) {
656 >                    putchar(*cp++);
657 >                    if (--k <= 0) {             /* line too long */
658 >                        while (*cp && !isspace(*cp))
659 >                            putchar(*cp++);     /* finish this word */
660 >                        if (*cp) {              /* start new line */
661 >                            putchar('\n');
662 >                            fputs(vnam(i), stdout);
663 >                            putchar('=');
664 >                            k = clipline;
665 >                        }
666 >                    }
667 >                }
668 >                putchar('\n');
669 >            }
670          fflush(stdout);
671   }
672  
# Line 614 | Line 693 | oconv()                                /* run oconv and mkillum if necessary */
693                          unlink(vval(OCTREE));
694                          exit(1);
695                  }
696 <                octreedate = time(0);
696 >                octreedate = time((time_t *)NULL);
697          }
698          if (oct1name == vval(OCTREE))           /* no mkillum? */
699                  oct1date = octreedate > matdate ? octreedate : matdate;
# Line 640 | Line 719 | oconv()                                /* run oconv and mkillum if necessary */
719                          unlink(oct0name);
720                          exit(1);
721                  }
722 <                oct0date = time(0);
722 >                oct0date = time((time_t *)NULL);
723          }
724          mkillumopts(mkopts);                    /* build mkillum command */
725          mktemp(illumtmp);
# Line 668 | Line 747 | oconv()                                /* run oconv and mkillum if necessary */
747                  unlink(oct1name);
748                  exit(1);
749          }
750 <        oct1date = time(0);
750 >        oct1date = time((time_t *)NULL);
751          rmfile(illumtmp);
752   }
753  
# Line 708 | Line 787 | register char  *mo;
787  
788   checkambfile()                  /* check date on ambient file */
789   {
790 <        unsigned long   afdate;
790 >        time_t  afdate;
791  
792          if (!vdef(AMBFILE))
793                  return;
# Line 723 | Line 802 | double
802   ambval()                                /* compute ambient value */
803   {
804          if (vdef(EXPOSURE)) {
726                if (!isflt(vval(EXPOSURE)))
727                        badvalue(EXPOSURE);
805                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
806                          return(.5/pow(2.,atof(vval(EXPOSURE))));
807                  return(.5/atof(vval(EXPOSURE)));
# Line 737 | Line 814 | ambval()                               /* compute ambient value */
814   }
815  
816  
817 + renderopts(op)                          /* set rendering options */
818 + char    *op;
819 + {
820 +        switch(vscale(QUALITY)) {
821 +        case LOW:
822 +                lowqopts(op);
823 +                break;
824 +        case MEDIUM:
825 +                medqopts(op);
826 +                break;
827 +        case HIGH:
828 +                hiqopts(op);
829 +                break;
830 +        }
831 + }
832 +
833 +
834   lowqopts(op)                            /* low quality rendering options */
835   register char   *op;
836   {
# Line 832 | Line 926 | register char  *op;
926          }
927          op = addarg(op, "-pt .08");
928          if (vbool(PENUMBRAS))
929 <                op = addarg(op, "-ds .2 -dj .35");
929 >                op = addarg(op, "-ds .2 -dj .5");
930          else
931                  op = addarg(op, "-ds .3");
932          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 1223 | Line 1317 | char   *opts;
1317          sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1318          if (rvdevice != NULL)
1319                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1320 +        if (vdef(EXPOSURE))
1321 +                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1322          strcat(combuf, oct1name);
1323          if (runcom(combuf)) {           /* run it */
1324                  fprintf(stderr, "%s: error running rview\n", progname);
# Line 1242 | Line 1338 | char   *opts;
1338                                          /* get pfilt options */
1339          pfiltopts(pfopts);
1340                                          /* get resolution, reporting */
1341 <        mult = vscale(QUALITY)+1;
1341 >        switch (vscale(QUALITY)) {
1342 >        case LOW:
1343 >                mult = 1;
1344 >                break;
1345 >        case MEDIUM:
1346 >                mult = 2;
1347 >                break;
1348 >        case HIGH:
1349 >                mult = 3;
1350 >                break;
1351 >        }
1352          {
1353                  int     xres, yres;
1354                  double  aspect;
# Line 1303 | Line 1409 | char   *opts;
1409                          }
1410                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1411                                          rep, vw, res, opts,
1412 <                                        oct1name, rawfile);
1412 >                                oct1name, rawfile);
1413                  }
1414                  if (runcom(combuf)) {           /* run rpict */
1415                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines