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.33 by greg, Thu Nov 18 10:00:21 1993 UTC vs.
Revision 2.38 by greg, Sat Jan 1 12:12:32 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   #include "standard.h"
12   #include "paths.h"
13   #include <ctype.h>
14 + #include <sys/types.h>
15  
16  
17   typedef struct {
# Line 101 | Line 102 | char   overfile[] = "overture.raw";
102   char    overfile[] = "/dev/null";
103   #endif
104  
105 < extern unsigned long    fdate(), time();
105 > extern time_t   fdate(), time();
106  
107 < unsigned long   scenedate;      /* date of latest scene or object file */
108 < unsigned long   octreedate;     /* date of octree */
109 < unsigned long   matdate;        /* date of latest material file */
110 < unsigned long   illumdate;      /* date of last illum file */
107 > time_t  scenedate;              /* date of latest scene or object file */
108 > time_t  octreedate;             /* date of octree */
109 > time_t  matdate;                /* date of latest material file */
110 > time_t  illumdate;              /* date of last illum file */
111  
112   char    *oct0name;              /* name of pre-mkillum octree */
113 < unsigned long   oct0date;       /* date of pre-mkillum octree */
113 > time_t  oct0date;               /* date of pre-mkillum octree */
114   char    *oct1name;              /* name of post-mkillum octree */
115 < unsigned long   oct1date;       /* date of post-mkillum octree (>= matdate) */
115 > time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
116  
117 + int     nowarn = 0;             /* no warnings */
118   int     explicate = 0;          /* explicate variables */
119   int     silent = 0;             /* do work silently */
120   int     noaction = 0;           /* don't do anything */
# Line 133 | Line 135 | int    argc;
135   char    *argv[];
136   {
137          char    ropts[512];
138 +        char    popts[64];
139          int     i;
140  
141          progname = argv[0];
# Line 157 | Line 160 | char   *argv[];
160                  case 'v':
161                          viewselect = argv[++i];
162                          break;
163 +                case 'w':
164 +                        nowarn++;
165 +                        break;
166                  default:
167                          goto userr;
168                  }
# Line 184 | Line 190 | char   *argv[];
190                                  /* check date on ambient file */
191          checkambfile();
192                                  /* run simulation */
193 <        renderopts(ropts);
193 >        renderopts(ropts, popts);
194          xferopts(ropts);
195          if (rvdevice != NULL)
196 <                rview(ropts);
196 >                rview(ropts, popts);
197          else
198 <                rpict(ropts);
198 >                rpict(ropts, popts);
199          exit(0);
200   userr:
201          fprintf(stderr,
# Line 272 | Line 278 | register char  *ass;
278          for (n = strlen(ass); n > 0; n--)
279                  if (!isspace(ass[n-1]))
280                          break;
281 <        if (!n) {
281 >        if (!n && !nowarn) {
282                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
283                                  progname, varname);
284                  return;
# Line 358 | Line 364 | register VARIABLE      *vp;
364   {
365          if (vp->nass < 2)
366                  return;
367 <        fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
367 >        if (!nowarn)
368 >                fprintf(stderr,
369 >                "%s: warning - multiple assignment of variable '%s'\n",
370                          progname, vp->name);
371          do
372                  vp->value += strlen(vp->value)+1;
# Line 459 | Line 467 | register VARIABLE      *vp;
467   }
468  
469  
470 < unsigned long
470 > time_t
471   checklast(fnames)                       /* check files and find most recent */
472   register char   *fnames;
473   {
474          char    thisfile[MAXPATH];
475 <        unsigned long   thisdate, lastdate = 0;
475 >        time_t  thisdate, lastdate = 0;
476          register char   *cp;
477  
478          if (fnames == NULL)
# Line 512 | Line 520 | int    pred;
520  
521   checkfiles()                    /* check for existence and modified times */
522   {
523 <        unsigned long   objdate;
523 >        time_t  objdate;
524  
525          if (!vdef(OCTREE)) {
526                  if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
# Line 640 | Line 648 | setdefaults()                  /* set default values for unassigned v
648  
649   printvals()                     /* print variable values */
650   {
651 <        register int    i, j;
651 >        int     i, j, clipline;
652 >        register char   *cp;
653 >        register int    k;
654  
655 <        for (i = 0; i < NVARS; i++)
656 <                for (j = 0; j < vdef(i); j++)
657 <                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
655 >        for (i = 0; i < NVARS; i++)             /* print each variable */
656 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
657 >                fputs(vnam(i), stdout);
658 >                fputs("= ", stdout);
659 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
660 >                                - strlen(vnam(i)) ;
661 >                cp = nvalue(vv+i, j);
662 >                while (*cp) {
663 >                    putchar(*cp++);
664 >                    if (--k <= 0) {             /* line too long */
665 >                        while (*cp && !isspace(*cp))
666 >                            putchar(*cp++);     /* finish this word */
667 >                        if (*cp) {              /* start new line */
668 >                            putchar('\n');
669 >                            fputs(vnam(i), stdout);
670 >                            putchar('=');
671 >                            k = clipline;
672 >                        }
673 >                    }
674 >                }
675 >                putchar('\n');
676 >            }
677          fflush(stdout);
678   }
679  
# Line 671 | Line 700 | oconv()                                /* run oconv and mkillum if necessary */
700                          unlink(vval(OCTREE));
701                          exit(1);
702                  }
703 <                octreedate = time(0);
703 >                octreedate = time((time_t *)NULL);
704          }
705          if (oct1name == vval(OCTREE))           /* no mkillum? */
706                  oct1date = octreedate > matdate ? octreedate : matdate;
# Line 697 | Line 726 | oconv()                                /* run oconv and mkillum if necessary */
726                          unlink(oct0name);
727                          exit(1);
728                  }
729 <                oct0date = time(0);
729 >                oct0date = time((time_t *)NULL);
730          }
731          mkillumopts(mkopts);                    /* build mkillum command */
732          mktemp(illumtmp);
# Line 725 | Line 754 | oconv()                                /* run oconv and mkillum if necessary */
754                  unlink(oct1name);
755                  exit(1);
756          }
757 <        oct1date = time(0);
757 >        oct1date = time((time_t *)NULL);
758          rmfile(illumtmp);
759   }
760  
# Line 765 | Line 794 | register char  *mo;
794  
795   checkambfile()                  /* check date on ambient file */
796   {
797 <        unsigned long   afdate;
797 >        time_t  afdate;
798  
799          if (!vdef(AMBFILE))
800                  return;
# Line 792 | Line 821 | ambval()                               /* compute ambient value */
821   }
822  
823  
824 < renderopts(op)                          /* set rendering options */
825 < char    *op;
824 > renderopts(op, po)                      /* set rendering options */
825 > char    *op, *po;
826   {
827          switch(vscale(QUALITY)) {
828          case LOW:
829 <                lowqopts(op);
829 >                lowqopts(op, po);
830                  break;
831          case MEDIUM:
832 <                medqopts(op);
832 >                medqopts(op, po);
833                  break;
834          case HIGH:
835 <                hiqopts(op);
835 >                hiqopts(op, po);
836                  break;
837          }
838   }
839  
840  
841 < lowqopts(op)                            /* low quality rendering options */
841 > lowqopts(op, po)                        /* low quality rendering options */
842   register char   *op;
843 + char    *po;
844   {
845          double  d, org[3], siz[3];
846  
847          *op = '\0';
848 +        *po = '\0';
849          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
850                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
851                  badvalue(ZONE);
# Line 823 | Line 854 | register char  *op;
854          d *= 3./(siz[0]+siz[1]+siz[2]);
855          switch (vscale(DETAIL)) {
856          case LOW:
857 <                op = addarg(op, "-ps 16 -dp 64");
857 >                po = addarg(po, "-ps 16");
858 >                op = addarg(op, "-dp 64");
859                  sprintf(op, " -ar %d", (int)(4*d));
860                  op += strlen(op);
861                  break;
862          case MEDIUM:
863 <                op = addarg(op, "-ps 8 -dp 128");
863 >                po = addarg(po, "-ps 8");
864 >                op = addarg(op, "-dp 128");
865                  sprintf(op, " -ar %d", (int)(8*d));
866                  op += strlen(op);
867                  break;
868          case HIGH:
869 <                op = addarg(op, "-ps 4 -dp 256");
869 >                po = addarg(po, "-ps 4");
870 >                op = addarg(op, "-dp 256");
871                  sprintf(op, " -ar %d", (int)(16*d));
872                  op += strlen(op);
873                  break;
874          }
875 <        op = addarg(op, "-pt .16");
875 >        po = addarg(po, "-pt .16");
876          if (vbool(PENUMBRAS))
877                  op = addarg(op, "-ds .4");
878          else
# Line 870 | Line 904 | register char  *op;
904   }
905  
906  
907 < medqopts(op)                            /* medium quality rendering options */
907 > medqopts(op, po)                        /* medium quality rendering options */
908   register char   *op;
909 + char    *po;
910   {
911          double  d, org[3], siz[3];
912  
913          *op = '\0';
914 +        *po = '\0';
915          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
916                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
917                  badvalue(ZONE);
# Line 884 | Line 920 | register char  *op;
920          d *= 3./(siz[0]+siz[1]+siz[2]);
921          switch (vscale(DETAIL)) {
922          case LOW:
923 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
923 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
924                  op = addarg(op, "-dp 256");
925                  sprintf(op, " -ar %d", (int)(8*d));
926                  op += strlen(op);
927                  break;
928          case MEDIUM:
929 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
929 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
930                  op = addarg(op, "-dp 512");
931                  sprintf(op, " -ar %d", (int)(16*d));
932                  op += strlen(op);
933                  break;
934          case HIGH:
935 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
935 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
936                  op = addarg(op, "-dp 1024");
937                  sprintf(op, " -ar %d", (int)(32*d));
938                  op += strlen(op);
939                  break;
940          }
941 <        op = addarg(op, "-pt .08");
941 >        po = addarg(po, "-pt .08");
942          if (vbool(PENUMBRAS))
943                  op = addarg(op, "-ds .2 -dj .5");
944          else
# Line 937 | Line 973 | register char  *op;
973   }
974  
975  
976 < hiqopts(op)                             /* high quality rendering options */
976 > hiqopts(op, po)                         /* high quality rendering options */
977   register char   *op;
978 + char    *po;
979   {
980          double  d, org[3], siz[3];
981  
982          *op = '\0';
983 +        *po = '\0';
984          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
985                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
986                  badvalue(ZONE);
# Line 951 | Line 989 | register char  *op;
989          d *= 3./(siz[0]+siz[1]+siz[2]);
990          switch (vscale(DETAIL)) {
991          case LOW:
992 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
992 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
993                  op = addarg(op, "-dp 1024");
994                  sprintf(op, " -ar %d", (int)(16*d));
995                  op += strlen(op);
996                  break;
997          case MEDIUM:
998 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
998 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
999                  op = addarg(op, "-dp 2048");
1000                  sprintf(op, " -ar %d", (int)(32*d));
1001                  op += strlen(op);
1002                  break;
1003          case HIGH:
1004 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1004 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1005                  op = addarg(op, "-dp 4096");
1006                  sprintf(op, " -ar %d", (int)(64*d));
1007                  op += strlen(op);
1008                  break;
1009          }
1010 <        op = addarg(op, "-pt .04");
1010 >        po = addarg(po, "-pt .04");
1011          if (vbool(PENUMBRAS))
1012                  op = addarg(op, "-ds .1 -dj .7");
1013          else
# Line 1282 | Line 1320 | register char  *vopts;
1320   }
1321  
1322  
1323 < rview(opts)                             /* run rview with first view */
1324 < char    *opts;
1323 > rview(opts, po)                         /* run rview with first view */
1324 > char    *opts, *po;
1325   {
1326          char    *vw;
1327          char    combuf[512];
# Line 1292 | Line 1330 | char   *opts;
1330                  return;
1331          if (sayview)
1332                  printview(vw);
1333 <        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1333 >        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1334          if (rvdevice != NULL)
1335                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1336          if (vdef(EXPOSURE))
# Line 1305 | Line 1343 | char   *opts;
1343   }
1344  
1345  
1346 < rpict(opts)                             /* run rpict and pfilt for each view */
1347 < char    *opts;
1346 > rpict(opts, po)                         /* run rpict and pfilt for each view */
1347 > char    *opts, *po;
1348   {
1349          char    combuf[1024];
1350          char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
# Line 1367 | Line 1405 | char   *opts;
1405                                                  /* build rpict command */
1406                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1407                  if (fdate(rawfile) >= oct1date)         /* recover */
1408 <                        sprintf(combuf, "rpict%s%s -ro %s %s",
1409 <                                        rep, opts, rawfile, oct1name);
1408 >                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1409 >                                        rep, po, opts, rawfile, oct1name);
1410                  else {
1411                          if (overture) {         /* run overture calculation */
1412                                  sprintf(combuf,
# Line 1385 | Line 1423 | char   *opts;
1423                                  rmfile(overfile);
1424   #endif
1425                          }
1426 <                        sprintf(combuf, "rpict%s %s %s%s %s > %s",
1427 <                                        rep, vw, res, opts,
1426 >                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1427 >                                        rep, vw, res, po, opts,
1428                                  oct1name, rawfile);
1429                  }
1430                  if (runcom(combuf)) {           /* run rpict */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines