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.43 by greg, Thu Jul 6 12:15:40 1995 UTC

# 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 RAWSAVE         23              /* save raw picture file */
53                                  /* total number of variables */
54 < #define NVARS           23
54 > #define NVARS           24
55  
56   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
57          {"objects",     3,      0,      NULL,   catvalues},
# Line 76 | Line 77 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
77          {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
78          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
79          {"REPORT",      3,      0,      NULL,   onevalue},
80 +        {"RAWSAVE",     3,      0,      NULL,   boolvalue},
81   };
82  
83   VARIABLE        *matchvar();
# Line 117 | Line 119 | time_t oct1date;               /* date of post-mkillum octree (>= m
119   int     nowarn = 0;             /* no warnings */
120   int     explicate = 0;          /* explicate variables */
121   int     silent = 0;             /* do work silently */
122 + int     touchonly = 0;          /* touch files only */
123   int     noaction = 0;           /* don't do anything */
124   int     sayview = 0;            /* print view out */
125   char    *rvdevice = NULL;       /* rview output device */
# Line 148 | Line 151 | char   *argv[];
151                  case 'n':
152                          noaction++;
153                          break;
154 +                case 't':
155 +                        touchonly++;
156 +                        break;
157                  case 'e':
158                          explicate++;
159                          break;
# Line 199 | Line 205 | char   *argv[];
205          exit(0);
206   userr:
207          fprintf(stderr,
208 <        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
208 > "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
209                          progname);
210          exit(1);
211   }
# Line 643 | Line 649 | setdefaults()                  /* set default values for unassigned v
649                  vval(VARIABILITY) = "L";
650                  vdef(VARIABILITY)++;
651          }
652 +        if (!vdef(RAWSAVE)) {
653 +                vval(RAWSAVE) = "F";
654 +                vdef(RAWSAVE)++;
655 +        }
656   }
657  
658  
# Line 685 | Line 695 | oconv()                                /* run oconv and mkillum if necessary */
695  
696          oconvopts(ocopts);              /* get options */
697          if (octreedate < scenedate) {   /* check date on original octree */
698 <                                                /* build command */
699 <                if (vdef(MATERIAL))
700 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
701 <                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
702 <                else
703 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
704 <                                        vval(SCENE), vval(OCTREE));
705 <                
706 <                if (runcom(combuf)) {           /* run it */
707 <                        fprintf(stderr,
698 >                if (touchonly && octreedate)
699 >                        touch(vval(OCTREE));
700 >                else {                          /* build command */
701 >                        if (vdef(MATERIAL))
702 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
703 >                                                vval(MATERIAL), vval(SCENE),
704 >                                                vval(OCTREE));
705 >                        else
706 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
707 >                                                vval(SCENE), vval(OCTREE));
708 >                        
709 >                        if (runcom(combuf)) {           /* run it */
710 >                                fprintf(stderr,
711                                  "%s: error generating octree\n\t%s removed\n",
712 <                                        progname, vval(OCTREE));
713 <                        unlink(vval(OCTREE));
714 <                        exit(1);
712 >                                                progname, vval(OCTREE));
713 >                                unlink(vval(OCTREE));
714 >                                exit(1);
715 >                        }
716                  }
717                  octreedate = time((time_t *)NULL);
718                  if (octreedate < scenedate)     /* in case clock is off */
# Line 711 | Line 725 | oconv()                                /* run oconv and mkillum if necessary */
725                  return;
726                                                  /* make octree0 */
727          if (oct0date < scenedate | oct0date < illumdate) {
728 <                                                /* build command */
728 >                if (touchonly && oct0date)
729 >                        touch(oct0name);
730 >                else {                          /* build command */
731 >                        if (octreedate)
732 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
733 >                                        vval(OCTREE), vval(ILLUM), oct0name);
734 >                        else if (vdef(MATERIAL))
735 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
736 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
737 >                        else
738 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
739 >                                        vval(ILLUM), oct0name);
740 >                        if (runcom(combuf)) {           /* run it */
741 >                                fprintf(stderr,
742 >                                "%s: error generating octree\n\t%s removed\n",
743 >                                                progname, oct0name);
744 >                                unlink(oct0name);
745 >                                exit(1);
746 >                        }
747 >                }
748 >                oct0date = time((time_t *)NULL);
749 >                if (oct0date < octreedate)      /* in case clock is off */
750 >                        oct0date = octreedate;
751 >                if (oct0date < illumdate)       /* ditto */
752 >                        oct0date = illumdate;
753 >                }
754 >        if (touchonly && oct1date)
755 >                touch(oct1name);
756 >        else {
757 >                mkillumopts(mkopts);            /* build mkillum command */
758 >                mktemp(illumtmp);
759 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
760 >                                oct0name, vval(ILLUM), illumtmp);
761 >                if (runcom(combuf)) {                   /* run it */
762 >                        fprintf(stderr, "%s: error running mkillum\n",
763 >                                        progname);
764 >                        unlink(illumtmp);
765 >                        exit(1);
766 >                }
767 >                                                /* make octree1 (frozen) */
768                  if (octreedate)
769 <                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
770 <                                vval(OCTREE), vval(ILLUM), oct0name);
769 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
770 >                                vval(OCTREE), illumtmp, oct1name);
771                  else if (vdef(MATERIAL))
772 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
773 <                                vval(MATERIAL), vval(ILLUM), oct0name);
772 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
773 >                                vval(MATERIAL), illumtmp, oct1name);
774                  else
775 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
776 <                                vval(ILLUM), oct0name);
775 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
776 >                                illumtmp, oct1name);
777                  if (runcom(combuf)) {           /* run it */
778                          fprintf(stderr,
779                                  "%s: error generating octree\n\t%s removed\n",
780 <                                        progname, oct0name);
781 <                        unlink(oct0name);
780 >                                        progname, oct1name);
781 >                        unlink(oct1name);
782                          exit(1);
783                  }
784 <                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;
784 >                rmfile(illumtmp);
785          }
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        }
786          oct1date = time((time_t *)NULL);
787          if (oct1date < oct0date)        /* in case clock is off */
788                  oct1date = oct0date;
766        rmfile(illumtmp);
789   }
790  
791  
# Line 809 | Line 831 | checkambfile()                 /* check date on ambient file */
831          if (!(afdate = fdate(vval(AMBFILE))))
832                  return;
833          if (oct1date > afdate)
834 <                rmfile(vval(AMBFILE));
834 >                if (touchonly)
835 >                        touch(vval(AMBFILE));
836 >                else
837 >                        rmfile(vval(AMBFILE));
838   }
839  
840  
# Line 1023 | Line 1048 | char   *po;
1048          }
1049          po = addarg(po, "-pt .04");
1050          if (vbool(PENUMBRAS))
1051 <                op = addarg(op, "-ds .1 -dj .7");
1051 >                op = addarg(op, "-ds .1 -dj .65");
1052          else
1053                  op = addarg(op, "-ds .2");
1054          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1342 | Line 1367 | char   *opts, *po;
1367          char    *vw;
1368          char    combuf[512];
1369                                          /* build command */
1370 <        if ((vw = getview(0, NULL)) == NULL)
1370 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1371                  return;
1372          if (sayview)
1373                  printview(vw);
# Line 1367 | Line 1392 | char   *opts, *po;
1392          char    pfopts[128];
1393          char    vs[32], *vw;
1394          int     vn, mult;
1395 +        time_t  rfdt, pfdt;
1396                                          /* get pfilt options */
1397          pfiltopts(pfopts);
1398                                          /* get resolution, reporting */
# Line 1416 | Line 1442 | char   *opts, *po;
1442                          sprintf(vs, "%d", vn);
1443                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1444                                                  /* check date on picture */
1445 <                if (fdate(picfile) >= oct1date)
1445 >                pfdt = fdate(picfile);
1446 >                if (pfdt >= oct1date)
1447                          continue;
1448 <                                                /* build rpict command */
1448 >                                                /* get raw file name */
1449                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1450 <                if (fdate(rawfile) >= oct1date)         /* recover */
1450 >                rfdt = fdate(rawfile);
1451 >                if (touchonly) {                /* update times only */
1452 >                        if (rfdt) {
1453 >                                if (rfdt < oct1date)
1454 >                                        touch(rawfile);
1455 >                        } else if (pfdt && pfdt < oct1date)
1456 >                                touch(picfile);
1457 >                        continue;
1458 >                }
1459 >                                                /* build rpict command */
1460 >                if (rfdt >= oct1date)           /* recover */
1461                          sprintf(combuf, "rpict%s%s%s -ro %s %s",
1462                                          rep, po, opts, rawfile, oct1name);
1463                  else {
# Line 1462 | Line 1499 | char   *opts, *po;
1499                          unlink(picfile);
1500                          exit(1);
1501                  }
1502 <                                                /* remove raw file */
1503 <                rmfile(rawfile);
1502 >                                                /* remove/rename raw file */
1503 >                if (vbool(RAWSAVE)) {
1504 >                        sprintf(combuf, "%s_%s.rwp", vval(PICTURE), vs);
1505 >                        mvfile(rawfile, combuf);
1506 >                } else
1507 >                        rmfile(rawfile);
1508          }
1509   }
1510  
1511  
1512 + touch(fn)                       /* update a file */
1513 + char    *fn;
1514 + {
1515 +        if (!silent)
1516 +                printf("\ttouch %s\n", fn);
1517 +        if (noaction)
1518 +                return(0);
1519 + #ifdef notused
1520 +        if (access(fn, F_OK) == -1)             /* create it */
1521 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1522 +                        return(-1);
1523 + #endif
1524 +        return(setfdate(fn, time((time_t *)NULL)));
1525 + }
1526 +
1527 +
1528   runcom(cs)                      /* run command */
1529   char    *cs;
1530   {
# Line 1492 | Line 1549 | char   *fn;
1549          if (noaction)
1550                  return(0);
1551          return(unlink(fn));
1552 + }
1553 +
1554 +
1555 + mvfile(fold, fnew)              /* move a file */
1556 + char    *fold, *fnew;
1557 + {
1558 +        if (!silent)
1559 + #ifdef MSDOS
1560 +                printf("\trename %s %s\n", fold, fnew);
1561 + #else
1562 +                printf("\tmv %s %s\n", fold, fnew);
1563 + #endif
1564 +        if (noaction)
1565 +                return(0);
1566 +        return(rename(fold, fnew));
1567   }
1568  
1569  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines