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.41 by greg, Mon Oct 24 13:49:16 1994 UTC

# Line 117 | Line 117 | time_t oct1date;               /* date of post-mkillum octree (>= m
117   int     nowarn = 0;             /* no warnings */
118   int     explicate = 0;          /* explicate variables */
119   int     silent = 0;             /* do work silently */
120 + int     touchonly = 0;          /* touch files only */
121   int     noaction = 0;           /* don't do anything */
122   int     sayview = 0;            /* print view out */
123   char    *rvdevice = NULL;       /* rview output device */
# Line 148 | Line 149 | char   *argv[];
149                  case 'n':
150                          noaction++;
151                          break;
152 +                case 't':
153 +                        touchonly++;
154 +                        break;
155                  case 'e':
156                          explicate++;
157                          break;
# Line 199 | Line 203 | char   *argv[];
203          exit(0);
204   userr:
205          fprintf(stderr,
206 <        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
206 > "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
207                          progname);
208          exit(1);
209   }
# Line 685 | Line 689 | oconv()                                /* run oconv and mkillum if necessary */
689  
690          oconvopts(ocopts);              /* get options */
691          if (octreedate < scenedate) {   /* check date on original octree */
692 <                                                /* build command */
693 <                if (vdef(MATERIAL))
694 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
695 <                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
696 <                else
697 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
698 <                                        vval(SCENE), vval(OCTREE));
699 <                
700 <                if (runcom(combuf)) {           /* run it */
701 <                        fprintf(stderr,
692 >                if (touchonly && octreedate)
693 >                        touch(vval(OCTREE));
694 >                else {                          /* build command */
695 >                        if (vdef(MATERIAL))
696 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
697 >                                                vval(MATERIAL), vval(SCENE),
698 >                                                vval(OCTREE));
699 >                        else
700 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
701 >                                                vval(SCENE), vval(OCTREE));
702 >                        
703 >                        if (runcom(combuf)) {           /* run it */
704 >                                fprintf(stderr,
705                                  "%s: error generating octree\n\t%s removed\n",
706 <                                        progname, vval(OCTREE));
707 <                        unlink(vval(OCTREE));
708 <                        exit(1);
706 >                                                progname, vval(OCTREE));
707 >                                unlink(vval(OCTREE));
708 >                                exit(1);
709 >                        }
710                  }
711                  octreedate = time((time_t *)NULL);
712                  if (octreedate < scenedate)     /* in case clock is off */
# Line 711 | Line 719 | oconv()                                /* run oconv and mkillum if necessary */
719                  return;
720                                                  /* make octree0 */
721          if (oct0date < scenedate | oct0date < illumdate) {
722 <                                                /* build command */
722 >                if (touchonly && oct0date)
723 >                        touch(oct0name);
724 >                else {                          /* build command */
725 >                        if (octreedate)
726 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
727 >                                        vval(OCTREE), vval(ILLUM), oct0name);
728 >                        else if (vdef(MATERIAL))
729 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
730 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
731 >                        else
732 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
733 >                                        vval(ILLUM), oct0name);
734 >                        if (runcom(combuf)) {           /* run it */
735 >                                fprintf(stderr,
736 >                                "%s: error generating octree\n\t%s removed\n",
737 >                                                progname, oct0name);
738 >                                unlink(oct0name);
739 >                                exit(1);
740 >                        }
741 >                }
742 >                oct0date = time((time_t *)NULL);
743 >                if (oct0date < octreedate)      /* in case clock is off */
744 >                        oct0date = octreedate;
745 >                if (oct0date < illumdate)       /* ditto */
746 >                        oct0date = illumdate;
747 >                }
748 >        if (touchonly && oct1date)
749 >                touch(oct1name);
750 >        else {
751 >                mkillumopts(mkopts);            /* build mkillum command */
752 >                mktemp(illumtmp);
753 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
754 >                                oct0name, vval(ILLUM), illumtmp);
755 >                if (runcom(combuf)) {                   /* run it */
756 >                        fprintf(stderr, "%s: error running mkillum\n",
757 >                                        progname);
758 >                        unlink(illumtmp);
759 >                        exit(1);
760 >                }
761 >                                                /* make octree1 (frozen) */
762                  if (octreedate)
763 <                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
764 <                                vval(OCTREE), vval(ILLUM), oct0name);
763 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
764 >                                vval(OCTREE), illumtmp, oct1name);
765                  else if (vdef(MATERIAL))
766 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
767 <                                vval(MATERIAL), vval(ILLUM), oct0name);
766 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
767 >                                vval(MATERIAL), illumtmp, oct1name);
768                  else
769 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
770 <                                vval(ILLUM), oct0name);
769 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
770 >                                illumtmp, oct1name);
771                  if (runcom(combuf)) {           /* run it */
772                          fprintf(stderr,
773                                  "%s: error generating octree\n\t%s removed\n",
774 <                                        progname, oct0name);
775 <                        unlink(oct0name);
774 >                                        progname, oct1name);
775 >                        unlink(oct1name);
776                          exit(1);
777                  }
778 <                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;
778 >                rmfile(illumtmp);
779          }
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        }
780          oct1date = time((time_t *)NULL);
781          if (oct1date < oct0date)        /* in case clock is off */
782                  oct1date = oct0date;
766        rmfile(illumtmp);
783   }
784  
785  
# Line 809 | Line 825 | checkambfile()                 /* check date on ambient file */
825          if (!(afdate = fdate(vval(AMBFILE))))
826                  return;
827          if (oct1date > afdate)
828 <                rmfile(vval(AMBFILE));
828 >                if (touchonly)
829 >                        touch(vval(AMBFILE));
830 >                else
831 >                        rmfile(vval(AMBFILE));
832   }
833  
834  
# Line 1342 | Line 1361 | char   *opts, *po;
1361          char    *vw;
1362          char    combuf[512];
1363                                          /* build command */
1364 <        if ((vw = getview(0, NULL)) == NULL)
1364 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1365                  return;
1366          if (sayview)
1367                  printview(vw);
# Line 1367 | Line 1386 | char   *opts, *po;
1386          char    pfopts[128];
1387          char    vs[32], *vw;
1388          int     vn, mult;
1389 +        time_t  rfdt, pfdt;
1390                                          /* get pfilt options */
1391          pfiltopts(pfopts);
1392                                          /* get resolution, reporting */
# Line 1416 | Line 1436 | char   *opts, *po;
1436                          sprintf(vs, "%d", vn);
1437                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1438                                                  /* check date on picture */
1439 <                if (fdate(picfile) >= oct1date)
1439 >                pfdt = fdate(picfile);
1440 >                if (pfdt >= oct1date)
1441                          continue;
1442 <                                                /* build rpict command */
1442 >                                                /* get raw file name */
1443                  sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1444 <                if (fdate(rawfile) >= oct1date)         /* recover */
1444 >                rfdt = fdate(rawfile);
1445 >                if (touchonly) {                /* update times only */
1446 >                        if (rfdt) {
1447 >                                if (rfdt < oct1date)
1448 >                                        touch(rawfile);
1449 >                        } else if (pfdt && pfdt < oct1date)
1450 >                                touch(picfile);
1451 >                        continue;
1452 >                }
1453 >                                                /* build rpict command */
1454 >                if (rfdt >= oct1date)           /* recover */
1455                          sprintf(combuf, "rpict%s%s%s -ro %s %s",
1456                                          rep, po, opts, rawfile, oct1name);
1457                  else {
# Line 1465 | Line 1496 | char   *opts, *po;
1496                                                  /* remove raw file */
1497                  rmfile(rawfile);
1498          }
1499 + }
1500 +
1501 +
1502 + touch(fn)                       /* update a file */
1503 + char    *fn;
1504 + {
1505 +        if (!silent)
1506 +                printf("\ttouch %s\n", fn);
1507 +        if (noaction)
1508 +                return(0);
1509 + #ifdef notused
1510 +        if (access(fn, F_OK) == -1)             /* create it */
1511 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1512 +                        return(-1);
1513 + #endif
1514 +        return(setfdate(fn, time((time_t *)NULL)));
1515   }
1516  
1517  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines