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.21 by greg, Tue Aug 24 22:14:21 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  
# Line 135 | Line 144 | char   *argv[];
144                  case 'o':
145                          rvdevice = argv[++i];
146                          break;
147 +                case 'V':
148 +                        sayview++;
149 +                        break;
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 >                                /* build octree */
175          oconv();
176 +                                /* check date on ambient file */
177 +        checkambfile();
178 +                                /* run simulation */
179          renderopts(ropts);
180          xferopts(ropts);
181          if (rvdevice != NULL)
# Line 195 | Line 210 | load(rfname)                   /* load Radiance simulation file */
210   char    *rfname;
211   {
212          FILE    *fp;
213 <        char    buf[256];
213 >        char    buf[512];
214          register char   *cp;
215  
216          if (rfname == NULL)
# Line 212 | Line 227 | char   *rfname;
227                          case '#':
228                                  *cp = '\0';
229                                  break;
230 +                        default:
231 +                                continue;
232                          }
233                          break;
234                  }
# Line 260 | Line 277 | register char  *ass;
277                  exit(1);
278          }
279                                          /* assign new value */
280 <        cp = vp->value; i = vp->nass;
281 <        while (i--)
282 <                while (*cp++)
283 <                        ;
284 <        i = cp - vp->value;
285 <        vp->value = realloc(vp->value, i+n+1);
280 >        if (i = vp->nass) {
281 >                cp = vp->value;
282 >                while (i--)
283 >                        while (*cp++)
284 >                                ;
285 >                i = cp - vp->value;
286 >                vp->value = realloc(vp->value, i+n+1);
287 >        } else
288 >                vp->value = malloc(n+1);
289          if (vp->value == NULL)
290                  syserr(progname);
291          strcpy(vp->value+i, ass);
# Line 294 | Line 314 | register int   n;
314   {
315          register char   *cp;
316  
317 <        if (vp == NULL || n < 0 || n >= vp->nass)
317 >        if (vp == NULL | n < 0 | n >= vp->nass)
318                  return(NULL);
319          cp = vp->value;
320          while (n--)
# Line 369 | Line 389 | register char  *fnames;
389          while (*fnames) {
390                  while (isspace(*fnames)) fnames++;
391                  cp = thisfile;
392 <                while (*fnames && !isspace(*fnames)) *cp++ = *fnames++;
392 >                while (*fnames && !isspace(*fnames))
393 >                        *cp++ = *fnames++;
394                  *cp = '\0';
395                  if ((thisdate = fdate(thisfile)) < 0)
396                          syserr(thisfile);
# Line 407 | Line 428 | checkfiles()                   /* check for existence and modified tim
428                                  vnam(OCTREE), vnam(SCENE));
429                  exit(1);
430          }
431 +        matdate = -1;
432 +        if (vdef(MATERIAL))
433 +                matdate = checklast(vval(MATERIAL));
434   }      
435  
436  
# Line 488 | Line 512 | printvals()                    /* print variable values */
512          register int    i, j;
513  
514          for (i = 0; i < NVARS; i++)
515 <                for (j = 0; j < vv[i].nass; j++)
516 <                        printf("%s= %s\n", vv[i].name, nvalue(vv+i, j));
515 >                for (j = 0; j < vdef(i); j++)
516 >                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
517          fflush(stdout);
518   }
519  
# Line 502 | Line 526 | oconv()                                /* run oconv if necessary */
526                  return;
527                                          /* build command */
528          oconvopts(ocopts);
529 <        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
530 <                        vdef(MATERIAL) ? vval(MATERIAL) : "",
531 <                        vval(SCENE), vval(OCTREE));
532 <        if (!silent) {                  /* echo it */
533 <                printf("\t%s\n", combuf);
534 <                fflush(stdout);
535 <        }
536 <        if (noaction)
513 <                return;
514 <        if (system(combuf)) {           /* run it */
529 >        if (vdef(MATERIAL))
530 >                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
531 >                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
532 >        else
533 >                sprintf(combuf, "oconv%s %s > %s", ocopts,
534 >                                vval(SCENE), vval(OCTREE));
535 >        
536 >        if (runcom(combuf)) {           /* run it */
537                  fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
538                                  progname, vval(OCTREE));
539                  unlink(vval(OCTREE));
# Line 543 | Line 565 | register char  *oo;
565   }
566  
567  
568 + checkambfile()                  /* check date on ambient file */
569 + {
570 +        long    afdate;
571 +
572 +        if (!vdef(AMBFILE))
573 +                return;
574 +        if ((afdate = fdate(vval(AMBFILE))) < 0)
575 +                return;
576 +        if (octreedate > afdate | matdate > afdate)
577 +                rmfile(vval(AMBFILE));
578 + }
579 +
580 +
581   double
582   ambval()                                /* compute ambient value */
583   {
584          if (vdef(EXPOSURE)) {
585 +                if (!isflt(vval(EXPOSURE)))
586 +                        badvalue(EXPOSURE);
587                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
588                          return(.5/pow(2.,atof(vval(EXPOSURE))));
589 <                if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.')
553 <                        return(.5/atof(vval(EXPOSURE)));
554 <                badvalue(EXPOSURE);
589 >                return(.5/atof(vval(EXPOSURE)));
590          }
591          if (vlet(ZONE) == 'E')
592                  return(10.);
# Line 575 | Line 610 | register char  *op;
610          d *= 3./(siz[0]+siz[1]+siz[2]);
611          switch (vscale(DETAIL)) {
612          case LOW:
613 <                op = addarg(op, "-ps 16");
579 <                op = addarg(op, "-dp 16");
613 >                op = addarg(op, "-ps 16 -dp 16");
614                  sprintf(op, " -ar %d", (int)(4*d));
615                  op += strlen(op);
616                  break;
617          case MEDIUM:
618 <                op = addarg(op, "-ps 8");
585 <                op = addarg(op, "-dp 32");
618 >                op = addarg(op, "-ps 8 -dp 32");
619                  sprintf(op, " -ar %d", (int)(8*d));
620                  op += strlen(op);
621                  break;
622          case HIGH:
623 <                op = addarg(op, "-ps 4");
591 <                op = addarg(op, "-dp 64");
623 >                op = addarg(op, "-ps 4 -dp 64");
624                  sprintf(op, " -ar %d", (int)(16*d));
625                  op += strlen(op);
626                  break;
# Line 596 | Line 628 | register char  *op;
628          op = addarg(op, "-pt .16");
629          if (vbool(PENUMBRAS))
630                  op = addarg(op, "-ds .4");
631 <        op = addarg(op, "-dt .2");
632 <        op = addarg(op, "-dc .25");
633 <        op = addarg(op, "-dr 0");
602 <        op = addarg(op, "-sj 0");
603 <        op = addarg(op, "-st .7");
604 <        op = addarg(op, "-ab 0");
631 >        else
632 >                op = addarg(op, "-ds 0");
633 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
634          if (vdef(AMBFILE)) {
635                  sprintf(op, " -af %s", vval(AMBFILE));
636                  op += strlen(op);
# Line 609 | Line 638 | register char  *op;
638                  overture = 0;
639          switch (vscale(VARIABILITY)) {
640          case LOW:
641 <                op = addarg(op, "-aa .4");
613 <                op = addarg(op, "-ad 32");
641 >                op = addarg(op, "-aa .4 -ad 64");
642                  break;
643          case MEDIUM:
644 <                op = addarg(op, "-aa .3");
617 <                op = addarg(op, "-ad 64");
644 >                op = addarg(op, "-aa .3 -ad 128");
645                  break;
646          case HIGH:
647 <                op = addarg(op, "-aa .25");
621 <                op = addarg(op, "-ad 128");
647 >                op = addarg(op, "-aa .25 -ad 256");
648                  break;
649          }
650          op = addarg(op, "-as 0");
651          d = ambval();
652          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
653          op += strlen(op);
654 <        op = addarg(op, "-lr 3");
629 <        op = addarg(op, "-lw .02");
654 >        op = addarg(op, "-lr 3 -lw .02");
655          if (vdef(RENDER))
656                  op = addarg(op, vval(RENDER));
657   }
# Line 665 | Line 690 | register char  *op;
690                  break;
691          }
692          op = addarg(op, "-pt .08");
693 <        if (vbool(PENUMBRAS)) {
694 <                op = addarg(op, "-ds .2");
695 <                op = addarg(op, "-dj .35");
671 <        } else
693 >        if (vbool(PENUMBRAS))
694 >                op = addarg(op, "-ds .2 -dj .35");
695 >        else
696                  op = addarg(op, "-ds .3");
697 <        op = addarg(op, "-dt .1");
698 <        op = addarg(op, "-dc .5");
699 <        op = addarg(op, "-dr 1");
700 <        op = addarg(op, "-sj .7");
701 <        op = addarg(op, "-st .15");
678 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
679 <        op += strlen(op);
697 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
698 >        if (overture = vint(INDIRECT)) {
699 >                sprintf(op, " -ab %d", overture);
700 >                op += strlen(op);
701 >        }
702          if (vdef(AMBFILE)) {
703                  sprintf(op, " -af %s", vval(AMBFILE));
704                  op += strlen(op);
# Line 684 | Line 706 | register char  *op;
706                  overture = 0;
707          switch (vscale(VARIABILITY)) {
708          case LOW:
709 <                op = addarg(op, "-aa .25");
688 <                op = addarg(op, "-ad 128");
689 <                op = addarg(op, "-as 0");
709 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
710                  break;
711          case MEDIUM:
712 <                op = addarg(op, "-aa .2");
693 <                op = addarg(op, "-ad 300");
694 <                op = addarg(op, "-as 64");
712 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
713                  break;
714          case HIGH:
715 <                op = addarg(op, "-aa .15");
698 <                op = addarg(op, "-ad 500");
699 <                op = addarg(op, "-as 128");
715 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
716                  break;
717          }
718          d = ambval();
719          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
720          op += strlen(op);
721 <        op = addarg(op, "-lr 6");
706 <        op = addarg(op, "-lw .002");
721 >        op = addarg(op, "-lr 6 -lw .002");
722          if (vdef(RENDER))
723                  op = addarg(op, vval(RENDER));
724   }
# Line 742 | Line 757 | register char  *op;
757                  break;
758          }
759          op = addarg(op, "-pt .04");
760 <        if (vbool(PENUMBRAS)) {
761 <                op = addarg(op, "-ds .1");
762 <                op = addarg(op, "-dj .7");
748 <        } else
760 >        if (vbool(PENUMBRAS))
761 >                op = addarg(op, "-ds .1 -dj .7");
762 >        else
763                  op = addarg(op, "-ds .2");
764 <        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");
764 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
765          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
766          op += strlen(op);
767          if (vdef(AMBFILE)) {
# Line 761 | Line 771 | register char  *op;
771                  overture = 0;
772          switch (vscale(VARIABILITY)) {
773          case LOW:
774 <                op = addarg(op, "-aa .15");
765 <                op = addarg(op, "-ad 200");
766 <                op = addarg(op, "-as 0");
774 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
775                  break;
776          case MEDIUM:
777 <                op = addarg(op, "-aa .125");
770 <                op = addarg(op, "-ad 512");
771 <                op = addarg(op, "-as 128");
777 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
778                  break;
779          case HIGH:
780 <                op = addarg(op, "-aa .08");
775 <                op = addarg(op, "-ad 850");
776 <                op = addarg(op, "-as 256");
780 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
781                  break;
782          }
783          d = ambval();
784          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
785          op += strlen(op);
786 <        op = addarg(op, "-lr 12");
783 <        op = addarg(op, "-lw .0005");
786 >        op = addarg(op, "-lr 12 -lw .0005");
787          if (vdef(RENDER))
788                  op = addarg(op, vval(RENDER));
789   }
# Line 790 | Line 793 | xferopts(ro)                           /* transfer options if indicated */
793   char    *ro;
794   {
795          int     fd, n;
796 +        register char   *cp;
797          
798          n = strlen(ro);
799          if (n < 2)
800                  return;
801          if (vdef(OPTFILE)) {
802 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
802 >                for (cp = ro; cp[1]; cp++)
803 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
804 >                                *cp = '\n';
805 >                        else
806 >                                *cp = cp[1];
807 >                *cp = '\n';
808 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
809 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
810                          syserr(vval(OPTFILE));
811 <                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));
811 >                sprintf(ro, " @%s", vval(OPTFILE));
812          }
813   #ifdef MSDOS
814          else if (n > 50) {
815 <                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 <                }
815 >                setenv("ROPT", ro+1);
816                  strcpy(ro, " $ROPT");
817          }
818   #endif
# Line 831 | Line 827 | register char  *po;
827                  po = addarg(po, "-1 -e");
828                  po = addarg(po, vval(EXPOSURE));
829          }
830 <        if (vscale(QUALITY) == HIGH)
831 <                po = addarg(po, "-r .65");
830 >        switch (vscale(QUALITY)) {
831 >        case MEDIUM:
832 >                po = addarg(po, "-r 1");
833 >                break;
834 >        case HIGH:
835 >                po = addarg(po, "-m .25");
836 >                break;
837 >        }
838          if (vdef(PFILT))
839                  po = addarg(po, vval(PFILT));
840   }
# Line 948 | Line 950 | register char  *vs;
950                          break;
951                  }
952          } else {
953 <                while (*vs && !isspace(*vs))    /* else skip id */
954 <                        vs++;
953 >                while (!isspace(*vs))           /* else skip id */
954 >                        if (!*vs++)
955 >                                return(NULL);
956                  if (upax) {                     /* specify up vector */
957                          strcpy(cp, vup[upax+3]);
958                          cp += strlen(cp);
959                  }
960          }
961 <                                        /* append any additional options */
962 <        strcpy(cp, vs);
961 >        strcpy(cp, vs);                 /* append any additional options */
962 > #ifdef MSDOS
963 >        if (strlen(viewopts) > 40) {
964 >                setenv("VIEW", viewopts);
965 >                return("$VIEW");
966 >        }
967 > #endif
968          return(viewopts);
969   }
970  
# Line 964 | Line 972 | register char  *vs;
972   char *
973   getview(n, vn)                          /* get view n, or NULL if none */
974   int     n;
975 < char    *vn;
975 > char    *vn;            /* returned view name */
976   {
977          register char   *mv;
978  
979 <        if (viewselect != NULL) {
979 >        if (viewselect != NULL) {               /* command-line selected */
980                  if (n)                          /* only do one */
981                          return(NULL);
982                  if (viewselect[0] == '-') {     /* already specified */
# Line 981 | Line 989 | char   *vn;
989                                  ;
990                          *vn = '\0';
991                  }
992 +                                                /* view number? */
993 +                if (isint(viewselect))
994 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
995                                                  /* check list */
996                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
997                          if (matchword(viewselect, mv))
998                                  return(specview(mv));
999                  return(specview(viewselect));   /* standard view? */
1000          }
1001 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
1002 <                if (*mv != '-')
1003 <                        while (*mv && !isspace(*mv))
1004 <                                *vn++ = *mv++;
1001 >        mv = nvalue(vv+VIEW, n);                /* use view n */
1002 >        if (vn != NULL & mv != NULL) {
1003 >                register char   *mv2 = mv;
1004 >                if (*mv2 != '-')
1005 >                        while (*mv2 && !isspace(*mv2))
1006 >                                *vn++ = *mv2++;
1007                  *vn = '\0';
1008          }
1009 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
1009 >        return(specview(mv));
1010   }
1011  
1012  
1013 + printview(vopts)                        /* print out selected view */
1014 + register char   *vopts;
1015 + {
1016 +        extern char     *atos();
1017 +        char    buf[256];
1018 +        FILE    *fp;
1019 +        register char   *cp;
1020 +
1021 +        if (vopts == NULL)
1022 +                return(-1);
1023 +        fputs("VIEW=", stdout);
1024 +        do {
1025 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1026 +                        vopts = sskip(vopts);
1027 +                        if (!*atos(buf, sizeof(buf), vopts))
1028 +                                return(-1);
1029 +                        if ((fp = fopen(buf, "r")) == NULL)
1030 +                                return(-1);
1031 +                        for (buf[sizeof(buf)-2] = '\n';
1032 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1033 +                                                buf[0] != '\n';
1034 +                                        buf[sizeof(buf)-2] = '\n') {
1035 +                                if (buf[sizeof(buf)-2] != '\n') {
1036 +                                        ungetc(buf[sizeof(buf)-2], fp);
1037 +                                        buf[sizeof(buf)-2] = '\0';
1038 +                                }
1039 +                                if (matchword(buf, "VIEW=") ||
1040 +                                                matchword(buf, "rview")) {
1041 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1042 +                                                putchar(*cp);
1043 +                                }
1044 +                        }
1045 +                        fclose(fp);
1046 +                        vopts = sskip(vopts);
1047 +                } else {
1048 +                        while (isspace(*vopts))
1049 +                                vopts++;
1050 +                        putchar(' ');
1051 +                        while (*vopts && !isspace(*vopts))
1052 +                                putchar(*vopts++);
1053 +                }
1054 +        } while (*vopts++);
1055 +        putchar('\n');
1056 +        return(0);
1057 + }
1058 +
1059 +
1060   rview(opts)                             /* run rview with first view */
1061   char    *opts;
1062   {
1063 +        char    *vw;
1064          char    combuf[512];
1065                                          /* build command */
1066 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1066 >        if ((vw = getview(0, NULL)) == NULL)
1067 >                return;
1068 >        if (sayview)
1069 >                printview(vw);
1070 >        sprintf(combuf, "rview %s%s ", vw, opts);
1071          if (rvdevice != NULL)
1072                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1073          strcat(combuf, vval(OCTREE));
1074 <        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 */
1074 >        if (runcom(combuf)) {           /* run it */
1075                  fprintf(stderr, "%s: error running rview\n", progname);
1076                  exit(1);
1077          }
# Line 1027 | Line 1086 | char   *opts;
1086          char    pfopts[128];
1087          char    vs[32], *vw;
1088          int     vn, mult;
1089 +        long    lastdate;
1090                                          /* get pfilt options */
1091          pfiltopts(pfopts);
1092                                          /* get resolution, reporting */
# Line 1057 | Line 1117 | char   *opts;
1117                  else
1118                          badvalue(REPORT);
1119          }
1120 <                                        /* check date on ambient file */
1121 <        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 <        }
1120 >                                        /* get update time */
1121 >        lastdate = octreedate > matdate ? octreedate : matdate;
1122                                          /* do each view */
1123          vn = 0;
1124          while ((vw = getview(vn++, vs)) != NULL) {
1125 +                if (sayview)
1126 +                        printview(vw);
1127                  if (!vs[0])
1128                          sprintf(vs, "%d", vn);
1129                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1130                                                  /* check date on picture */
1131 <                if (fdate(picfile) > octreedate)
1131 >                if (fdate(picfile) >= lastdate)
1132                          continue;
1133                                                  /* build rpict command */
1134                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1135 <                if (fdate(rawfile) > octreedate)        /* recover */
1135 >                if (fdate(rawfile) >= octreedate)       /* recover */
1136                          sprintf(combuf, "rpict%s%s -ro %s %s",
1137                                          rep, opts, rawfile, vval(OCTREE));
1138                  else {
# Line 1090 | Line 1140 | char   *opts;
1140                                  sprintf(combuf,
1141                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1142                                                  rep, vw, opts,
1143 <                                                vval(OCTREE), rawfile);
1144 <                                if (!silent) {
1095 <                                        printf("\t%s\n", combuf);
1096 <                                        fflush(stdout);
1097 <                                }
1098 <                                if (!noaction && system(combuf)) {
1143 >                                                vval(OCTREE), overfile);
1144 >                                if (runcom(combuf)) {
1145                                          fprintf(stderr,
1146 <                        "%s: error in overture for view %s\n\t%s removed\n",
1147 <                                                progname, vs, rawfile);
1102 <                                        unlink(rawfile);
1146 >                                        "%s: error in overture for view %s\n",
1147 >                                                progname, vs);
1148                                          exit(1);
1149                                  }
1150 + #ifdef NIX
1151 +                                rmfile(overfile);
1152 + #endif
1153                          }
1154                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1155                                          rep, vw, res, opts,
1156                                          vval(OCTREE), rawfile);
1157                  }
1158 <                if (!silent) {                  /* echo rpict command */
1111 <                        printf("\t%s\n", combuf);
1112 <                        fflush(stdout);
1113 <                }
1114 <                if (!noaction && system(combuf)) {      /* run rpict */
1158 >                if (runcom(combuf)) {           /* run rpict */
1159                          fprintf(stderr, "%s: error rendering view %s\n",
1160                                          progname, vs);
1161                          exit(1);
# Line 1123 | Line 1167 | char   *opts;
1167                  else
1168                          sprintf(combuf, "pfilt%s %s > %s", pfopts,
1169                                          rawfile, picfile);
1170 <                if (!silent) {                  /* echo pfilt command */
1127 <                        printf("\t%s\n", combuf);
1128 <                        fflush(stdout);
1129 <                }
1130 <                if (!noaction && system(combuf)) {      /* run pfilt */
1170 >                if (runcom(combuf)) {           /* run pfilt */
1171                          fprintf(stderr,
1172                          "%s: error filtering view %s\n\t%s removed\n",
1173                                          progname, vs, picfile);
# Line 1135 | Line 1175 | char   *opts;
1175                          exit(1);
1176                  }
1177                                                  /* remove raw file */
1178 <                if (!silent)
1178 >                rmfile(rawfile);
1179 >        }
1180 > }
1181 >
1182 >
1183 > runcom(cs)                      /* run command */
1184 > char    *cs;
1185 > {
1186 >        if (!silent)            /* echo it */
1187 >                printf("\t%s\n", cs);
1188 >        if (noaction)
1189 >                return(0);
1190 >        fflush(stdout);         /* flush output and pass to shell */
1191 >        return(system(cs));
1192 > }
1193 >
1194 >
1195 > rmfile(fn)                      /* remove a file */
1196 > char    *fn;
1197 > {
1198 >        if (!silent)
1199   #ifdef MSDOS
1200 <                        printf("\tdel %s\n", rawfile);
1200 >                printf("\tdel %s\n", fn);
1201   #else
1202 <                        printf("\trm %s\n", rawfile);
1202 >                printf("\trm -f %s\n", fn);
1203   #endif
1204 <                if (!noaction)
1205 <                        unlink(rawfile);
1204 >        if (noaction)
1205 >                return(0);
1206 >        return(unlink(fn));
1207 > }
1208 >
1209 >
1210 > #ifdef MSDOS
1211 > setenv(vname, value)            /* set an environment variable */
1212 > char    *vname, *value;
1213 > {
1214 >        register char   *evp;
1215 >
1216 >        evp = bmalloc(strlen(vname)+strlen(value)+2);
1217 >        if (evp == NULL)
1218 >                syserr(progname);
1219 >        sprintf(evp, "%s=%s", vname, value);
1220 >        if (putenv(evp) != 0) {
1221 >                fprintf(stderr, "%s: out of environment space\n", progname);
1222 >                exit(1);
1223          }
1224 +        if (!silent)
1225 +                printf("set %s\n", evp);
1226   }
1227 + #endif
1228  
1229  
1230   badvalue(vc)                    /* report bad variable value and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines