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.7 by greg, Tue Apr 6 17:21:04 1993 UTC vs.
Revision 2.22 by greg, Wed Aug 25 13:48:37 1993 UTC

# Line 105 | Line 105 | extern long    fdate(), time();
105  
106   long    scenedate;              /* date of latest scene or object file */
107   long    octreedate;             /* date of octree */
108 + long    matdate;                /* date of latest material file */
109  
110   int     explicate = 0;          /* explicate variables */
111   int     silent = 0;             /* do work silently */
112   int     noaction = 0;           /* don't do anything */
113 + int     sayview = 0;            /* print view out */
114   char    *rvdevice = NULL;       /* rview output device */
115   char    *viewselect = NULL;     /* specific view only */
116  
117   int     overture = 0;           /* overture calculation needed */
118  
119   char    *progname;              /* global argv[0] */
120 + char    *rifname;               /* global rad input file name */
121  
122   char    radname[MAXPATH];       /* root Radiance file name */
123  
# Line 142 | Line 145 | char   *argv[];
145                  case 'o':
146                          rvdevice = argv[++i];
147                          break;
148 +                case 'V':
149 +                        sayview++;
150 +                        break;
151                  case 'v':
152                          viewselect = argv[++i];
153                          break;
# Line 150 | Line 156 | char   *argv[];
156                  }
157          if (i >= argc)
158                  goto userr;
159 +        rifname = argv[i];
160                                  /* assign Radiance root file name */
161 <        rootname(radname, argv[i]);
161 >        rootname(radname, rifname);
162                                  /* load variable values */
163 <        load(argv[i]);
163 >        load(rifname);
164                                  /* get any additional assignments */
165          for (i++; i < argc; i++)
166                  setvariable(argv[i]);
# Line 309 | Line 316 | register int   n;
316   {
317          register char   *cp;
318  
319 <        if (vp == NULL || n < 0 || n >= vp->nass)
319 >        if (vp == NULL | n < 0 | n >= vp->nass)
320                  return(NULL);
321          cp = vp->value;
322          while (n--)
# Line 423 | Line 430 | checkfiles()                   /* check for existence and modified tim
430                                  vnam(OCTREE), vnam(SCENE));
431                  exit(1);
432          }
433 +        matdate = -1;
434 +        if (vdef(MATERIAL))
435 +                matdate = checklast(vval(MATERIAL));
436   }      
437  
438  
# Line 561 | Line 571 | checkambfile()                 /* check date on ambient file */
571   {
572          long    afdate;
573  
574 <        if (vdef(AMBFILE)) {
575 <                afdate = fdate(vval(AMBFILE));
576 <                if (afdate >= 0 & octreedate > afdate)
577 <                        rmfile(vval(AMBFILE));
578 <        }
574 >        if (!vdef(AMBFILE))
575 >                return;
576 >        if ((afdate = fdate(vval(AMBFILE))) < 0)
577 >                return;
578 >        if (octreedate > afdate | matdate > afdate)
579 >                rmfile(vval(AMBFILE));
580   }
581  
582  
# Line 573 | Line 584 | double
584   ambval()                                /* compute ambient value */
585   {
586          if (vdef(EXPOSURE)) {
587 +                if (!isflt(vval(EXPOSURE)))
588 +                        badvalue(EXPOSURE);
589                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
590                          return(.5/pow(2.,atof(vval(EXPOSURE))));
591 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
579 <                        return(.5/atof(vval(EXPOSURE)));
580 <                badvalue(EXPOSURE);
591 >                return(.5/atof(vval(EXPOSURE)));
592          }
593          if (vlet(ZONE) == 'E')
594                  return(10.);
# Line 621 | Line 632 | register char  *op;
632                  op = addarg(op, "-ds .4");
633          else
634                  op = addarg(op, "-ds 0");
635 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
635 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
636          if (vdef(AMBFILE)) {
637                  sprintf(op, " -af %s", vval(AMBFILE));
638                  op += strlen(op);
# Line 629 | Line 640 | register char  *op;
640                  overture = 0;
641          switch (vscale(VARIABILITY)) {
642          case LOW:
643 <                op = addarg(op, "-aa .4 -ad 32");
643 >                op = addarg(op, "-aa .4 -ad 64");
644                  break;
645          case MEDIUM:
646 <                op = addarg(op, "-aa .3 -ad 64");
646 >                op = addarg(op, "-aa .3 -ad 128");
647                  break;
648          case HIGH:
649 <                op = addarg(op, "-aa .25 -ad 128");
649 >                op = addarg(op, "-aa .25 -ad 256");
650                  break;
651          }
652          op = addarg(op, "-as 0");
# Line 685 | Line 696 | register char  *op;
696                  op = addarg(op, "-ds .2 -dj .35");
697          else
698                  op = addarg(op, "-ds .3");
699 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
699 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
700          if (overture = vint(INDIRECT)) {
701                  sprintf(op, " -ab %d", overture);
702                  op += strlen(op);
# Line 697 | Line 708 | register char  *op;
708                  overture = 0;
709          switch (vscale(VARIABILITY)) {
710          case LOW:
711 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
711 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
712                  break;
713          case MEDIUM:
714 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
714 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
715                  break;
716          case HIGH:
717 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
717 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
718                  break;
719          }
720          d = ambval();
# Line 752 | Line 763 | register char  *op;
763                  op = addarg(op, "-ds .1 -dj .7");
764          else
765                  op = addarg(op, "-ds .2");
766 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
766 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
767          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
768          op += strlen(op);
769          if (vdef(AMBFILE)) {
# Line 762 | Line 773 | register char  *op;
773                  overture = 0;
774          switch (vscale(VARIABILITY)) {
775          case LOW:
776 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
776 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
777                  break;
778          case MEDIUM:
779 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
779 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
780                  break;
781          case HIGH:
782 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
782 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
783                  break;
784          }
785          d = ambval();
# Line 784 | Line 795 | xferopts(ro)                           /* transfer options if indicated */
795   char    *ro;
796   {
797          int     fd, n;
798 +        register char   *cp;
799          
800          n = strlen(ro);
801          if (n < 2)
802                  return;
803          if (vdef(OPTFILE)) {
804 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
804 >                for (cp = ro; cp[1]; cp++)
805 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
806 >                                *cp = '\n';
807 >                        else
808 >                                *cp = cp[1];
809 >                *cp = '\n';
810 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
811 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
812                          syserr(vval(OPTFILE));
813 <                if (write(fd, ro+1, n-1) != n-1)
795 <                        syserr(vval(OPTFILE));
796 <                write(fd, "\n", 1);
797 <                close(fd);
798 <                sprintf(ro, " \"^%s\"", vval(OPTFILE));
813 >                sprintf(ro, " @%s", vval(OPTFILE));
814          }
815   #ifdef MSDOS
816          else if (n > 50) {
817 <                register char   *evp = bmalloc(n+6);
803 <                if (evp == NULL)
804 <                        syserr(progname);
805 <                strcpy(evp, "ROPT=");
806 <                strcat(evp, ro);
807 <                if (putenv(evp) != 0) {
808 <                        fprintf(stderr, "%s: out of environment space\n",
809 <                                        progname);
810 <                        exit(1);
811 <                }
817 >                setenv("ROPT", ro+1);
818                  strcpy(ro, " $ROPT");
819          }
820   #endif
# Line 823 | Line 829 | register char  *po;
829                  po = addarg(po, "-1 -e");
830                  po = addarg(po, vval(EXPOSURE));
831          }
832 <        if (vscale(QUALITY) == HIGH)
833 <                po = addarg(po, "-r .65");
832 >        switch (vscale(QUALITY)) {
833 >        case MEDIUM:
834 >                po = addarg(po, "-r 1");
835 >                break;
836 >        case HIGH:
837 >                po = addarg(po, "-m .25");
838 >                break;
839 >        }
840          if (vdef(PFILT))
841                  po = addarg(po, vval(PFILT));
842   }
# Line 948 | Line 960 | register char  *vs;
960                          cp += strlen(cp);
961                  }
962          }
963 <                                        /* append any additional options */
964 <        strcpy(cp, vs);
963 >        strcpy(cp, vs);                 /* append any additional options */
964 > #ifdef MSDOS
965 >        if (strlen(viewopts) > 40) {
966 >                setenv("VIEW", viewopts);
967 >                return("$VIEW");
968 >        }
969 > #endif
970          return(viewopts);
971   }
972  
# Line 957 | Line 974 | register char  *vs;
974   char *
975   getview(n, vn)                          /* get view n, or NULL if none */
976   int     n;
977 < char    *vn;
977 > char    *vn;            /* returned view name */
978   {
979          register char   *mv;
980  
981 <        if (viewselect != NULL) {
981 >        if (viewselect != NULL) {               /* command-line selected */
982                  if (n)                          /* only do one */
983                          return(NULL);
984                  if (viewselect[0] == '-') {     /* already specified */
# Line 974 | Line 991 | char   *vn;
991                                  ;
992                          *vn = '\0';
993                  }
994 +                                                /* view number? */
995 +                if (isint(viewselect))
996 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
997                                                  /* check list */
998                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
999                          if (matchword(viewselect, mv))
1000                                  return(specview(mv));
1001                  return(specview(viewselect));   /* standard view? */
1002          }
1003 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
1004 <                if (*mv != '-')
1005 <                        while (*mv && !isspace(*mv))
1006 <                                *vn++ = *mv++;
1003 >        mv = nvalue(vv+VIEW, n);                /* use view n */
1004 >        if (vn != NULL & mv != NULL) {
1005 >                register char   *mv2 = mv;
1006 >                if (*mv2 != '-')
1007 >                        while (*mv2 && !isspace(*mv2))
1008 >                                *vn++ = *mv2++;
1009                  *vn = '\0';
1010          }
1011 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
1011 >        return(specview(mv));
1012   }
1013  
1014  
1015 + printview(vopts)                        /* print out selected view */
1016 + register char   *vopts;
1017 + {
1018 +        extern char     *atos();
1019 +        char    buf[256];
1020 +        FILE    *fp;
1021 +        register char   *cp;
1022 +
1023 +        if (vopts == NULL)
1024 +                return(-1);
1025 +        fputs("VIEW=", stdout);
1026 +        do {
1027 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1028 +                        vopts = sskip(vopts);
1029 +                        if (!*atos(buf, sizeof(buf), vopts))
1030 +                                return(-1);
1031 +                        if ((fp = fopen(buf, "r")) == NULL)
1032 +                                return(-1);
1033 +                        for (buf[sizeof(buf)-2] = '\n';
1034 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1035 +                                                buf[0] != '\n';
1036 +                                        buf[sizeof(buf)-2] = '\n') {
1037 +                                if (buf[sizeof(buf)-2] != '\n') {
1038 +                                        ungetc(buf[sizeof(buf)-2], fp);
1039 +                                        buf[sizeof(buf)-2] = '\0';
1040 +                                }
1041 +                                if (matchword(buf, "VIEW=") ||
1042 +                                                matchword(buf, "rview")) {
1043 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1044 +                                                putchar(*cp);
1045 +                                }
1046 +                        }
1047 +                        fclose(fp);
1048 +                        vopts = sskip(vopts);
1049 +                } else {
1050 +                        while (isspace(*vopts))
1051 +                                vopts++;
1052 +                        putchar(' ');
1053 +                        while (*vopts && !isspace(*vopts))
1054 +                                putchar(*vopts++);
1055 +                }
1056 +        } while (*vopts++);
1057 +        putchar('\n');
1058 +        return(0);
1059 + }
1060 +
1061 +
1062   rview(opts)                             /* run rview with first view */
1063   char    *opts;
1064   {
1065 +        char    *vw;
1066          char    combuf[512];
1067                                          /* build command */
1068 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1068 >        if ((vw = getview(0, NULL)) == NULL)
1069 >                return;
1070 >        if (sayview)
1071 >                printview(vw);
1072 >        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1073          if (rvdevice != NULL)
1074                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1075          strcat(combuf, vval(OCTREE));
# Line 1014 | Line 1088 | char   *opts;
1088          char    pfopts[128];
1089          char    vs[32], *vw;
1090          int     vn, mult;
1091 +        long    lastdate;
1092                                          /* get pfilt options */
1093          pfiltopts(pfopts);
1094                                          /* get resolution, reporting */
# Line 1044 | Line 1119 | char   *opts;
1119                  else
1120                          badvalue(REPORT);
1121          }
1122 +                                        /* get update time */
1123 +        lastdate = octreedate > matdate ? octreedate : matdate;
1124                                          /* do each view */
1125          vn = 0;
1126          while ((vw = getview(vn++, vs)) != NULL) {
1127 +                if (sayview)
1128 +                        printview(vw);
1129                  if (!vs[0])
1130                          sprintf(vs, "%d", vn);
1131                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1132                                                  /* check date on picture */
1133 <                if (fdate(picfile) > octreedate)
1133 >                if (fdate(picfile) >= lastdate)
1134                          continue;
1135                                                  /* build rpict command */
1136                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1137 <                if (fdate(rawfile) > octreedate)        /* recover */
1137 >                if (fdate(rawfile) >= octreedate)       /* recover */
1138                          sprintf(combuf, "rpict%s%s -ro %s %s",
1139                                          rep, opts, rawfile, vval(OCTREE));
1140                  else {
# Line 1128 | Line 1207 | char   *fn;
1207                  return(0);
1208          return(unlink(fn));
1209   }
1210 +
1211 +
1212 + #ifdef MSDOS
1213 + setenv(vname, value)            /* set an environment variable */
1214 + char    *vname, *value;
1215 + {
1216 +        register char   *evp;
1217 +
1218 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1219 +        if (evp == NULL)
1220 +                syserr(progname);
1221 +        sprintf(evp, "%s=%s", vname, value);
1222 +        if (putenv(evp) != 0) {
1223 +                fprintf(stderr, "%s: out of environment space\n", progname);
1224 +                exit(1);
1225 +        }
1226 +        if (!silent)
1227 +                printf("set %s\n", evp);
1228 + }
1229 + #endif
1230  
1231  
1232   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines