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.40 by greg, Thu Apr 21 12:22:44 1994 UTC vs.
Revision 2.45 by greg, Mon Aug 28 10:12:40 1995 UTC

# Line 38 | Line 38 | int    onevalue(), catvalues(), boolvalue(),
38   #define ZONE            9               /* simulation zone */
39   #define QUALITY         10              /* desired rendering quality */
40   #define OCTREE          11              /* octree file name */
41 < #define PICTURE         12              /* picture file name */
41 > #define PICTURE         12              /* picture file root name */
42   #define AMBFILE         13              /* ambient file name */
43   #define OPTFILE         14              /* rendering options file */
44   #define EXPOSURE        15              /* picture exposure setting */
# Line 49 | Line 49 | int    onevalue(), catvalues(), boolvalue(),
49   #define PENUMBRAS       20              /* shadow penumbras are desired */
50   #define VARIABILITY     21              /* level of light variability */
51   #define REPORT          22              /* report frequency and errfile */
52 + #define RAWFILE         23              /* raw picture file root name */
53 + #define ZFILE           24              /* distance file root name */
54                                  /* total number of variables */
55 < #define NVARS           23
55 > #define NVARS           25
56  
57   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
58          {"objects",     3,      0,      NULL,   catvalues},
# Line 76 | Line 78 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
78          {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
79          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
80          {"REPORT",      3,      0,      NULL,   onevalue},
81 +        {"RAWFILE",     3,      0,      NULL,   onevalue},
82 +        {"ZFILE",       2,      0,      NULL,   onevalue},
83   };
84  
85   VARIABLE        *matchvar();
# Line 97 | Line 101 | char   *nvalue();
101  
102                                  /* overture calculation file */
103   #ifdef NIX
104 < char    overfile[] = "overture.raw";
104 > char    overfile[] = "overture.unf";
105   #else
106   char    overfile[] = "/dev/null";
107   #endif
# Line 117 | Line 121 | time_t oct1date;               /* date of post-mkillum octree (>= m
121   int     nowarn = 0;             /* no warnings */
122   int     explicate = 0;          /* explicate variables */
123   int     silent = 0;             /* do work silently */
124 + int     touchonly = 0;          /* touch files only */
125   int     noaction = 0;           /* don't do anything */
126   int     sayview = 0;            /* print view out */
127   char    *rvdevice = NULL;       /* rview output device */
# Line 148 | Line 153 | char   *argv[];
153                  case 'n':
154                          noaction++;
155                          break;
156 +                case 't':
157 +                        touchonly++;
158 +                        break;
159                  case 'e':
160                          explicate++;
161                          break;
# Line 199 | Line 207 | char   *argv[];
207          exit(0);
208   userr:
209          fprintf(stderr,
210 <        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
210 > "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
211                          progname);
212          exit(1);
213   }
# Line 685 | Line 693 | oconv()                                /* run oconv and mkillum if necessary */
693  
694          oconvopts(ocopts);              /* get options */
695          if (octreedate < scenedate) {   /* check date on original octree */
696 <                                                /* build command */
697 <                if (vdef(MATERIAL))
698 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
699 <                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
700 <                else
701 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
702 <                                        vval(SCENE), vval(OCTREE));
703 <                
704 <                if (runcom(combuf)) {           /* run it */
705 <                        fprintf(stderr,
696 >                if (touchonly && octreedate)
697 >                        touch(vval(OCTREE));
698 >                else {                          /* build command */
699 >                        if (vdef(MATERIAL))
700 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
701 >                                                vval(MATERIAL), vval(SCENE),
702 >                                                vval(OCTREE));
703 >                        else
704 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
705 >                                                vval(SCENE), vval(OCTREE));
706 >                        
707 >                        if (runcom(combuf)) {           /* run it */
708 >                                fprintf(stderr,
709                                  "%s: error generating octree\n\t%s removed\n",
710 <                                        progname, vval(OCTREE));
711 <                        unlink(vval(OCTREE));
712 <                        exit(1);
710 >                                                progname, vval(OCTREE));
711 >                                unlink(vval(OCTREE));
712 >                                exit(1);
713 >                        }
714                  }
715                  octreedate = time((time_t *)NULL);
716                  if (octreedate < scenedate)     /* in case clock is off */
# Line 711 | Line 723 | oconv()                                /* run oconv and mkillum if necessary */
723                  return;
724                                                  /* make octree0 */
725          if (oct0date < scenedate | oct0date < illumdate) {
726 <                                                /* build command */
726 >                if (touchonly && oct0date)
727 >                        touch(oct0name);
728 >                else {                          /* build command */
729 >                        if (octreedate)
730 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
731 >                                        vval(OCTREE), vval(ILLUM), oct0name);
732 >                        else if (vdef(MATERIAL))
733 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
734 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
735 >                        else
736 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
737 >                                        vval(ILLUM), oct0name);
738 >                        if (runcom(combuf)) {           /* run it */
739 >                                fprintf(stderr,
740 >                                "%s: error generating octree\n\t%s removed\n",
741 >                                                progname, oct0name);
742 >                                unlink(oct0name);
743 >                                exit(1);
744 >                        }
745 >                }
746 >                oct0date = time((time_t *)NULL);
747 >                if (oct0date < octreedate)      /* in case clock is off */
748 >                        oct0date = octreedate;
749 >                if (oct0date < illumdate)       /* ditto */
750 >                        oct0date = illumdate;
751 >                }
752 >        if (touchonly && oct1date)
753 >                touch(oct1name);
754 >        else {
755 >                mkillumopts(mkopts);            /* build mkillum command */
756 >                mktemp(illumtmp);
757 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
758 >                                oct0name, vval(ILLUM), illumtmp);
759 >                if (runcom(combuf)) {                   /* run it */
760 >                        fprintf(stderr, "%s: error running mkillum\n",
761 >                                        progname);
762 >                        unlink(illumtmp);
763 >                        exit(1);
764 >                }
765 >                                                /* make octree1 (frozen) */
766                  if (octreedate)
767 <                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
768 <                                vval(OCTREE), vval(ILLUM), oct0name);
767 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
768 >                                vval(OCTREE), illumtmp, oct1name);
769                  else if (vdef(MATERIAL))
770 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
771 <                                vval(MATERIAL), vval(ILLUM), oct0name);
770 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
771 >                                vval(MATERIAL), illumtmp, oct1name);
772                  else
773 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
774 <                                vval(ILLUM), oct0name);
773 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
774 >                                illumtmp, oct1name);
775                  if (runcom(combuf)) {           /* run it */
776                          fprintf(stderr,
777                                  "%s: error generating octree\n\t%s removed\n",
778 <                                        progname, oct0name);
779 <                        unlink(oct0name);
778 >                                        progname, oct1name);
779 >                        unlink(oct1name);
780                          exit(1);
781                  }
782 <                oct0date = time((time_t *)NULL);
732 <                if (oct0date < octreedate)      /* in case clock is off */
733 <                        oct0date = octreedate;
734 <                if (oct0date < illumdate)       /* ditto */
735 <                        oct0date = illumdate;
782 >                rmfile(illumtmp);
783          }
737        mkillumopts(mkopts);                    /* build mkillum command */
738        mktemp(illumtmp);
739        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
740                        oct0name, vval(ILLUM), illumtmp);
741        if (runcom(combuf)) {                   /* run it */
742                fprintf(stderr, "%s: error running mkillum\n", progname);
743                unlink(illumtmp);
744                exit(1);
745        }
746                                                /* make octree1 (frozen) */
747        if (octreedate)
748                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
749                        vval(OCTREE), illumtmp, oct1name);
750        else if (vdef(MATERIAL))
751                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
752                        vval(MATERIAL), illumtmp, oct1name);
753        else
754                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
755                        illumtmp, oct1name);
756        if (runcom(combuf)) {           /* run it */
757                fprintf(stderr,
758                        "%s: error generating octree\n\t%s removed\n",
759                                progname, oct1name);
760                unlink(oct1name);
761                exit(1);
762        }
784          oct1date = time((time_t *)NULL);
785          if (oct1date < oct0date)        /* in case clock is off */
786                  oct1date = oct0date;
766        rmfile(illumtmp);
787   }
788  
789  
# Line 809 | Line 829 | checkambfile()                 /* check date on ambient file */
829          if (!(afdate = fdate(vval(AMBFILE))))
830                  return;
831          if (oct1date > afdate)
832 <                rmfile(vval(AMBFILE));
832 >                if (touchonly)
833 >                        touch(vval(AMBFILE));
834 >                else
835 >                        rmfile(vval(AMBFILE));
836   }
837  
838  
# Line 1023 | Line 1046 | char   *po;
1046          }
1047          po = addarg(po, "-pt .04");
1048          if (vbool(PENUMBRAS))
1049 <                op = addarg(op, "-ds .1 -dj .7");
1049 >                op = addarg(op, "-ds .1 -dj .65");
1050          else
1051                  op = addarg(op, "-ds .2");
1052          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1160 | Line 1183 | register char  *vs;
1183                  zpos = -1; vs++;
1184          }
1185          viewtype = 'v';
1186 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
1186 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
1187                  viewtype = *vs++;
1188          cp = viewopts;
1189          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1215 | Line 1238 | register char  *vs;
1238                  case 'h':
1239                          cp = addarg(cp, "-vh 180 -vv 180");
1240                          break;
1241 +                case 'c':
1242 +                        cp = addarg(cp, "-vh 180 -vv 90");
1243 +                        break;
1244                  }
1245          } else {
1246                  while (!isspace(*vs))           /* else skip id */
# Line 1342 | Line 1368 | char   *opts, *po;
1368          char    *vw;
1369          char    combuf[512];
1370                                          /* build command */
1371 <        if ((vw = getview(0, NULL)) == NULL)
1371 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1372                  return;
1373          if (sayview)
1374                  printview(vw);
# Line 1363 | Line 1389 | rpict(opts, po)                                /* run rpict and pfilt for each vie
1389   char    *opts, *po;
1390   {
1391          char    combuf[1024];
1392 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1392 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1393 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1394          char    pfopts[128];
1395          char    vs[32], *vw;
1396          int     vn, mult;
1397 +        time_t  rfdt, pfdt;
1398                                          /* get pfilt options */
1399          pfiltopts(pfopts);
1400                                          /* get resolution, reporting */
# Line 1415 | Line 1443 | char   *opts, *po;
1443                  if (!vs[0])
1444                          sprintf(vs, "%d", vn);
1445                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1446 +                if (vdef(ZFILE))
1447 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1448 +                else
1449 +                        zopt[0] = '\0';
1450                                                  /* check date on picture */
1451 <                if (fdate(picfile) >= oct1date)
1451 >                pfdt = fdate(picfile);
1452 >                if (pfdt >= oct1date)
1453                          continue;
1454 +                                                /* get raw file name */
1455 +                sprintf(rawfile, "%s_%s.unf",
1456 +                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1457 +                rfdt = fdate(rawfile);
1458 +                if (touchonly) {                /* update times only */
1459 +                        if (rfdt) {
1460 +                                if (rfdt < oct1date)
1461 +                                        touch(rawfile);
1462 +                        } else if (pfdt && pfdt < oct1date)
1463 +                                touch(picfile);
1464 +                        continue;
1465 +                }
1466                                                  /* build rpict command */
1467 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1468 <                if (fdate(rawfile) >= oct1date)         /* recover */
1469 <                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1425 <                                        rep, po, opts, rawfile, oct1name);
1467 >                if (rfdt >= oct1date)           /* recover */
1468 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1469 >                                rep, po, opts, zopt, rawfile, oct1name);
1470                  else {
1471                          if (overture) {         /* run overture calculation */
1472                                  sprintf(combuf,
# Line 1439 | Line 1483 | char   *opts, *po;
1483                                  rmfile(overfile);
1484   #endif
1485                          }
1486 <                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1487 <                                        rep, vw, res, po, opts,
1488 <                                oct1name, rawfile);
1486 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1487 >                                        rep, vw, res, po, opts, zopt,
1488 >                                        oct1name, rawfile);
1489                  }
1490                  if (runcom(combuf)) {           /* run rpict */
1491                          fprintf(stderr, "%s: error rendering view %s\n",
1492                                          progname, vs);
1493                          exit(1);
1494                  }
1495 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1496                                                  /* build pfilt command */
1497 <                if (mult > 1)
1498 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1497 >                        if (mult > 1)
1498 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1499                                          pfopts, mult, mult, rawfile, picfile);
1500 <                else
1501 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1502 <                                        rawfile, picfile);
1503 <                if (runcom(combuf)) {           /* run pfilt */
1504 <                        fprintf(stderr,
1505 <                        "%s: error filtering view %s\n\t%s removed\n",
1506 <                                        progname, vs, picfile);
1507 <                        unlink(picfile);
1508 <                        exit(1);
1500 >                        else
1501 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1502 >                                                rawfile, picfile);
1503 >                        if (runcom(combuf)) {           /* run pfilt */
1504 >                                fprintf(stderr,
1505 >                                "%s: error filtering view %s\n\t%s removed\n",
1506 >                                                progname, vs, picfile);
1507 >                                unlink(picfile);
1508 >                                exit(1);
1509 >                        }
1510                  }
1511 <                                                /* remove raw file */
1512 <                rmfile(rawfile);
1511 >                                                /* remove/rename raw file */
1512 >                if (vdef(RAWFILE)) {
1513 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1514 >                        mvfile(rawfile, combuf);
1515 >                } else
1516 >                        rmfile(rawfile);
1517          }
1518   }
1519  
1520  
1521 + touch(fn)                       /* update a file */
1522 + char    *fn;
1523 + {
1524 +        if (!silent)
1525 +                printf("\ttouch %s\n", fn);
1526 +        if (noaction)
1527 +                return(0);
1528 + #ifdef notused
1529 +        if (access(fn, F_OK) == -1)             /* create it */
1530 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1531 +                        return(-1);
1532 + #endif
1533 +        return(setfdate(fn, time((time_t *)NULL)));
1534 + }
1535 +
1536 +
1537   runcom(cs)                      /* run command */
1538   char    *cs;
1539   {
# Line 1492 | Line 1558 | char   *fn;
1558          if (noaction)
1559                  return(0);
1560          return(unlink(fn));
1561 + }
1562 +
1563 +
1564 + mvfile(fold, fnew)              /* move a file */
1565 + char    *fold, *fnew;
1566 + {
1567 +        if (!silent)
1568 + #ifdef MSDOS
1569 +                printf("\trename %s %s\n", fold, fnew);
1570 + #else
1571 +                printf("\tmv %s %s\n", fold, fnew);
1572 + #endif
1573 +        if (noaction)
1574 +                return(0);
1575 +        return(rename(fold, fnew));
1576   }
1577  
1578  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines