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.4 by greg, Fri Mar 12 13:37:03 1993 UTC vs.
Revision 2.24 by greg, Thu Sep 9 13:07:13 1993 UTC

# Line 94 | Line 94 | int    (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
94  
95   #define renderopts      (*setqopts[vscale(QUALITY)])
96  
97 +                                /* overture calculation file */
98 + #ifdef NIX
99 + char    overfile[] = "overture.raw";
100 + #else
101 + char    overfile[] = "/dev/null";
102 + #endif
103 +
104   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 135 | 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 143 | 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 159 | Line 173 | char   *argv[];
173                                  /* print all values if requested */
174          if (explicate)
175                  printvals();
176 <                                /* run simulation */
176 >                                /* build octree */
177          oconv();
178 +                                /* check date on ambient file */
179 +        checkambfile();
180 +                                /* run simulation */
181          renderopts(ropts);
182          xferopts(ropts);
183          if (rvdevice != NULL)
# Line 299 | 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 413 | 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 547 | Line 567 | register char  *oo;
567   }
568  
569  
570 + checkambfile()                  /* check date on ambient file */
571 + {
572 +        long    afdate;
573 +
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 +
583   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] == '.')
557 <                        return(.5/atof(vval(EXPOSURE)));
558 <                badvalue(EXPOSURE);
591 >                return(.5/atof(vval(EXPOSURE)));
592          }
593          if (vlet(ZONE) == 'E')
594                  return(10.);
# Line 579 | Line 612 | register char  *op;
612          d *= 3./(siz[0]+siz[1]+siz[2]);
613          switch (vscale(DETAIL)) {
614          case LOW:
615 <                op = addarg(op, "-ps 16 -dp 16");
615 >                op = addarg(op, "-ps 16 -dp 64");
616                  sprintf(op, " -ar %d", (int)(4*d));
617                  op += strlen(op);
618                  break;
619          case MEDIUM:
620 <                op = addarg(op, "-ps 8 -dp 32");
620 >                op = addarg(op, "-ps 8 -dp 128");
621                  sprintf(op, " -ar %d", (int)(8*d));
622                  op += strlen(op);
623                  break;
624          case HIGH:
625 <                op = addarg(op, "-ps 4 -dp 64");
625 >                op = addarg(op, "-ps 4 -dp 256");
626                  sprintf(op, " -ar %d", (int)(16*d));
627                  op += strlen(op);
628                  break;
# Line 599 | 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 607 | 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 641 | Line 674 | register char  *op;
674          switch (vscale(DETAIL)) {
675          case LOW:
676                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
677 <                op = addarg(op, "-dp 64");
677 >                op = addarg(op, "-dp 256");
678                  sprintf(op, " -ar %d", (int)(8*d));
679                  op += strlen(op);
680                  break;
681          case MEDIUM:
682                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
683 <                op = addarg(op, "-dp 128");
683 >                op = addarg(op, "-dp 512");
684                  sprintf(op, " -ar %d", (int)(16*d));
685                  op += strlen(op);
686                  break;
687          case HIGH:
688                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
689 <                op = addarg(op, "-dp 256");
689 >                op = addarg(op, "-dp 1024");
690                  sprintf(op, " -ar %d", (int)(32*d));
691                  op += strlen(op);
692                  break;
# Line 663 | 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");
700 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
701 <        op += strlen(op);
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);
703 >        }
704          if (vdef(AMBFILE)) {
705                  sprintf(op, " -af %s", vval(AMBFILE));
706                  op += strlen(op);
# Line 673 | 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 706 | Line 741 | register char  *op;
741          switch (vscale(DETAIL)) {
742          case LOW:
743                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
744 <                op = addarg(op, "-dp 256");
744 >                op = addarg(op, "-dp 1024");
745                  sprintf(op, " -ar %d", (int)(16*d));
746                  op += strlen(op);
747                  break;
748          case MEDIUM:
749                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
750 <                op = addarg(op, "-dp 512");
750 >                op = addarg(op, "-dp 2048");
751                  sprintf(op, " -ar %d", (int)(32*d));
752                  op += strlen(op);
753                  break;
754          case HIGH:
755                  op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
756 <                op = addarg(op, "-dp 1024");
756 >                op = addarg(op, "-dp 4096");
757                  sprintf(op, " -ar %d", (int)(64*d));
758                  op += strlen(op);
759                  break;
# Line 728 | 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 738 | 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 760 | 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)
771 <                        syserr(vval(OPTFILE));
772 <                write(fd, "\n", 1);
773 <                close(fd);
774 <                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);
779 <                if (evp == NULL)
780 <                        syserr(progname);
781 <                strcpy(evp, "ROPT=");
782 <                strcat(evp, ro);
783 <                if (putenv(evp) != 0) {
784 <                        fprintf(stderr, "%s: out of environment space\n",
785 <                                        progname);
786 <                        exit(1);
787 <                }
817 >                setenv("ROPT", ro+1);
818                  strcpy(ro, " $ROPT");
819          }
820   #endif
# Line 799 | 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 924 | 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 933 | 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 950 | 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(), *getenv();
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 + #ifdef MSDOS
1054 +                        if (*vopts == '$') {            /* expand env. var. */
1055 +                                if (!*atos(buf, sizeof(buf), vopts+1))
1056 +                                        return(-1);
1057 +                                if ((cp = getenv(buf)) == NULL)
1058 +                                        return(-1);
1059 +                                fputs(cp, stdout);
1060 +                                vopts = sskip(vopts);
1061 +                        } else
1062 + #endif
1063 +                                while (*vopts && !isspace(*vopts))
1064 +                                        putchar(*vopts++);
1065 +                }
1066 +        } while (*vopts++);
1067 +        putchar('\n');
1068 +        return(0);
1069 + }
1070 +
1071 +
1072   rview(opts)                             /* run rview with first view */
1073   char    *opts;
1074   {
1075 +        char    *vw;
1076          char    combuf[512];
1077                                          /* build command */
1078 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1078 >        if ((vw = getview(0, NULL)) == NULL)
1079 >                return;
1080 >        if (sayview)
1081 >                printview(vw);
1082 >        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1083          if (rvdevice != NULL)
1084                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1085          strcat(combuf, vval(OCTREE));
# Line 990 | Line 1098 | char   *opts;
1098          char    pfopts[128];
1099          char    vs[32], *vw;
1100          int     vn, mult;
1101 +        long    lastdate;
1102                                          /* get pfilt options */
1103          pfiltopts(pfopts);
1104                                          /* get resolution, reporting */
# Line 1020 | Line 1129 | char   *opts;
1129                  else
1130                          badvalue(REPORT);
1131          }
1132 <                                        /* check date on ambient file */
1133 <        if (vdef(AMBFILE)) {
1025 <                long    afdate = fdate(vval(AMBFILE));
1026 <                if (afdate >= 0 & octreedate > afdate)
1027 <                        rmfile(vval(AMBFILE));
1028 <        }
1132 >                                        /* get update time */
1133 >        lastdate = octreedate > matdate ? octreedate : matdate;
1134                                          /* do each view */
1135          vn = 0;
1136          while ((vw = getview(vn++, vs)) != NULL) {
1137 +                if (sayview)
1138 +                        printview(vw);
1139                  if (!vs[0])
1140                          sprintf(vs, "%d", vn);
1141                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1142                                                  /* check date on picture */
1143 <                if (fdate(picfile) > octreedate)
1143 >                if (fdate(picfile) >= lastdate)
1144                          continue;
1145                                                  /* build rpict command */
1146                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1147 <                if (fdate(rawfile) > octreedate)        /* recover */
1147 >                if (fdate(rawfile) >= octreedate)       /* recover */
1148                          sprintf(combuf, "rpict%s%s -ro %s %s",
1149                                          rep, opts, rawfile, vval(OCTREE));
1150                  else {
# Line 1045 | Line 1152 | char   *opts;
1152                                  sprintf(combuf,
1153                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1154                                                  rep, vw, opts,
1155 <                                                vval(OCTREE), rawfile);
1155 >                                                vval(OCTREE), overfile);
1156                                  if (runcom(combuf)) {
1157                                          fprintf(stderr,
1158 <                        "%s: error in overture for view %s\n\t%s removed\n",
1159 <                                                progname, vs, rawfile);
1053 <                                        unlink(rawfile);
1158 >                                        "%s: error in overture for view %s\n",
1159 >                                                progname, vs);
1160                                          exit(1);
1161                                  }
1162 + #ifdef NIX
1163 +                                rmfile(overfile);
1164 + #endif
1165                          }
1166                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1167                                          rep, vw, res, opts,
# Line 1108 | Line 1217 | char   *fn;
1217                  return(0);
1218          return(unlink(fn));
1219   }
1220 +
1221 +
1222 + #ifdef MSDOS
1223 + setenv(vname, value)            /* set an environment variable */
1224 + char    *vname, *value;
1225 + {
1226 +        register char   *evp;
1227 +
1228 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1229 +        if (evp == NULL)
1230 +                syserr(progname);
1231 +        sprintf(evp, "%s=%s", vname, value);
1232 +        if (putenv(evp) != 0) {
1233 +                fprintf(stderr, "%s: out of environment space\n", progname);
1234 +                exit(1);
1235 +        }
1236 +        if (!silent)
1237 +                printf("set %s\n", evp);
1238 + }
1239 + #endif
1240  
1241  
1242   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines