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.46 by greg, Tue Nov 7 18:22:24 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1995 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 37 | 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 48 | 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 75 | 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 96 | 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
108  
109 < extern unsigned long    fdate(), time();
109 > extern time_t   fdate(), time();
110  
111 < unsigned long   scenedate;      /* date of latest scene or object file */
112 < unsigned long   octreedate;     /* date of octree */
113 < unsigned long   matdate;        /* date of latest material file */
114 < unsigned long   illumdate;      /* date of last illum file */
111 > time_t  scenedate;              /* date of latest scene or object file */
112 > time_t  octreedate;             /* date of octree */
113 > time_t  matdate;                /* date of latest material file */
114 > time_t  illumdate;              /* date of last illum file */
115  
116   char    *oct0name;              /* name of pre-mkillum octree */
117 < unsigned long   oct0date;       /* date of pre-mkillum octree */
117 > time_t  oct0date;               /* date of pre-mkillum octree */
118   char    *oct1name;              /* name of post-mkillum octree */
119 < unsigned long   oct1date;       /* date of post-mkillum octree (>= matdate) */
119 > time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
120  
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 133 | Line 140 | int    argc;
140   char    *argv[];
141   {
142          char    ropts[512];
143 +        char    popts[64];
144          int     i;
145  
146          progname = argv[0];
# Line 145 | 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 157 | Line 168 | char   *argv[];
168                  case 'v':
169                          viewselect = argv[++i];
170                          break;
171 +                case 'w':
172 +                        nowarn++;
173 +                        break;
174                  default:
175                          goto userr;
176                  }
# Line 184 | Line 198 | char   *argv[];
198                                  /* check date on ambient file */
199          checkambfile();
200                                  /* run simulation */
201 <        renderopts(ropts);
201 >        renderopts(ropts, popts);
202          xferopts(ropts);
203          if (rvdevice != NULL)
204 <                rview(ropts);
204 >                rview(ropts, popts);
205          else
206 <                rpict(ropts);
206 >                rpict(ropts, popts);
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 272 | Line 286 | register char  *ass;
286          for (n = strlen(ass); n > 0; n--)
287                  if (!isspace(ass[n-1]))
288                          break;
289 <        if (!n) {
289 >        if (!n && !nowarn) {
290                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
291                                  progname, varname);
292                  return;
# Line 358 | Line 372 | register VARIABLE      *vp;
372   {
373          if (vp->nass < 2)
374                  return;
375 <        fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
375 >        if (!nowarn)
376 >                fprintf(stderr,
377 >                "%s: warning - multiple assignment of variable '%s'\n",
378                          progname, vp->name);
379          do
380                  vp->value += strlen(vp->value)+1;
# Line 459 | Line 475 | register VARIABLE      *vp;
475   }
476  
477  
478 < unsigned long
478 > time_t
479   checklast(fnames)                       /* check files and find most recent */
480   register char   *fnames;
481   {
482          char    thisfile[MAXPATH];
483 <        unsigned long   thisdate, lastdate = 0;
483 >        time_t  thisdate, lastdate = 0;
484          register char   *cp;
485  
486          if (fnames == NULL)
# Line 512 | Line 528 | int    pred;
528  
529   checkfiles()                    /* check for existence and modified times */
530   {
531 <        unsigned long   objdate;
531 >        time_t  objdate;
532  
533          if (!vdef(OCTREE)) {
534                  if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
# Line 547 | Line 563 | double org[3], *sizp;
563          extern FILE     *popen();
564          static double   oorg[3], osiz = 0.;
565          double  min[3], max[3];
566 <        char    buf[512];
566 >        char    buf[1024];
567          FILE    *fp;
568          register int    i;
569  
# Line 640 | Line 656 | setdefaults()                  /* set default values for unassigned v
656  
657   printvals()                     /* print variable values */
658   {
659 <        register int    i, j;
659 >        int     i, j, clipline;
660 >        register char   *cp;
661 >        register int    k;
662  
663 <        for (i = 0; i < NVARS; i++)
664 <                for (j = 0; j < vdef(i); j++)
665 <                        printf("%s= %s\n", vnam(i), nvalue(vv+i, j));
663 >        for (i = 0; i < NVARS; i++)             /* print each variable */
664 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
665 >                fputs(vnam(i), stdout);
666 >                fputs("= ", stdout);
667 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
668 >                                - strlen(vnam(i)) ;
669 >                cp = nvalue(vv+i, j);
670 >                while (*cp) {
671 >                    putchar(*cp++);
672 >                    if (--k <= 0) {             /* line too long */
673 >                        while (*cp && !isspace(*cp))
674 >                            putchar(*cp++);     /* finish this word */
675 >                        if (*cp) {              /* start new line */
676 >                            putchar('\n');
677 >                            fputs(vnam(i), stdout);
678 >                            putchar('=');
679 >                            k = clipline;
680 >                        }
681 >                    }
682 >                }
683 >                putchar('\n');
684 >            }
685          fflush(stdout);
686   }
687  
# Line 652 | Line 689 | printvals()                    /* print variable values */
689   oconv()                         /* run oconv and mkillum if necessary */
690   {
691          static char     illumtmp[] = "ilXXXXXX";
692 <        char    combuf[512], ocopts[64], mkopts[64];
692 >        char    combuf[1024], ocopts[64], mkopts[64];
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(0);
715 >                octreedate = time((time_t *)NULL);
716 >                if (octreedate < scenedate)     /* in case clock is off */
717 >                        octreedate = scenedate;
718          }
719          if (oct1name == vval(OCTREE))           /* no mkillum? */
720                  oct1date = octreedate > matdate ? octreedate : matdate;
# Line 680 | 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 >                        unlink(illumtmp);
781                          exit(1);
782                  }
783 <                oct0date = time(0);
783 >                rmfile(illumtmp);
784          }
785 <        mkillumopts(mkopts);                    /* build mkillum command */
786 <        mktemp(illumtmp);
787 <        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
705 <                        oct0name, vval(ILLUM), illumtmp);
706 <        if (runcom(combuf)) {                   /* run it */
707 <                fprintf(stderr, "%s: error running mkillum\n", progname);
708 <                unlink(illumtmp);
709 <                exit(1);
710 <        }
711 <                                                /* make octree1 (frozen) */
712 <        if (octreedate)
713 <                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
714 <                        vval(OCTREE), illumtmp, oct1name);
715 <        else if (vdef(MATERIAL))
716 <                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
717 <                        vval(MATERIAL), illumtmp, oct1name);
718 <        else
719 <                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
720 <                        illumtmp, oct1name);
721 <        if (runcom(combuf)) {           /* run it */
722 <                fprintf(stderr,
723 <                        "%s: error generating octree\n\t%s removed\n",
724 <                                progname, oct1name);
725 <                unlink(oct1name);
726 <                exit(1);
727 <        }
728 <        oct1date = time(0);
729 <        rmfile(illumtmp);
785 >        oct1date = time((time_t *)NULL);
786 >        if (oct1date < oct0date)        /* in case clock is off */
787 >                oct1date = oct0date;
788   }
789  
790  
# Line 765 | Line 823 | register char  *mo;
823  
824   checkambfile()                  /* check date on ambient file */
825   {
826 <        unsigned long   afdate;
826 >        time_t  afdate;
827  
828          if (!vdef(AMBFILE))
829                  return;
830          if (!(afdate = fdate(vval(AMBFILE))))
831                  return;
832          if (oct1date > afdate)
833 <                rmfile(vval(AMBFILE));
833 >                if (touchonly)
834 >                        touch(vval(AMBFILE));
835 >                else
836 >                        rmfile(vval(AMBFILE));
837   }
838  
839  
# Line 792 | Line 853 | ambval()                               /* compute ambient value */
853   }
854  
855  
856 < renderopts(op)                          /* set rendering options */
857 < char    *op;
856 > renderopts(op, po)                      /* set rendering options */
857 > char    *op, *po;
858   {
859          switch(vscale(QUALITY)) {
860          case LOW:
861 <                lowqopts(op);
861 >                lowqopts(op, po);
862                  break;
863          case MEDIUM:
864 <                medqopts(op);
864 >                medqopts(op, po);
865                  break;
866          case HIGH:
867 <                hiqopts(op);
867 >                hiqopts(op, po);
868                  break;
869          }
870   }
871  
872  
873 < lowqopts(op)                            /* low quality rendering options */
873 > lowqopts(op, po)                        /* low quality rendering options */
874   register char   *op;
875 + char    *po;
876   {
877          double  d, org[3], siz[3];
878  
879          *op = '\0';
880 +        *po = '\0';
881          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
882                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
883                  badvalue(ZONE);
884          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
885 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
886 +                badvalue(ZONE);
887          getoctcube(org, &d);
888          d *= 3./(siz[0]+siz[1]+siz[2]);
889          switch (vscale(DETAIL)) {
890          case LOW:
891 <                op = addarg(op, "-ps 16 -dp 64");
891 >                po = addarg(po, "-ps 16");
892 >                op = addarg(op, "-dp 64");
893                  sprintf(op, " -ar %d", (int)(4*d));
894                  op += strlen(op);
895                  break;
896          case MEDIUM:
897 <                op = addarg(op, "-ps 8 -dp 128");
897 >                po = addarg(po, "-ps 8");
898 >                op = addarg(op, "-dp 128");
899                  sprintf(op, " -ar %d", (int)(8*d));
900                  op += strlen(op);
901                  break;
902          case HIGH:
903 <                op = addarg(op, "-ps 4 -dp 256");
903 >                po = addarg(po, "-ps 4");
904 >                op = addarg(op, "-dp 256");
905                  sprintf(op, " -ar %d", (int)(16*d));
906                  op += strlen(op);
907                  break;
908          }
909 <        op = addarg(op, "-pt .16");
909 >        po = addarg(po, "-pt .16");
910          if (vbool(PENUMBRAS))
911                  op = addarg(op, "-ds .4");
912          else
# Line 870 | Line 938 | register char  *op;
938   }
939  
940  
941 < medqopts(op)                            /* medium quality rendering options */
941 > medqopts(op, po)                        /* medium quality rendering options */
942   register char   *op;
943 + char    *po;
944   {
945          double  d, org[3], siz[3];
946  
947          *op = '\0';
948 +        *po = '\0';
949          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
950                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
951                  badvalue(ZONE);
952          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
953 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
954 +                badvalue(ZONE);
955          getoctcube(org, &d);
956          d *= 3./(siz[0]+siz[1]+siz[2]);
957          switch (vscale(DETAIL)) {
958          case LOW:
959 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
959 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
960                  op = addarg(op, "-dp 256");
961                  sprintf(op, " -ar %d", (int)(8*d));
962                  op += strlen(op);
963                  break;
964          case MEDIUM:
965 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
965 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
966                  op = addarg(op, "-dp 512");
967                  sprintf(op, " -ar %d", (int)(16*d));
968                  op += strlen(op);
969                  break;
970          case HIGH:
971 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
971 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
972                  op = addarg(op, "-dp 1024");
973                  sprintf(op, " -ar %d", (int)(32*d));
974                  op += strlen(op);
975                  break;
976          }
977 <        op = addarg(op, "-pt .08");
977 >        po = addarg(po, "-pt .08");
978          if (vbool(PENUMBRAS))
979                  op = addarg(op, "-ds .2 -dj .5");
980          else
# Line 937 | Line 1009 | register char  *op;
1009   }
1010  
1011  
1012 < hiqopts(op)                             /* high quality rendering options */
1012 > hiqopts(op, po)                         /* high quality rendering options */
1013   register char   *op;
1014 + char    *po;
1015   {
1016          double  d, org[3], siz[3];
1017  
1018          *op = '\0';
1019 +        *po = '\0';
1020          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
1021                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
1022                  badvalue(ZONE);
1023          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
1024 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
1025 +                badvalue(ZONE);
1026          getoctcube(org, &d);
1027          d *= 3./(siz[0]+siz[1]+siz[2]);
1028          switch (vscale(DETAIL)) {
1029          case LOW:
1030 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1030 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1031                  op = addarg(op, "-dp 1024");
1032                  sprintf(op, " -ar %d", (int)(16*d));
1033                  op += strlen(op);
1034                  break;
1035          case MEDIUM:
1036 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1036 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1037                  op = addarg(op, "-dp 2048");
1038                  sprintf(op, " -ar %d", (int)(32*d));
1039                  op += strlen(op);
1040                  break;
1041          case HIGH:
1042 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1042 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1043                  op = addarg(op, "-dp 4096");
1044                  sprintf(op, " -ar %d", (int)(64*d));
1045                  op += strlen(op);
1046                  break;
1047          }
1048 <        op = addarg(op, "-pt .04");
1048 >        po = addarg(po, "-pt .04");
1049          if (vbool(PENUMBRAS))
1050 <                op = addarg(op, "-ds .1 -dj .7");
1050 >                op = addarg(op, "-ds .1 -dj .65");
1051          else
1052                  op = addarg(op, "-ds .2");
1053          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1108 | Line 1184 | register char  *vs;
1184                  zpos = -1; vs++;
1185          }
1186          viewtype = 'v';
1187 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
1187 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
1188                  viewtype = *vs++;
1189          cp = viewopts;
1190          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1119 | Line 1195 | register char  *vs;
1195                          badvalue(ZONE);
1196                  for (i = 0; i < 3; i++) {
1197                          dim[i] -= cent[i];
1198 +                        if (dim[i] <= FTINY)
1199 +                                badvalue(ZONE);
1200                          cent[i] += .5*dim[i];
1201                  }
1202                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
# Line 1161 | Line 1239 | register char  *vs;
1239                  case 'h':
1240                          cp = addarg(cp, "-vh 180 -vv 180");
1241                          break;
1242 +                case 'c':
1243 +                        cp = addarg(cp, "-vh 180 -vv 90");
1244 +                        break;
1245                  }
1246          } else {
1247                  while (!isspace(*vs))           /* else skip id */
# Line 1282 | Line 1363 | register char  *vopts;
1363   }
1364  
1365  
1366 < rview(opts)                             /* run rview with first view */
1367 < char    *opts;
1366 > rview(opts, po)                         /* run rview with first view */
1367 > char    *opts, *po;
1368   {
1369          char    *vw;
1370          char    combuf[512];
1371                                          /* build command */
1372 <        if ((vw = getview(0, NULL)) == NULL)
1372 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1373                  return;
1374          if (sayview)
1375                  printview(vw);
1376 <        sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname);
1376 >        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1377          if (rvdevice != NULL)
1378                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1379          if (vdef(EXPOSURE))
# Line 1305 | Line 1386 | char   *opts;
1386   }
1387  
1388  
1389 < rpict(opts)                             /* run rpict and pfilt for each view */
1390 < char    *opts;
1389 > rpict(opts, po)                         /* run rpict and pfilt for each view */
1390 > char    *opts, *po;
1391   {
1392          char    combuf[1024];
1393 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1393 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1394 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1395          char    pfopts[128];
1396          char    vs[32], *vw;
1397          int     vn, mult;
1398 +        time_t  rfdt, pfdt;
1399                                          /* get pfilt options */
1400          pfiltopts(pfopts);
1401                                          /* get resolution, reporting */
# Line 1361 | Line 1444 | char   *opts;
1444                  if (!vs[0])
1445                          sprintf(vs, "%d", vn);
1446                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1447 +                if (vdef(ZFILE))
1448 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1449 +                else
1450 +                        zopt[0] = '\0';
1451                                                  /* check date on picture */
1452 <                if (fdate(picfile) >= oct1date)
1452 >                pfdt = fdate(picfile);
1453 >                if (pfdt >= oct1date)
1454                          continue;
1455 +                                                /* get raw file name */
1456 +                sprintf(rawfile, "%s_%s.unf",
1457 +                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1458 +                rfdt = fdate(rawfile);
1459 +                if (touchonly) {                /* update times only */
1460 +                        if (rfdt) {
1461 +                                if (rfdt < oct1date)
1462 +                                        touch(rawfile);
1463 +                        } else if (pfdt && pfdt < oct1date)
1464 +                                touch(picfile);
1465 +                        continue;
1466 +                }
1467                                                  /* build rpict command */
1468 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1469 <                if (fdate(rawfile) >= oct1date)         /* recover */
1470 <                        sprintf(combuf, "rpict%s%s -ro %s %s",
1371 <                                        rep, opts, rawfile, oct1name);
1468 >                if (rfdt >= oct1date)           /* recover */
1469 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1470 >                                rep, po, opts, zopt, rawfile, oct1name);
1471                  else {
1472                          if (overture) {         /* run overture calculation */
1473                                  sprintf(combuf,
# Line 1385 | Line 1484 | char   *opts;
1484                                  rmfile(overfile);
1485   #endif
1486                          }
1487 <                        sprintf(combuf, "rpict%s %s %s%s %s > %s",
1488 <                                        rep, vw, res, opts,
1489 <                                oct1name, rawfile);
1487 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1488 >                                        rep, vw, res, po, opts, zopt,
1489 >                                        oct1name, rawfile);
1490                  }
1491                  if (runcom(combuf)) {           /* run rpict */
1492                          fprintf(stderr, "%s: error rendering view %s\n",
1493                                          progname, vs);
1494                          exit(1);
1495                  }
1496 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1497                                                  /* build pfilt command */
1498 <                if (mult > 1)
1499 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1498 >                        if (mult > 1)
1499 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1500                                          pfopts, mult, mult, rawfile, picfile);
1501 <                else
1502 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1503 <                                        rawfile, picfile);
1504 <                if (runcom(combuf)) {           /* run pfilt */
1505 <                        fprintf(stderr,
1506 <                        "%s: error filtering view %s\n\t%s removed\n",
1507 <                                        progname, vs, picfile);
1508 <                        unlink(picfile);
1509 <                        exit(1);
1501 >                        else
1502 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1503 >                                                rawfile, picfile);
1504 >                        if (runcom(combuf)) {           /* run pfilt */
1505 >                                fprintf(stderr,
1506 >                                "%s: error filtering view %s\n\t%s removed\n",
1507 >                                                progname, vs, picfile);
1508 >                                unlink(picfile);
1509 >                                exit(1);
1510 >                        }
1511                  }
1512 <                                                /* remove raw file */
1513 <                rmfile(rawfile);
1512 >                                                /* remove/rename raw file */
1513 >                if (vdef(RAWFILE)) {
1514 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1515 >                        mvfile(rawfile, combuf);
1516 >                } else
1517 >                        rmfile(rawfile);
1518          }
1519   }
1520  
1521  
1522 + touch(fn)                       /* update a file */
1523 + char    *fn;
1524 + {
1525 +        if (!silent)
1526 +                printf("\ttouch %s\n", fn);
1527 +        if (noaction)
1528 +                return(0);
1529 + #ifdef notused
1530 +        if (access(fn, F_OK) == -1)             /* create it */
1531 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1532 +                        return(-1);
1533 + #endif
1534 +        return(setfdate(fn, time((time_t *)NULL)));
1535 + }
1536 +
1537 +
1538   runcom(cs)                      /* run command */
1539   char    *cs;
1540   {
# Line 1438 | Line 1559 | char   *fn;
1559          if (noaction)
1560                  return(0);
1561          return(unlink(fn));
1562 + }
1563 +
1564 +
1565 + mvfile(fold, fnew)              /* move a file */
1566 + char    *fold, *fnew;
1567 + {
1568 +        if (!silent)
1569 + #ifdef MSDOS
1570 +                printf("\trename %s %s\n", fold, fnew);
1571 + #else
1572 +                printf("\tmv %s %s\n", fold, fnew);
1573 + #endif
1574 +        if (noaction)
1575 +                return(0);
1576 +        return(rename(fold, fnew));
1577   }
1578  
1579  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines