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.6 by greg, Tue Mar 30 13:16:26 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 195 | Line 202 | load(rfname)                   /* load Radiance simulation file */
202   char    *rfname;
203   {
204          FILE    *fp;
205 <        char    buf[256];
205 >        char    buf[512];
206          register char   *cp;
207  
208          if (rfname == NULL)
# Line 212 | Line 219 | char   *rfname;
219                          case '#':
220                                  *cp = '\0';
221                                  break;
222 +                        default:
223 +                                continue;
224                          }
225                          break;
226                  }
# Line 260 | Line 269 | register char  *ass;
269                  exit(1);
270          }
271                                          /* assign new value */
272 <        cp = vp->value; i = vp->nass;
273 <        while (i--)
274 <                while (*cp++)
275 <                        ;
276 <        i = cp - vp->value;
277 <        vp->value = realloc(vp->value, i+n+1);
272 >        if (i = vp->nass) {
273 >                cp = vp->value;
274 >                while (i--)
275 >                        while (*cp++)
276 >                                ;
277 >                i = cp - vp->value;
278 >                vp->value = realloc(vp->value, i+n+1);
279 >        } else
280 >                vp->value = malloc(n+1);
281          if (vp->value == NULL)
282                  syserr(progname);
283          strcpy(vp->value+i, ass);
# Line 369 | Line 381 | register char  *fnames;
381          while (*fnames) {
382                  while (isspace(*fnames)) fnames++;
383                  cp = thisfile;
384 <                while (*fnames && !isspace(*fnames)) *cp++ = *fnames++;
384 >                while (*fnames && !isspace(*fnames))
385 >                        *cp++ = *fnames++;
386                  *cp = '\0';
387                  if ((thisdate = fdate(thisfile)) < 0)
388                          syserr(thisfile);
# Line 488 | Line 501 | printvals()                    /* print variable values */
501          register int    i, j;
502  
503          for (i = 0; i < NVARS; i++)
504 <                for (j = 0; j < vv[i].nass; j++)
505 <                        printf("%s= %s\n", vv[i].name, nvalue(vv+i, j));
504 >                for (j = 0; j < vdef(i); j++)
505 >                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
506          fflush(stdout);
507   }
508  
# Line 502 | Line 515 | oconv()                                /* run oconv if necessary */
515                  return;
516                                          /* build command */
517          oconvopts(ocopts);
518 <        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
519 <                        vdef(MATERIAL) ? vval(MATERIAL) : "",
520 <                        vval(SCENE), vval(OCTREE));
521 <        if (!silent) {                  /* echo it */
522 <                printf("\t%s\n", combuf);
523 <                fflush(stdout);
524 <        }
525 <        if (noaction)
513 <                return;
514 <        if (system(combuf)) {           /* run it */
518 >        if (vdef(MATERIAL))
519 >                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
520 >                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
521 >        else
522 >                sprintf(combuf, "oconv%s %s > %s", ocopts,
523 >                                vval(SCENE), vval(OCTREE));
524 >        
525 >        if (runcom(combuf)) {           /* run it */
526                  fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
527                                  progname, vval(OCTREE));
528                  unlink(vval(OCTREE));
# Line 575 | Line 586 | register char  *op;
586          d *= 3./(siz[0]+siz[1]+siz[2]);
587          switch (vscale(DETAIL)) {
588          case LOW:
589 <                op = addarg(op, "-ps 16");
579 <                op = addarg(op, "-dp 16");
589 >                op = addarg(op, "-ps 16 -dp 16");
590                  sprintf(op, " -ar %d", (int)(4*d));
591                  op += strlen(op);
592                  break;
593          case MEDIUM:
594 <                op = addarg(op, "-ps 8");
585 <                op = addarg(op, "-dp 32");
594 >                op = addarg(op, "-ps 8 -dp 32");
595                  sprintf(op, " -ar %d", (int)(8*d));
596                  op += strlen(op);
597                  break;
598          case HIGH:
599 <                op = addarg(op, "-ps 4");
591 <                op = addarg(op, "-dp 64");
599 >                op = addarg(op, "-ps 4 -dp 64");
600                  sprintf(op, " -ar %d", (int)(16*d));
601                  op += strlen(op);
602                  break;
# Line 596 | Line 604 | register char  *op;
604          op = addarg(op, "-pt .16");
605          if (vbool(PENUMBRAS))
606                  op = addarg(op, "-ds .4");
607 <        op = addarg(op, "-dt .2");
608 <        op = addarg(op, "-dc .25");
609 <        op = addarg(op, "-dr 0");
602 <        op = addarg(op, "-sj 0");
603 <        op = addarg(op, "-st .7");
604 <        op = addarg(op, "-ab 0");
607 >        else
608 >                op = addarg(op, "-ds 0");
609 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
610          if (vdef(AMBFILE)) {
611                  sprintf(op, " -af %s", vval(AMBFILE));
612                  op += strlen(op);
# Line 609 | Line 614 | register char  *op;
614                  overture = 0;
615          switch (vscale(VARIABILITY)) {
616          case LOW:
617 <                op = addarg(op, "-aa .4");
613 <                op = addarg(op, "-ad 32");
617 >                op = addarg(op, "-aa .4 -ad 32");
618                  break;
619          case MEDIUM:
620 <                op = addarg(op, "-aa .3");
617 <                op = addarg(op, "-ad 64");
620 >                op = addarg(op, "-aa .3 -ad 64");
621                  break;
622          case HIGH:
623 <                op = addarg(op, "-aa .25");
621 <                op = addarg(op, "-ad 128");
623 >                op = addarg(op, "-aa .25 -ad 128");
624                  break;
625          }
626          op = addarg(op, "-as 0");
627          d = ambval();
628          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
629          op += strlen(op);
630 <        op = addarg(op, "-lr 3");
629 <        op = addarg(op, "-lw .02");
630 >        op = addarg(op, "-lr 3 -lw .02");
631          if (vdef(RENDER))
632                  op = addarg(op, vval(RENDER));
633   }
# Line 665 | Line 666 | register char  *op;
666                  break;
667          }
668          op = addarg(op, "-pt .08");
669 <        if (vbool(PENUMBRAS)) {
670 <                op = addarg(op, "-ds .2");
671 <                op = addarg(op, "-dj .35");
671 <        } else
669 >        if (vbool(PENUMBRAS))
670 >                op = addarg(op, "-ds .2 -dj .35");
671 >        else
672                  op = addarg(op, "-ds .3");
673 <        op = addarg(op, "-dt .1");
674 <        op = addarg(op, "-dc .5");
675 <        op = addarg(op, "-dr 1");
676 <        op = addarg(op, "-sj .7");
677 <        op = addarg(op, "-st .15");
678 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
679 <        op += strlen(op);
673 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
674 >        if (overture = vint(INDIRECT)) {
675 >                sprintf(op, " -ab %d", overture);
676 >                op += strlen(op);
677 >        }
678          if (vdef(AMBFILE)) {
679                  sprintf(op, " -af %s", vval(AMBFILE));
680                  op += strlen(op);
# Line 684 | Line 682 | register char  *op;
682                  overture = 0;
683          switch (vscale(VARIABILITY)) {
684          case LOW:
685 <                op = addarg(op, "-aa .25");
688 <                op = addarg(op, "-ad 128");
689 <                op = addarg(op, "-as 0");
685 >                op = addarg(op, "-aa .25 -ad 128 -as 0");
686                  break;
687          case MEDIUM:
688 <                op = addarg(op, "-aa .2");
693 <                op = addarg(op, "-ad 300");
694 <                op = addarg(op, "-as 64");
688 >                op = addarg(op, "-aa .2 -ad 300 -as 64");
689                  break;
690          case HIGH:
691 <                op = addarg(op, "-aa .15");
698 <                op = addarg(op, "-ad 500");
699 <                op = addarg(op, "-as 128");
691 >                op = addarg(op, "-aa .15 -ad 500 -as 128");
692                  break;
693          }
694          d = ambval();
695          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
696          op += strlen(op);
697 <        op = addarg(op, "-lr 6");
706 <        op = addarg(op, "-lw .002");
697 >        op = addarg(op, "-lr 6 -lw .002");
698          if (vdef(RENDER))
699                  op = addarg(op, vval(RENDER));
700   }
# Line 742 | Line 733 | register char  *op;
733                  break;
734          }
735          op = addarg(op, "-pt .04");
736 <        if (vbool(PENUMBRAS)) {
737 <                op = addarg(op, "-ds .1");
738 <                op = addarg(op, "-dj .7");
748 <        } else
736 >        if (vbool(PENUMBRAS))
737 >                op = addarg(op, "-ds .1 -dj .7");
738 >        else
739                  op = addarg(op, "-ds .2");
740 <        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");
740 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
741          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
742          op += strlen(op);
743          if (vdef(AMBFILE)) {
# Line 761 | Line 747 | register char  *op;
747                  overture = 0;
748          switch (vscale(VARIABILITY)) {
749          case LOW:
750 <                op = addarg(op, "-aa .15");
765 <                op = addarg(op, "-ad 200");
766 <                op = addarg(op, "-as 0");
750 >                op = addarg(op, "-aa .15 -ad 200 -as 0");
751                  break;
752          case MEDIUM:
753 <                op = addarg(op, "-aa .125");
770 <                op = addarg(op, "-ad 512");
771 <                op = addarg(op, "-as 128");
753 >                op = addarg(op, "-aa .125 -ad 512 -as 128");
754                  break;
755          case HIGH:
756 <                op = addarg(op, "-aa .08");
775 <                op = addarg(op, "-ad 850");
776 <                op = addarg(op, "-as 256");
756 >                op = addarg(op, "-aa .08 -ad 850 -as 256");
757                  break;
758          }
759          d = ambval();
760          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
761          op += strlen(op);
762 <        op = addarg(op, "-lr 12");
783 <        op = addarg(op, "-lw .0005");
762 >        op = addarg(op, "-lr 12 -lw .0005");
763          if (vdef(RENDER))
764                  op = addarg(op, vval(RENDER));
765   }
# Line 801 | Line 780 | char   *ro;
780                          syserr(vval(OPTFILE));
781                  write(fd, "\n", 1);
782                  close(fd);
783 <                ro[0] = ' ';
805 <                ro[1] = '^';
806 <                strcpy(ro+2, vval(OPTFILE));
783 >                sprintf(ro, " \"^%s\"", vval(OPTFILE));
784          }
785   #ifdef MSDOS
786          else if (n > 50) {
# Line 948 | Line 925 | register char  *vs;
925                          break;
926                  }
927          } else {
928 <                while (*vs && !isspace(*vs))    /* else skip id */
929 <                        vs++;
928 >                while (!isspace(*vs))           /* else skip id */
929 >                        if (!*vs++)
930 >                                return(NULL);
931                  if (upax) {                     /* specify up vector */
932                          strcpy(cp, vup[upax+3]);
933                          cp += strlen(cp);
# Line 1006 | Line 984 | char   *opts;
984          if (rvdevice != NULL)
985                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
986          strcat(combuf, vval(OCTREE));
987 <        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 */
987 >        if (runcom(combuf)) {           /* run it */
988                  fprintf(stderr, "%s: error running rview\n", progname);
989                  exit(1);
990          }
# Line 1060 | Line 1032 | char   *opts;
1032                                          /* check date on ambient file */
1033          if (vdef(AMBFILE)) {
1034                  long    afdate = fdate(vval(AMBFILE));
1035 <                if (afdate >= 0 & octreedate > afdate) {
1036 <                        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 <                }
1035 >                if (afdate >= 0 & octreedate > afdate)
1036 >                        rmfile(vval(AMBFILE));
1037          }
1038                                          /* do each view */
1039          vn = 0;
# Line 1090 | Line 1054 | char   *opts;
1054                                  sprintf(combuf,
1055                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1056                                                  rep, vw, opts,
1057 <                                                vval(OCTREE), rawfile);
1058 <                                if (!silent) {
1095 <                                        printf("\t%s\n", combuf);
1096 <                                        fflush(stdout);
1097 <                                }
1098 <                                if (!noaction && system(combuf)) {
1057 >                                                vval(OCTREE), overfile);
1058 >                                if (runcom(combuf)) {
1059                                          fprintf(stderr,
1060 <                        "%s: error in overture for view %s\n\t%s removed\n",
1061 <                                                progname, vs, rawfile);
1102 <                                        unlink(rawfile);
1060 >                                        "%s: error in overture for view %s\n",
1061 >                                                progname, vs);
1062                                          exit(1);
1063                                  }
1064 + #ifdef NIX
1065 +                                rmfile(overfile);
1066 + #endif
1067                          }
1068                          sprintf(combuf, "rpict%s %s %s%s %s > %s",
1069                                          rep, vw, res, opts,
1070                                          vval(OCTREE), rawfile);
1071                  }
1072 <                if (!silent) {                  /* echo rpict command */
1111 <                        printf("\t%s\n", combuf);
1112 <                        fflush(stdout);
1113 <                }
1114 <                if (!noaction && system(combuf)) {      /* run rpict */
1072 >                if (runcom(combuf)) {           /* run rpict */
1073                          fprintf(stderr, "%s: error rendering view %s\n",
1074                                          progname, vs);
1075                          exit(1);
# Line 1123 | Line 1081 | char   *opts;
1081                  else
1082                          sprintf(combuf, "pfilt%s %s > %s", pfopts,
1083                                          rawfile, picfile);
1084 <                if (!silent) {                  /* echo pfilt command */
1127 <                        printf("\t%s\n", combuf);
1128 <                        fflush(stdout);
1129 <                }
1130 <                if (!noaction && system(combuf)) {      /* run pfilt */
1084 >                if (runcom(combuf)) {           /* run pfilt */
1085                          fprintf(stderr,
1086                          "%s: error filtering view %s\n\t%s removed\n",
1087                                          progname, vs, picfile);
# Line 1135 | Line 1089 | char   *opts;
1089                          exit(1);
1090                  }
1091                                                  /* remove raw file */
1092 <                if (!silent)
1092 >                rmfile(rawfile);
1093 >        }
1094 > }
1095 >
1096 >
1097 > runcom(cs)                      /* run command */
1098 > char    *cs;
1099 > {
1100 >        if (!silent)            /* echo it */
1101 >                printf("\t%s\n", cs);
1102 >        if (noaction)
1103 >                return(0);
1104 >        fflush(stdout);         /* flush output and pass to shell */
1105 >        return(system(cs));
1106 > }
1107 >
1108 >
1109 > rmfile(fn)                      /* remove a file */
1110 > char    *fn;
1111 > {
1112 >        if (!silent)
1113   #ifdef MSDOS
1114 <                        printf("\tdel %s\n", rawfile);
1114 >                printf("\tdel %s\n", fn);
1115   #else
1116 <                        printf("\trm %s\n", rawfile);
1116 >                printf("\trm -f %s\n", fn);
1117   #endif
1118 <                if (!noaction)
1119 <                        unlink(rawfile);
1120 <        }
1118 >        if (noaction)
1119 >                return(0);
1120 >        return(unlink(fn));
1121   }
1122  
1123  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines