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.10 by greg, Thu May 27 17:41:46 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 */
# Line 159 | Line 166 | char   *argv[];
166                                  /* print all values if requested */
167          if (explicate)
168                  printvals();
169 <                                /* run simulation */
169 >                                /* build octree */
170          oconv();
171 +                                /* check date on ambient file */
172 +        checkambfile();
173 +                                /* run simulation */
174          renderopts(ropts);
175          xferopts(ropts);
176          if (rvdevice != NULL)
# Line 547 | Line 557 | register char  *oo;
557   }
558  
559  
560 + checkambfile()                  /* check date on ambient file */
561 + {
562 +        long    afdate;
563 +
564 +        if (vdef(AMBFILE)) {
565 +                afdate = fdate(vval(AMBFILE));
566 +                if (afdate >= 0 & octreedate > afdate)
567 +                        rmfile(vval(AMBFILE));
568 +        }
569 + }
570 +
571 +
572   double
573   ambval()                                /* compute ambient value */
574   {
# Line 664 | Line 686 | register char  *op;
686          else
687                  op = addarg(op, "-ds .3");
688          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
689 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
690 <        op += strlen(op);
689 >        if (overture = vint(INDIRECT)) {
690 >                sprintf(op, " -ab %d", overture);
691 >                op += strlen(op);
692 >        }
693          if (vdef(AMBFILE)) {
694                  sprintf(op, " -af %s", vval(AMBFILE));
695                  op += strlen(op);
# Line 760 | Line 784 | xferopts(ro)                           /* transfer options if indicated */
784   char    *ro;
785   {
786          int     fd, n;
787 +        register char   *cp;
788          
789          n = strlen(ro);
790          if (n < 2)
791                  return;
792          if (vdef(OPTFILE)) {
793 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
793 >                for (cp = ro; cp[1]; cp++)
794 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
795 >                                *cp = '\n';
796 >                        else
797 >                                *cp = cp[1];
798 >                *cp = '\n';
799 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
800 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
801                          syserr(vval(OPTFILE));
770                if (write(fd, ro+1, n-1) != n-1)
771                        syserr(vval(OPTFILE));
772                write(fd, "\n", 1);
773                close(fd);
802                  sprintf(ro, " \"^%s\"", vval(OPTFILE));
803          }
804   #ifdef MSDOS
805          else if (n > 50) {
806 <                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 <                }
806 >                setenv("ROPT", ro+1);
807                  strcpy(ro, " $ROPT");
808          }
809   #endif
# Line 924 | Line 943 | register char  *vs;
943                          cp += strlen(cp);
944                  }
945          }
946 <                                        /* append any additional options */
947 <        strcpy(cp, vs);
946 >        strcpy(cp, vs);                 /* append any additional options */
947 > #ifdef MSDOS
948 >        if (strlen(viewopts) > 40) {
949 >                setenv("VIEW", viewopts);
950 >                return("$VIEW");
951 >        }
952 > #endif
953          return(viewopts);
954   }
955  
# Line 933 | Line 957 | register char  *vs;
957   char *
958   getview(n, vn)                          /* get view n, or NULL if none */
959   int     n;
960 < char    *vn;
960 > char    *vn;            /* returned view name */
961   {
962 <        register char   *mv;
962 >        register char   *mv = NULL;
963  
964 <        if (viewselect != NULL) {
964 >        if (viewselect != NULL) {               /* command-line selected */
965                  if (n)                          /* only do one */
966                          return(NULL);
967                  if (viewselect[0] == '-') {     /* already specified */
# Line 956 | Line 980 | char   *vn;
980                                  return(specview(mv));
981                  return(specview(viewselect));   /* standard view? */
982          }
983 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
983 >        mv = nvalue(vv+VIEW, n);                /* use view n */
984 >        if (vn != NULL & mv != NULL) {
985                  if (*mv != '-')
986                          while (*mv && !isspace(*mv))
987                                  *vn++ = *mv++;
988                  *vn = '\0';
989          }
990 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
990 >        return(specview(mv));
991   }
992  
993  
# Line 1020 | Line 1045 | char   *opts;
1045                  else
1046                          badvalue(REPORT);
1047          }
1023                                        /* check date on ambient file */
1024        if (vdef(AMBFILE)) {
1025                long    afdate = fdate(vval(AMBFILE));
1026                if (afdate >= 0 & octreedate > afdate)
1027                        rmfile(vval(AMBFILE));
1028        }
1048                                          /* do each view */
1049          vn = 0;
1050          while ((vw = getview(vn++, vs)) != NULL) {
# Line 1045 | Line 1064 | char   *opts;
1064                                  sprintf(combuf,
1065                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1066                                                  rep, vw, opts,
1067 <                                                vval(OCTREE), rawfile);
1067 >                                                vval(OCTREE), overfile);
1068                                  if (runcom(combuf)) {
1069                                          fprintf(stderr,
1070 <                        "%s: error in overture for view %s\n\t%s removed\n",
1071 <                                                progname, vs, rawfile);
1053 <                                        unlink(rawfile);
1070 >                                        "%s: error in overture for view %s\n",
1071 >                                                progname, vs);
1072                                          exit(1);
1073                                  }
1074 + #ifdef NIX
1075 +                                rmfile(overfile);
1076 + #endif
1077                          }
1078                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1079                                          rep, vw, res, opts,
# Line 1108 | Line 1129 | char   *fn;
1129                  return(0);
1130          return(unlink(fn));
1131   }
1132 +
1133 +
1134 + #ifdef MSDOS
1135 + setenv(vname, value)            /* set an environment variable */
1136 + char    *vname, *value;
1137 + {
1138 +        register char   *evp;
1139 +
1140 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1141 +        if (evp == NULL)
1142 +                syserr(progname);
1143 +        sprintf(evp, "%s=%s", vname, value);
1144 +        if (putenv(evp) != 0) {
1145 +                fprintf(stderr, "%s: out of environment space\n", progname);
1146 +                exit(1);
1147 +        }
1148 +        if (!silent)
1149 +                printf("set %s\n", evp);
1150 + }
1151 + #endif
1152  
1153  
1154   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines