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.20 by greg, Tue Aug 24 21:44:55 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     vwonly = 0;             /* print view only */
114   char    *rvdevice = NULL;       /* rview output device */
115   char    *viewselect = NULL;     /* specific view only */
116  
# Line 142 | Line 144 | char   *argv[];
144                  case 'o':
145                          rvdevice = argv[++i];
146                          break;
147 +                case 'V':
148 +                        vwonly++;
149 +                /* fall through */
150                  case 'v':
151                          viewselect = argv[++i];
152                          break;
# Line 166 | Line 171 | char   *argv[];
171                                  /* print all values if requested */
172          if (explicate)
173                  printvals();
174 +                                /* print view and exit? */
175 +        if (vwonly)
176 +                exit(printview()==0 ? 0 : 1);
177                                  /* build octree */
178          oconv();
179                                  /* check date on ambient file */
# Line 309 | Line 317 | register int   n;
317   {
318          register char   *cp;
319  
320 <        if (vp == NULL || n < 0 || n >= vp->nass)
320 >        if (vp == NULL | n < 0 | n >= vp->nass)
321                  return(NULL);
322          cp = vp->value;
323          while (n--)
# Line 423 | Line 431 | checkfiles()                   /* check for existence and modified tim
431                                  vnam(OCTREE), vnam(SCENE));
432                  exit(1);
433          }
434 +        matdate = -1;
435 +        if (vdef(MATERIAL))
436 +                matdate = checklast(vval(MATERIAL));
437   }      
438  
439  
# Line 561 | Line 572 | checkambfile()                 /* check date on ambient file */
572   {
573          long    afdate;
574  
575 <        if (vdef(AMBFILE)) {
576 <                afdate = fdate(vval(AMBFILE));
577 <                if (afdate >= 0 & octreedate > afdate)
578 <                        rmfile(vval(AMBFILE));
579 <        }
575 >        if (!vdef(AMBFILE))
576 >                return;
577 >        if ((afdate = fdate(vval(AMBFILE))) < 0)
578 >                return;
579 >        if (octreedate > afdate | matdate > afdate)
580 >                rmfile(vval(AMBFILE));
581   }
582  
583  
# Line 573 | Line 585 | double
585   ambval()                                /* compute ambient value */
586   {
587          if (vdef(EXPOSURE)) {
588 +                if (!isflt(vval(EXPOSURE)))
589 +                        badvalue(EXPOSURE);
590                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
591                          return(.5/pow(2.,atof(vval(EXPOSURE))));
592 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
579 <                        return(.5/atof(vval(EXPOSURE)));
580 <                badvalue(EXPOSURE);
592 >                return(.5/atof(vval(EXPOSURE)));
593          }
594          if (vlet(ZONE) == 'E')
595                  return(10.);
# Line 621 | Line 633 | register char  *op;
633                  op = addarg(op, "-ds .4");
634          else
635                  op = addarg(op, "-ds 0");
636 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
636 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
637          if (vdef(AMBFILE)) {
638                  sprintf(op, " -af %s", vval(AMBFILE));
639                  op += strlen(op);
# Line 629 | Line 641 | register char  *op;
641                  overture = 0;
642          switch (vscale(VARIABILITY)) {
643          case LOW:
644 <                op = addarg(op, "-aa .4 -ad 32");
644 >                op = addarg(op, "-aa .4 -ad 64");
645                  break;
646          case MEDIUM:
647 <                op = addarg(op, "-aa .3 -ad 64");
647 >                op = addarg(op, "-aa .3 -ad 128");
648                  break;
649          case HIGH:
650 <                op = addarg(op, "-aa .25 -ad 128");
650 >                op = addarg(op, "-aa .25 -ad 256");
651                  break;
652          }
653          op = addarg(op, "-as 0");
# Line 685 | Line 697 | register char  *op;
697                  op = addarg(op, "-ds .2 -dj .35");
698          else
699                  op = addarg(op, "-ds .3");
700 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
700 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
701          if (overture = vint(INDIRECT)) {
702                  sprintf(op, " -ab %d", overture);
703                  op += strlen(op);
# Line 697 | Line 709 | register char  *op;
709                  overture = 0;
710          switch (vscale(VARIABILITY)) {
711          case LOW:
712 <                op = addarg(op, "-aa .25 -ad 128 -as 0");
712 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
713                  break;
714          case MEDIUM:
715 <                op = addarg(op, "-aa .2 -ad 300 -as 64");
715 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
716                  break;
717          case HIGH:
718 <                op = addarg(op, "-aa .15 -ad 500 -as 128");
718 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
719                  break;
720          }
721          d = ambval();
# Line 752 | Line 764 | register char  *op;
764                  op = addarg(op, "-ds .1 -dj .7");
765          else
766                  op = addarg(op, "-ds .2");
767 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
767 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
768          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
769          op += strlen(op);
770          if (vdef(AMBFILE)) {
# Line 762 | Line 774 | register char  *op;
774                  overture = 0;
775          switch (vscale(VARIABILITY)) {
776          case LOW:
777 <                op = addarg(op, "-aa .15 -ad 200 -as 0");
777 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
778                  break;
779          case MEDIUM:
780 <                op = addarg(op, "-aa .125 -ad 512 -as 128");
780 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
781                  break;
782          case HIGH:
783 <                op = addarg(op, "-aa .08 -ad 850 -as 256");
783 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
784                  break;
785          }
786          d = ambval();
# Line 784 | Line 796 | xferopts(ro)                           /* transfer options if indicated */
796   char    *ro;
797   {
798          int     fd, n;
799 +        register char   *cp;
800          
801          n = strlen(ro);
802          if (n < 2)
803                  return;
804          if (vdef(OPTFILE)) {
805 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
805 >                for (cp = ro; cp[1]; cp++)
806 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
807 >                                *cp = '\n';
808 >                        else
809 >                                *cp = cp[1];
810 >                *cp = '\n';
811 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
812 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
813                          syserr(vval(OPTFILE));
814 <                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));
814 >                sprintf(ro, " @%s", vval(OPTFILE));
815          }
816   #ifdef MSDOS
817          else if (n > 50) {
818 <                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 <                }
818 >                setenv("ROPT", ro+1);
819                  strcpy(ro, " $ROPT");
820          }
821   #endif
# Line 823 | Line 830 | register char  *po;
830                  po = addarg(po, "-1 -e");
831                  po = addarg(po, vval(EXPOSURE));
832          }
833 <        if (vscale(QUALITY) == HIGH)
834 <                po = addarg(po, "-r .65");
833 >        switch (vscale(QUALITY)) {
834 >        case MEDIUM:
835 >                po = addarg(po, "-r 1");
836 >                break;
837 >        case HIGH:
838 >                po = addarg(po, "-m .25");
839 >                break;
840 >        }
841          if (vdef(PFILT))
842                  po = addarg(po, vval(PFILT));
843   }
# Line 948 | Line 961 | register char  *vs;
961                          cp += strlen(cp);
962                  }
963          }
964 <                                        /* append any additional options */
965 <        strcpy(cp, vs);
964 >        strcpy(cp, vs);                 /* append any additional options */
965 > #ifdef MSDOS
966 >        if (strlen(viewopts) > 40) {
967 >                setenv("VIEW", viewopts);
968 >                return("$VIEW");
969 >        }
970 > #endif
971          return(viewopts);
972   }
973  
# Line 957 | Line 975 | register char  *vs;
975   char *
976   getview(n, vn)                          /* get view n, or NULL if none */
977   int     n;
978 < char    *vn;
978 > char    *vn;            /* returned view name */
979   {
980          register char   *mv;
981  
982 <        if (viewselect != NULL) {
982 >        if (viewselect != NULL) {               /* command-line selected */
983                  if (n)                          /* only do one */
984                          return(NULL);
985                  if (viewselect[0] == '-') {     /* already specified */
# Line 974 | Line 992 | char   *vn;
992                                  ;
993                          *vn = '\0';
994                  }
995 +                                                /* view number? */
996 +                if (isint(viewselect))
997 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
998                                                  /* check list */
999                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1000                          if (matchword(viewselect, mv))
1001                                  return(specview(mv));
1002                  return(specview(viewselect));   /* standard view? */
1003          }
1004 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
1005 <                if (*mv != '-')
1006 <                        while (*mv && !isspace(*mv))
1007 <                                *vn++ = *mv++;
1004 >        mv = nvalue(vv+VIEW, n);                /* use view n */
1005 >        if (vn != NULL & mv != NULL) {
1006 >                register char   *mv2 = mv;
1007 >                if (*mv2 != '-')
1008 >                        while (*mv2 && !isspace(*mv2))
1009 >                                *vn++ = *mv2++;
1010                  *vn = '\0';
1011          }
1012 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
1012 >        return(specview(mv));
1013   }
1014  
1015  
1016 + printview()                     /* print out selected view */
1017 + {
1018 +        extern char     *atos();
1019 +        char    buf[256];
1020 +        FILE    *fp;
1021 +        register char   *vopts, *cp;
1022 +
1023 +        vopts = getview(0, NULL);
1024 +        if (vopts == NULL)
1025 +                return(-1);
1026 +        fputs("VIEW=", stdout);
1027 +        do {
1028 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1029 +                        vopts = sskip(vopts);
1030 +                        if (!*atos(buf, sizeof(buf), vopts))
1031 +                                return(-1);
1032 +                        if ((fp = fopen(buf, "r")) == NULL)
1033 +                                return(-1);
1034 +                        for (buf[sizeof(buf)-2] = '\n';
1035 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1036 +                                                buf[0] != '\n';
1037 +                                        buf[sizeof(buf)-2] = '\n') {
1038 +                                if (buf[sizeof(buf)-2] != '\n') {
1039 +                                        ungetc(buf[sizeof(buf)-2], fp);
1040 +                                        buf[sizeof(buf)-2] = '\0';
1041 +                                }
1042 +                                if (matchword(buf, "VIEW=") ||
1043 +                                                matchword(buf, "rview")) {
1044 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1045 +                                                putchar(*cp);
1046 +                                }
1047 +                        }
1048 +                        fclose(fp);
1049 +                        vopts = sskip(vopts);
1050 +                } else {
1051 +                        while (isspace(*vopts))
1052 +                                vopts++;
1053 +                        putchar(' ');
1054 +                        while (*vopts && !isspace(*vopts))
1055 +                                putchar(*vopts++);
1056 +                }
1057 +        } while (*vopts++);
1058 +        putchar('\n');
1059 +        return(0);
1060 + }
1061 +
1062 +
1063   rview(opts)                             /* run rview with first view */
1064   char    *opts;
1065   {
# Line 1014 | Line 1084 | char   *opts;
1084          char    pfopts[128];
1085          char    vs[32], *vw;
1086          int     vn, mult;
1087 +        long    lastdate;
1088                                          /* get pfilt options */
1089          pfiltopts(pfopts);
1090                                          /* get resolution, reporting */
# Line 1044 | Line 1115 | char   *opts;
1115                  else
1116                          badvalue(REPORT);
1117          }
1118 +                                        /* get update time */
1119 +        lastdate = octreedate > matdate ? octreedate : matdate;
1120                                          /* do each view */
1121          vn = 0;
1122          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1051 | Line 1124 | char   *opts;
1124                          sprintf(vs, "%d", vn);
1125                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1126                                                  /* check date on picture */
1127 <                if (fdate(picfile) > octreedate)
1127 >                if (fdate(picfile) >= lastdate)
1128                          continue;
1129                                                  /* build rpict command */
1130                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1131 <                if (fdate(rawfile) > octreedate)        /* recover */
1131 >                if (fdate(rawfile) >= octreedate)       /* recover */
1132                          sprintf(combuf, "rpict%s%s -ro %s %s",
1133                                          rep, opts, rawfile, vval(OCTREE));
1134                  else {
# Line 1128 | Line 1201 | char   *fn;
1201                  return(0);
1202          return(unlink(fn));
1203   }
1204 +
1205 +
1206 + #ifdef MSDOS
1207 + setenv(vname, value)            /* set an environment variable */
1208 + char    *vname, *value;
1209 + {
1210 +        register char   *evp;
1211 +
1212 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1213 +        if (evp == NULL)
1214 +                syserr(progname);
1215 +        sprintf(evp, "%s=%s", vname, value);
1216 +        if (putenv(evp) != 0) {
1217 +                fprintf(stderr, "%s: out of environment space\n", progname);
1218 +                exit(1);
1219 +        }
1220 +        if (!silent)
1221 +                printf("set %s\n", evp);
1222 + }
1223 + #endif
1224  
1225  
1226   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines