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.4 by greg, Fri Mar 12 13:37:03 1993 UTC

# Line 195 | Line 195 | load(rfname)                   /* load Radiance simulation file */
195   char    *rfname;
196   {
197          FILE    *fp;
198 <        char    buf[256];
198 >        char    buf[512];
199          register char   *cp;
200  
201          if (rfname == NULL)
# Line 212 | Line 212 | char   *rfname;
212                          case '#':
213                                  *cp = '\0';
214                                  break;
215 +                        default:
216 +                                continue;
217                          }
218                          break;
219                  }
# Line 260 | Line 262 | register char  *ass;
262                  exit(1);
263          }
264                                          /* assign new value */
265 <        cp = vp->value; i = vp->nass;
266 <        while (i--)
267 <                while (*cp++)
268 <                        ;
269 <        i = cp - vp->value;
270 <        vp->value = realloc(vp->value, i+n+1);
265 >        if (i = vp->nass) {
266 >                cp = vp->value;
267 >                while (i--)
268 >                        while (*cp++)
269 >                                ;
270 >                i = cp - vp->value;
271 >                vp->value = realloc(vp->value, i+n+1);
272 >        } else
273 >                vp->value = malloc(n+1);
274          if (vp->value == NULL)
275                  syserr(progname);
276          strcpy(vp->value+i, ass);
# Line 369 | Line 374 | register char  *fnames;
374          while (*fnames) {
375                  while (isspace(*fnames)) fnames++;
376                  cp = thisfile;
377 <                while (*fnames && !isspace(*fnames)) *cp++ = *fnames++;
377 >                while (*fnames && !isspace(*fnames))
378 >                        *cp++ = *fnames++;
379                  *cp = '\0';
380                  if ((thisdate = fdate(thisfile)) < 0)
381                          syserr(thisfile);
# Line 488 | Line 494 | printvals()                    /* print variable values */
494          register int    i, j;
495  
496          for (i = 0; i < NVARS; i++)
497 <                for (j = 0; j < vv[i].nass; j++)
498 <                        printf("%s= %s\n", vv[i].name, nvalue(vv+i, j));
497 >                for (j = 0; j < vdef(i); j++)
498 >                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
499          fflush(stdout);
500   }
501  
# Line 502 | Line 508 | oconv()                                /* run oconv if necessary */
508                  return;
509                                          /* build command */
510          oconvopts(ocopts);
511 <        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
512 <                        vdef(MATERIAL) ? vval(MATERIAL) : "",
513 <                        vval(SCENE), vval(OCTREE));
514 <        if (!silent) {                  /* echo it */
515 <                printf("\t%s\n", combuf);
516 <                fflush(stdout);
517 <        }
518 <        if (noaction)
513 <                return;
514 <        if (system(combuf)) {           /* run it */
511 >        if (vdef(MATERIAL))
512 >                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
513 >                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
514 >        else
515 >                sprintf(combuf, "oconv%s %s > %s", ocopts,
516 >                                vval(SCENE), vval(OCTREE));
517 >        
518 >        if (runcom(combuf)) {           /* run it */
519                  fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
520                                  progname, vval(OCTREE));
521                  unlink(vval(OCTREE));
# Line 575 | Line 579 | register char  *op;
579          d *= 3./(siz[0]+siz[1]+siz[2]);
580          switch (vscale(DETAIL)) {
581          case LOW:
582 <                op = addarg(op, "-ps 16");
579 <                op = addarg(op, "-dp 16");
582 >                op = addarg(op, "-ps 16 -dp 16");
583                  sprintf(op, " -ar %d", (int)(4*d));
584                  op += strlen(op);
585                  break;
586          case MEDIUM:
587 <                op = addarg(op, "-ps 8");
585 <                op = addarg(op, "-dp 32");
587 >                op = addarg(op, "-ps 8 -dp 32");
588                  sprintf(op, " -ar %d", (int)(8*d));
589                  op += strlen(op);
590                  break;
591          case HIGH:
592 <                op = addarg(op, "-ps 4");
591 <                op = addarg(op, "-dp 64");
592 >                op = addarg(op, "-ps 4 -dp 64");
593                  sprintf(op, " -ar %d", (int)(16*d));
594                  op += strlen(op);
595                  break;
# Line 596 | Line 597 | register char  *op;
597          op = addarg(op, "-pt .16");
598          if (vbool(PENUMBRAS))
599                  op = addarg(op, "-ds .4");
600 <        op = addarg(op, "-dt .2");
601 <        op = addarg(op, "-dc .25");
602 <        op = addarg(op, "-dr 0");
602 <        op = addarg(op, "-sj 0");
603 <        op = addarg(op, "-st .7");
604 <        op = addarg(op, "-ab 0");
600 >        else
601 >                op = addarg(op, "-ds 0");
602 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7");
603          if (vdef(AMBFILE)) {
604                  sprintf(op, " -af %s", vval(AMBFILE));
605                  op += strlen(op);
# Line 609 | Line 607 | register char  *op;
607                  overture = 0;
608          switch (vscale(VARIABILITY)) {
609          case LOW:
610 <                op = addarg(op, "-aa .4");
613 <                op = addarg(op, "-ad 32");
610 >                op = addarg(op, "-aa .4 -ad 32");
611                  break;
612          case MEDIUM:
613 <                op = addarg(op, "-aa .3");
617 <                op = addarg(op, "-ad 64");
613 >                op = addarg(op, "-aa .3 -ad 64");
614                  break;
615          case HIGH:
616 <                op = addarg(op, "-aa .25");
621 <                op = addarg(op, "-ad 128");
616 >                op = addarg(op, "-aa .25 -ad 128");
617                  break;
618          }
619          op = addarg(op, "-as 0");
620          d = ambval();
621          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
622          op += strlen(op);
623 <        op = addarg(op, "-lr 3");
629 <        op = addarg(op, "-lw .02");
623 >        op = addarg(op, "-lr 3 -lw .02");
624          if (vdef(RENDER))
625                  op = addarg(op, vval(RENDER));
626   }
# Line 665 | Line 659 | register char  *op;
659                  break;
660          }
661          op = addarg(op, "-pt .08");
662 <        if (vbool(PENUMBRAS)) {
663 <                op = addarg(op, "-ds .2");
664 <                op = addarg(op, "-dj .35");
671 <        } else
662 >        if (vbool(PENUMBRAS))
663 >                op = addarg(op, "-ds .2 -dj .35");
664 >        else
665                  op = addarg(op, "-ds .3");
666 <        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");
666 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15");
667          sprintf(op, " -ab %d", overture=vint(INDIRECT));
668          op += strlen(op);
669          if (vdef(AMBFILE)) {
# Line 684 | Line 673 | register char  *op;
673                  overture = 0;
674          switch (vscale(VARIABILITY)) {
675          case LOW:
676 <                op = addarg(op, "-aa .25");
688 <                op = addarg(op, "-ad 128");
689 <                op = addarg(op, "-as 0");
676 >                op = addarg(op, "-aa .25 -ad 128 -as 0");
677                  break;
678          case MEDIUM:
679 <                op = addarg(op, "-aa .2");
693 <                op = addarg(op, "-ad 300");
694 <                op = addarg(op, "-as 64");
679 >                op = addarg(op, "-aa .2 -ad 300 -as 64");
680                  break;
681          case HIGH:
682 <                op = addarg(op, "-aa .15");
698 <                op = addarg(op, "-ad 500");
699 <                op = addarg(op, "-as 128");
682 >                op = addarg(op, "-aa .15 -ad 500 -as 128");
683                  break;
684          }
685          d = ambval();
686          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
687          op += strlen(op);
688 <        op = addarg(op, "-lr 6");
706 <        op = addarg(op, "-lw .002");
688 >        op = addarg(op, "-lr 6 -lw .002");
689          if (vdef(RENDER))
690                  op = addarg(op, vval(RENDER));
691   }
# Line 742 | Line 724 | register char  *op;
724                  break;
725          }
726          op = addarg(op, "-pt .04");
727 <        if (vbool(PENUMBRAS)) {
728 <                op = addarg(op, "-ds .1");
729 <                op = addarg(op, "-dj .7");
748 <        } else
727 >        if (vbool(PENUMBRAS))
728 >                op = addarg(op, "-ds .1 -dj .7");
729 >        else
730                  op = addarg(op, "-ds .2");
731 <        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");
731 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03");
732          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
733          op += strlen(op);
734          if (vdef(AMBFILE)) {
# Line 761 | Line 738 | register char  *op;
738                  overture = 0;
739          switch (vscale(VARIABILITY)) {
740          case LOW:
741 <                op = addarg(op, "-aa .15");
765 <                op = addarg(op, "-ad 200");
766 <                op = addarg(op, "-as 0");
741 >                op = addarg(op, "-aa .15 -ad 200 -as 0");
742                  break;
743          case MEDIUM:
744 <                op = addarg(op, "-aa .125");
770 <                op = addarg(op, "-ad 512");
771 <                op = addarg(op, "-as 128");
744 >                op = addarg(op, "-aa .125 -ad 512 -as 128");
745                  break;
746          case HIGH:
747 <                op = addarg(op, "-aa .08");
775 <                op = addarg(op, "-ad 850");
776 <                op = addarg(op, "-as 256");
747 >                op = addarg(op, "-aa .08 -ad 850 -as 256");
748                  break;
749          }
750          d = ambval();
751          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
752          op += strlen(op);
753 <        op = addarg(op, "-lr 12");
783 <        op = addarg(op, "-lw .0005");
753 >        op = addarg(op, "-lr 12 -lw .0005");
754          if (vdef(RENDER))
755                  op = addarg(op, vval(RENDER));
756   }
# Line 801 | Line 771 | char   *ro;
771                          syserr(vval(OPTFILE));
772                  write(fd, "\n", 1);
773                  close(fd);
774 <                ro[0] = ' ';
805 <                ro[1] = '^';
806 <                strcpy(ro+2, vval(OPTFILE));
774 >                sprintf(ro, " \"^%s\"", vval(OPTFILE));
775          }
776   #ifdef MSDOS
777          else if (n > 50) {
# Line 948 | Line 916 | register char  *vs;
916                          break;
917                  }
918          } else {
919 <                while (*vs && !isspace(*vs))    /* else skip id */
920 <                        vs++;
919 >                while (!isspace(*vs))           /* else skip id */
920 >                        if (!*vs++)
921 >                                return(NULL);
922                  if (upax) {                     /* specify up vector */
923                          strcpy(cp, vup[upax+3]);
924                          cp += strlen(cp);
# Line 1006 | Line 975 | char   *opts;
975          if (rvdevice != NULL)
976                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
977          strcat(combuf, vval(OCTREE));
978 <        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 */
978 >        if (runcom(combuf)) {           /* run it */
979                  fprintf(stderr, "%s: error running rview\n", progname);
980                  exit(1);
981          }
# Line 1060 | Line 1023 | char   *opts;
1023                                          /* check date on ambient file */
1024          if (vdef(AMBFILE)) {
1025                  long    afdate = fdate(vval(AMBFILE));
1026 <                if (afdate >= 0 & octreedate > afdate) {
1027 <                        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 <                }
1026 >                if (afdate >= 0 & octreedate > afdate)
1027 >                        rmfile(vval(AMBFILE));
1028          }
1029                                          /* do each view */
1030          vn = 0;
# Line 1091 | Line 1046 | char   *opts;
1046                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1047                                                  rep, vw, opts,
1048                                                  vval(OCTREE), rawfile);
1049 <                                if (!silent) {
1095 <                                        printf("\t%s\n", combuf);
1096 <                                        fflush(stdout);
1097 <                                }
1098 <                                if (!noaction && system(combuf)) {
1049 >                                if (runcom(combuf)) {
1050                                          fprintf(stderr,
1051                          "%s: error in overture for view %s\n\t%s removed\n",
1052                                                  progname, vs, rawfile);
# Line 1107 | Line 1058 | char   *opts;
1058                                          rep, vw, res, opts,
1059                                          vval(OCTREE), rawfile);
1060                  }
1061 <                if (!silent) {                  /* echo rpict command */
1111 <                        printf("\t%s\n", combuf);
1112 <                        fflush(stdout);
1113 <                }
1114 <                if (!noaction && system(combuf)) {      /* run rpict */
1061 >                if (runcom(combuf)) {           /* run rpict */
1062                          fprintf(stderr, "%s: error rendering view %s\n",
1063                                          progname, vs);
1064                          exit(1);
# Line 1123 | Line 1070 | char   *opts;
1070                  else
1071                          sprintf(combuf, "pfilt%s %s > %s", pfopts,
1072                                          rawfile, picfile);
1073 <                if (!silent) {                  /* echo pfilt command */
1127 <                        printf("\t%s\n", combuf);
1128 <                        fflush(stdout);
1129 <                }
1130 <                if (!noaction && system(combuf)) {      /* run pfilt */
1073 >                if (runcom(combuf)) {           /* run pfilt */
1074                          fprintf(stderr,
1075                          "%s: error filtering view %s\n\t%s removed\n",
1076                                          progname, vs, picfile);
# Line 1135 | Line 1078 | char   *opts;
1078                          exit(1);
1079                  }
1080                                                  /* remove raw file */
1081 <                if (!silent)
1081 >                rmfile(rawfile);
1082 >        }
1083 > }
1084 >
1085 >
1086 > runcom(cs)                      /* run command */
1087 > char    *cs;
1088 > {
1089 >        if (!silent)            /* echo it */
1090 >                printf("\t%s\n", cs);
1091 >        if (noaction)
1092 >                return(0);
1093 >        fflush(stdout);         /* flush output and pass to shell */
1094 >        return(system(cs));
1095 > }
1096 >
1097 >
1098 > rmfile(fn)                      /* remove a file */
1099 > char    *fn;
1100 > {
1101 >        if (!silent)
1102   #ifdef MSDOS
1103 <                        printf("\tdel %s\n", rawfile);
1103 >                printf("\tdel %s\n", fn);
1104   #else
1105 <                        printf("\trm %s\n", rawfile);
1105 >                printf("\trm -f %s\n", fn);
1106   #endif
1107 <                if (!noaction)
1108 <                        unlink(rawfile);
1109 <        }
1107 >        if (noaction)
1108 >                return(0);
1109 >        return(unlink(fn));
1110   }
1111  
1112  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines