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.31 by greg, Thu Nov 11 13:17:01 1993 UTC

# Line 21 | Line 21 | typedef struct {
21          int     (*fixval)();    /* assignment checking function */
22   } VARIABLE;
23  
24 < int     onevalue(), catvalues();
24 > int     onevalue(), catvalues(), boolvalue(),
25 >        qualvalue(), fltvalue(), intvalue();
26  
27                                  /* variables */
28   #define OBJECT          0               /* object files */
# Line 61 | Line 62 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
62          {"pfilt",       2,      0,      NULL,   catvalues},
63          {"view",        2,      0,      NULL,   NULL},
64          {"ZONE",        2,      0,      NULL,   onevalue},
65 <        {"QUALITY",     3,      0,      NULL,   onevalue},
65 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
66          {"OCTREE",      3,      0,      NULL,   onevalue},
67          {"PICTURE",     3,      0,      NULL,   onevalue},
68          {"AMBFILE",     3,      0,      NULL,   onevalue},
69          {"OPTFILE",     3,      0,      NULL,   onevalue},
70 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
70 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
71          {"RESOLUTION",  3,      0,      NULL,   onevalue},
72          {"UP",          2,      0,      NULL,   onevalue},
73 <        {"INDIRECT",    3,      0,      NULL,   onevalue},
74 <        {"DETAIL",      3,      0,      NULL,   onevalue},
75 <        {"PENUMBRAS",   3,      0,      NULL,   onevalue},
76 <        {"VARIABILITY", 3,      0,      NULL,   onevalue},
73 >        {"INDIRECT",    3,      0,      NULL,   intvalue},
74 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
75 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
76 >        {"VARIABILITY", 3,      0,      NULL,   qualvalue},
77          {"REPORT",      3,      0,      NULL,   onevalue},
78   };
79  
80   VARIABLE        *matchvar();
81   char    *nvalue();
81 int     vscale();
82  
83   #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
84  
# Line 87 | Line 87 | int    vscale();
87   #define vval(vc)        (vv[vc].value)
88   #define vint(vc)        atoi(vval(vc))
89   #define vlet(vc)        UPPER(vval(vc)[0])
90 + #define vscale          vlet
91   #define vbool(vc)       (vlet(vc)=='T')
92  
93 < #define HIGH            2
94 < #define MEDIUM          1
95 < #define LOW             0
93 > #define HIGH            'H'
94 > #define MEDIUM          'M'
95 > #define LOW             'L'
96  
96 int     lowqopts(), medqopts(), hiqopts();
97 int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
98
99 #define renderopts      (*setqopts[vscale(QUALITY)])
100
97                                  /* overture calculation file */
98   #ifdef NIX
99   char    overfile[] = "overture.raw";
# 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 + 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   unsigned long
464   checklast(fnames)                       /* check files and find most recent */
465   register char   *fnames;
# Line 723 | Line 781 | double
781   ambval()                                /* compute ambient value */
782   {
783          if (vdef(EXPOSURE)) {
726                if (!isflt(vval(EXPOSURE)))
727                        badvalue(EXPOSURE);
784                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
785                          return(.5/pow(2.,atof(vval(EXPOSURE))));
786                  return(.5/atof(vval(EXPOSURE)));
# Line 737 | Line 793 | ambval()                               /* compute ambient value */
793   }
794  
795  
796 + renderopts(op)                          /* set rendering options */
797 + char    *op;
798 + {
799 +        switch(vscale(QUALITY)) {
800 +        case LOW:
801 +                lowqopts(op);
802 +                break;
803 +        case MEDIUM:
804 +                medqopts(op);
805 +                break;
806 +        case HIGH:
807 +                lowqopts(op);
808 +                break;
809 +        }
810 + }
811 +
812 +
813   lowqopts(op)                            /* low quality rendering options */
814   register char   *op;
815   {
# Line 832 | Line 905 | register char  *op;
905          }
906          op = addarg(op, "-pt .08");
907          if (vbool(PENUMBRAS))
908 <                op = addarg(op, "-ds .2 -dj .35");
908 >                op = addarg(op, "-ds .2 -dj .5");
909          else
910                  op = addarg(op, "-ds .3");
911          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
# Line 1223 | Line 1296 | char   *opts;
1296          sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1297          if (rvdevice != NULL)
1298                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1299 +        if (vdef(EXPOSURE))
1300 +                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1301          strcat(combuf, oct1name);
1302          if (runcom(combuf)) {           /* run it */
1303                  fprintf(stderr, "%s: error running rview\n", progname);
# Line 1242 | Line 1317 | char   *opts;
1317                                          /* get pfilt options */
1318          pfiltopts(pfopts);
1319                                          /* get resolution, reporting */
1320 <        mult = vscale(QUALITY)+1;
1320 >        switch (vscale(QUALITY)) {
1321 >        case LOW:
1322 >                mult = 1;
1323 >                break;
1324 >        case MEDIUM:
1325 >                mult = 2;
1326 >                break;
1327 >        case HIGH:
1328 >                mult = 3;
1329 >                break;
1330 >        }
1331          {
1332                  int     xres, yres;
1333                  double  aspect;
# Line 1303 | Line 1388 | char   *opts;
1388                          }
1389                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1390                                          rep, vw, res, opts,
1391 <                                        oct1name, rawfile);
1391 >                                oct1name, rawfile);
1392                  }
1393                  if (runcom(combuf)) {           /* run rpict */
1394                          fprintf(stderr, "%s: error rendering view %s\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines