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.3 by greg, Thu Mar 11 17:23:33 1993 UTC vs.
Revision 2.20 by greg, Tue Aug 24 21:44:55 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     vwonly = 0;             /* print view only */
114   char    *rvdevice = NULL;       /* rview output device */
115   char    *viewselect = NULL;     /* specific view only */
116  
# Line 135 | 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 159 | Line 171 | char   *argv[];
171                                  /* print all values if requested */
172          if (explicate)
173                  printvals();
174 <                                /* run simulation */
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 */
180 +        checkambfile();
181 +                                /* run simulation */
182          renderopts(ropts);
183          xferopts(ropts);
184          if (rvdevice != NULL)
# Line 195 | Line 213 | load(rfname)                   /* load Radiance simulation file */
213   char    *rfname;
214   {
215          FILE    *fp;
216 <        char    buf[256];
216 >        char    buf[512];
217          register char   *cp;
218  
219          if (rfname == NULL)
# Line 212 | Line 230 | char   *rfname;
230                          case '#':
231                                  *cp = '\0';
232                                  break;
233 +                        default:
234 +                                continue;
235                          }
236                          break;
237                  }
# Line 260 | Line 280 | register char  *ass;
280                  exit(1);
281          }
282                                          /* assign new value */
283 <        cp = vp->value; i = vp->nass;
284 <        while (i--)
285 <                while (*cp++)
286 <                        ;
287 <        i = cp - vp->value;
288 <        vp->value = realloc(vp->value, i+n+1);
283 >        if (i = vp->nass) {
284 >                cp = vp->value;
285 >                while (i--)
286 >                        while (*cp++)
287 >                                ;
288 >                i = cp - vp->value;
289 >                vp->value = realloc(vp->value, i+n+1);
290 >        } else
291 >                vp->value = malloc(n+1);
292          if (vp->value == NULL)
293                  syserr(progname);
294          strcpy(vp->value+i, ass);
# Line 294 | 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 369 | Line 392 | register char  *fnames;
392          while (*fnames) {
393                  while (isspace(*fnames)) fnames++;
394                  cp = thisfile;
395 <                while (*fnames && !isspace(*fnames)) *cp++ = *fnames++;
395 >                while (*fnames && !isspace(*fnames))
396 >                        *cp++ = *fnames++;
397                  *cp = '\0';
398                  if ((thisdate = fdate(thisfile)) < 0)
399                          syserr(thisfile);
# Line 407 | 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 488 | Line 515 | printvals()                    /* print variable values */
515          register int    i, j;
516  
517          for (i = 0; i < NVARS; i++)
518 <                for (j = 0; j < vv[i].nass; j++)
519 <                        printf("%s= %s\n", vv[i].name, nvalue(vv+i, j));
518 >                for (j = 0; j < vdef(i); j++)
519 >                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
520          fflush(stdout);
521   }
522  
# Line 502 | Line 529 | oconv()                                /* run oconv if necessary */
529                  return;
530                                          /* build command */
531          oconvopts(ocopts);
532 <        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
533 <                        vdef(MATERIAL) ? vval(MATERIAL) : "",
534 <                        vval(SCENE), vval(OCTREE));
535 <        if (!silent) {                  /* echo it */
536 <                printf("\t%s\n", combuf);
537 <                fflush(stdout);
538 <        }
539 <        if (noaction)
513 <                return;
514 <        if (system(combuf)) {           /* run it */
532 >        if (vdef(MATERIAL))
533 >                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
534 >                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
535 >        else
536 >                sprintf(combuf, "oconv%s %s > %s", ocopts,
537 >                                vval(SCENE), vval(OCTREE));
538 >        
539 >        if (runcom(combuf)) {           /* run it */
540                  fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
541                                  progname, vval(OCTREE));
542                  unlink(vval(OCTREE));
# Line 543 | Line 568 | register char  *oo;
568   }
569  
570  
571 + checkambfile()                  /* check date on ambient file */
572 + {
573 +        long    afdate;
574 +
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 +
584   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] == '.')
553 <                        return(.5/atof(vval(EXPOSURE)));
554 <                badvalue(EXPOSURE);
592 >                return(.5/atof(vval(EXPOSURE)));
593          }
594          if (vlet(ZONE) == 'E')
595                  return(10.);
# Line 575 | Line 613 | register char  *op;
613          d *= 3./(siz[0]+siz[1]+siz[2]);
614          switch (vscale(DETAIL)) {
615          case LOW:
616 <                op = addarg(op, "-ps 16");
579 <                op = addarg(op, "-dp 16");
616 >                op = addarg(op, "-ps 16 -dp 16");
617                  sprintf(op, " -ar %d", (int)(4*d));
618                  op += strlen(op);
619                  break;
620          case MEDIUM:
621 <                op = addarg(op, "-ps 8");
585 <                op = addarg(op, "-dp 32");
621 >                op = addarg(op, "-ps 8 -dp 32");
622                  sprintf(op, " -ar %d", (int)(8*d));
623                  op += strlen(op);
624                  break;
625          case HIGH:
626 <                op = addarg(op, "-ps 4");
591 <                op = addarg(op, "-dp 64");
626 >                op = addarg(op, "-ps 4 -dp 64");
627                  sprintf(op, " -ar %d", (int)(16*d));
628                  op += strlen(op);
629                  break;
# Line 596 | Line 631 | register char  *op;
631          op = addarg(op, "-pt .16");
632          if (vbool(PENUMBRAS))
633                  op = addarg(op, "-ds .4");
634 <        op = addarg(op, "-dt .2");
635 <        op = addarg(op, "-dc .25");
636 <        op = addarg(op, "-dr 0");
602 <        op = addarg(op, "-sj 0");
603 <        op = addarg(op, "-st .7");
604 <        op = addarg(op, "-ab 0");
634 >        else
635 >                op = addarg(op, "-ds 0");
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 609 | Line 641 | register char  *op;
641                  overture = 0;
642          switch (vscale(VARIABILITY)) {
643          case LOW:
644 <                op = addarg(op, "-aa .4");
613 <                op = addarg(op, "-ad 32");
644 >                op = addarg(op, "-aa .4 -ad 64");
645                  break;
646          case MEDIUM:
647 <                op = addarg(op, "-aa .3");
617 <                op = addarg(op, "-ad 64");
647 >                op = addarg(op, "-aa .3 -ad 128");
648                  break;
649          case HIGH:
650 <                op = addarg(op, "-aa .25");
621 <                op = addarg(op, "-ad 128");
650 >                op = addarg(op, "-aa .25 -ad 256");
651                  break;
652          }
653          op = addarg(op, "-as 0");
654          d = ambval();
655          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
656          op += strlen(op);
657 <        op = addarg(op, "-lr 3");
629 <        op = addarg(op, "-lw .02");
657 >        op = addarg(op, "-lr 3 -lw .02");
658          if (vdef(RENDER))
659                  op = addarg(op, vval(RENDER));
660   }
# Line 665 | Line 693 | register char  *op;
693                  break;
694          }
695          op = addarg(op, "-pt .08");
696 <        if (vbool(PENUMBRAS)) {
697 <                op = addarg(op, "-ds .2");
698 <                op = addarg(op, "-dj .35");
671 <        } else
696 >        if (vbool(PENUMBRAS))
697 >                op = addarg(op, "-ds .2 -dj .35");
698 >        else
699                  op = addarg(op, "-ds .3");
700 <        op = addarg(op, "-dt .1");
701 <        op = addarg(op, "-dc .5");
702 <        op = addarg(op, "-dr 1");
703 <        op = addarg(op, "-sj .7");
704 <        op = addarg(op, "-st .15");
678 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
679 <        op += strlen(op);
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);
704 >        }
705          if (vdef(AMBFILE)) {
706                  sprintf(op, " -af %s", vval(AMBFILE));
707                  op += strlen(op);
# Line 684 | Line 709 | register char  *op;
709                  overture = 0;
710          switch (vscale(VARIABILITY)) {
711          case LOW:
712 <                op = addarg(op, "-aa .25");
688 <                op = addarg(op, "-ad 128");
689 <                op = addarg(op, "-as 0");
712 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
713                  break;
714          case MEDIUM:
715 <                op = addarg(op, "-aa .2");
693 <                op = addarg(op, "-ad 300");
694 <                op = addarg(op, "-as 64");
715 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
716                  break;
717          case HIGH:
718 <                op = addarg(op, "-aa .15");
698 <                op = addarg(op, "-ad 500");
699 <                op = addarg(op, "-as 128");
718 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
719                  break;
720          }
721          d = ambval();
722          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
723          op += strlen(op);
724 <        op = addarg(op, "-lr 6");
706 <        op = addarg(op, "-lw .002");
724 >        op = addarg(op, "-lr 6 -lw .002");
725          if (vdef(RENDER))
726                  op = addarg(op, vval(RENDER));
727   }
# Line 742 | Line 760 | register char  *op;
760                  break;
761          }
762          op = addarg(op, "-pt .04");
763 <        if (vbool(PENUMBRAS)) {
764 <                op = addarg(op, "-ds .1");
765 <                op = addarg(op, "-dj .7");
748 <        } else
763 >        if (vbool(PENUMBRAS))
764 >                op = addarg(op, "-ds .1 -dj .7");
765 >        else
766                  op = addarg(op, "-ds .2");
767 <        op = addarg(op, "-dt .05");
751 <        op = addarg(op, "-dc .75");
752 <        op = addarg(op, "-dr 3");
753 <        op = addarg(op, "-sj 1");
754 <        op = addarg(op, "-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 761 | Line 774 | register char  *op;
774                  overture = 0;
775          switch (vscale(VARIABILITY)) {
776          case LOW:
777 <                op = addarg(op, "-aa .15");
765 <                op = addarg(op, "-ad 200");
766 <                op = addarg(op, "-as 0");
777 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
778                  break;
779          case MEDIUM:
780 <                op = addarg(op, "-aa .125");
770 <                op = addarg(op, "-ad 512");
771 <                op = addarg(op, "-as 128");
780 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
781                  break;
782          case HIGH:
783 <                op = addarg(op, "-aa .08");
775 <                op = addarg(op, "-ad 850");
776 <                op = addarg(op, "-as 256");
783 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
784                  break;
785          }
786          d = ambval();
787          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
788          op += strlen(op);
789 <        op = addarg(op, "-lr 12");
783 <        op = addarg(op, "-lw .0005");
789 >        op = addarg(op, "-lr 12 -lw .0005");
790          if (vdef(RENDER))
791                  op = addarg(op, vval(RENDER));
792   }
# Line 790 | 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)
801 <                        syserr(vval(OPTFILE));
802 <                write(fd, "\n", 1);
803 <                close(fd);
804 <                ro[0] = ' ';
805 <                ro[1] = '^';
806 <                strcpy(ro+2, vval(OPTFILE));
814 >                sprintf(ro, " @%s", vval(OPTFILE));
815          }
816   #ifdef MSDOS
817          else if (n > 50) {
818 <                register char   *evp = bmalloc(n+6);
811 <                if (evp == NULL)
812 <                        syserr(progname);
813 <                strcpy(evp, "ROPT=");
814 <                strcat(evp, ro);
815 <                if (putenv(evp) != 0) {
816 <                        fprintf(stderr, "%s: out of environment space\n",
817 <                                        progname);
818 <                        exit(1);
819 <                }
818 >                setenv("ROPT", ro+1);
819                  strcpy(ro, " $ROPT");
820          }
821   #endif
# Line 831 | 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 953 | register char  *vs;
953                          break;
954                  }
955          } else {
956 <                while (*vs && !isspace(*vs))    /* else skip id */
957 <                        vs++;
956 >                while (!isspace(*vs))           /* else skip id */
957 >                        if (!*vs++)
958 >                                return(NULL);
959                  if (upax) {                     /* specify up vector */
960                          strcpy(cp, vup[upax+3]);
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 964 | 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 981 | 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 1006 | Line 1069 | char   *opts;
1069          if (rvdevice != NULL)
1070                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1071          strcat(combuf, vval(OCTREE));
1072 <        if (!silent) {                  /* echo it */
1010 <                printf("\t%s\n", combuf);
1011 <                fflush(stdout);
1012 <        }
1013 <        if (noaction)
1014 <                return;
1015 <        if (system(combuf)) {           /* run it */
1072 >        if (runcom(combuf)) {           /* run it */
1073                  fprintf(stderr, "%s: error running rview\n", progname);
1074                  exit(1);
1075          }
# Line 1027 | 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 1057 | Line 1115 | char   *opts;
1115                  else
1116                          badvalue(REPORT);
1117          }
1118 <                                        /* check date on ambient file */
1119 <        if (vdef(AMBFILE)) {
1062 <                long    afdate = fdate(vval(AMBFILE));
1063 <                if (afdate >= 0 & octreedate > afdate) {
1064 <                        if (!silent)
1065 < #ifdef MSDOS
1066 <                                printf("\tdel %s\n", vval(AMBFILE));
1067 < #else
1068 <                                printf("\trm %s\n", vval(AMBFILE));
1069 < #endif
1070 <                        if (!noaction)
1071 <                                unlink(vval(AMBFILE));
1072 <                }
1073 <        }
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 1078 | 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 1090 | Line 1136 | char   *opts;
1136                                  sprintf(combuf,
1137                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1138                                                  rep, vw, opts,
1139 <                                                vval(OCTREE), rawfile);
1140 <                                if (!silent) {
1095 <                                        printf("\t%s\n", combuf);
1096 <                                        fflush(stdout);
1097 <                                }
1098 <                                if (!noaction && system(combuf)) {
1139 >                                                vval(OCTREE), overfile);
1140 >                                if (runcom(combuf)) {
1141                                          fprintf(stderr,
1142 <                        "%s: error in overture for view %s\n\t%s removed\n",
1143 <                                                progname, vs, rawfile);
1102 <                                        unlink(rawfile);
1142 >                                        "%s: error in overture for view %s\n",
1143 >                                                progname, vs);
1144                                          exit(1);
1145                                  }
1146 + #ifdef NIX
1147 +                                rmfile(overfile);
1148 + #endif
1149                          }
1150                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1151                                          rep, vw, res, opts,
1152                                          vval(OCTREE), rawfile);
1153                  }
1154 <                if (!silent) {                  /* echo rpict command */
1111 <                        printf("\t%s\n", combuf);
1112 <                        fflush(stdout);
1113 <                }
1114 <                if (!noaction && system(combuf)) {      /* run rpict */
1154 >                if (runcom(combuf)) {           /* run rpict */
1155                          fprintf(stderr, "%s: error rendering view %s\n",
1156                                          progname, vs);
1157                          exit(1);
# Line 1123 | Line 1163 | char   *opts;
1163                  else
1164                          sprintf(combuf, "pfilt%s %s > %s", pfopts,
1165                                          rawfile, picfile);
1166 <                if (!silent) {                  /* echo pfilt command */
1127 <                        printf("\t%s\n", combuf);
1128 <                        fflush(stdout);
1129 <                }
1130 <                if (!noaction && system(combuf)) {      /* run pfilt */
1166 >                if (runcom(combuf)) {           /* run pfilt */
1167                          fprintf(stderr,
1168                          "%s: error filtering view %s\n\t%s removed\n",
1169                                          progname, vs, picfile);
# Line 1135 | Line 1171 | char   *opts;
1171                          exit(1);
1172                  }
1173                                                  /* remove raw file */
1174 <                if (!silent)
1174 >                rmfile(rawfile);
1175 >        }
1176 > }
1177 >
1178 >
1179 > runcom(cs)                      /* run command */
1180 > char    *cs;
1181 > {
1182 >        if (!silent)            /* echo it */
1183 >                printf("\t%s\n", cs);
1184 >        if (noaction)
1185 >                return(0);
1186 >        fflush(stdout);         /* flush output and pass to shell */
1187 >        return(system(cs));
1188 > }
1189 >
1190 >
1191 > rmfile(fn)                      /* remove a file */
1192 > char    *fn;
1193 > {
1194 >        if (!silent)
1195   #ifdef MSDOS
1196 <                        printf("\tdel %s\n", rawfile);
1196 >                printf("\tdel %s\n", fn);
1197   #else
1198 <                        printf("\trm %s\n", rawfile);
1198 >                printf("\trm -f %s\n", fn);
1199   #endif
1200 <                if (!noaction)
1201 <                        unlink(rawfile);
1200 >        if (noaction)
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