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.49 by greg, Tue Dec 12 15:13:32 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 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 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include "standard.h"
12   #include "paths.h"
13 + #include "vars.h"
14   #include <ctype.h>
15   #include <sys/types.h>
16  
16
17 typedef struct {
18        char    *name;          /* variable name */
19        short   nick;           /* # characters required for nickname */
20        short   nass;           /* # assignments made */
21        char    *value;         /* assigned value(s) */
22        int     (*fixval)();    /* assignment checking function */
23 } VARIABLE;
24
25 int     onevalue(), catvalues(), boolvalue(),
26        qualvalue(), fltvalue(), intvalue();
27
17                                  /* variables */
18   #define OBJECT          0               /* object files */
19   #define SCENE           1               /* scene files */
# Line 38 | Line 27 | int    onevalue(), catvalues(), boolvalue(),
27   #define ZONE            9               /* simulation zone */
28   #define QUALITY         10              /* desired rendering quality */
29   #define OCTREE          11              /* octree file name */
30 < #define PICTURE         12              /* picture file name */
30 > #define PICTURE         12              /* picture file root name */
31   #define AMBFILE         13              /* ambient file name */
32   #define OPTFILE         14              /* rendering options file */
33   #define EXPOSURE        15              /* picture exposure setting */
# Line 49 | Line 38 | int    onevalue(), catvalues(), boolvalue(),
38   #define PENUMBRAS       20              /* shadow penumbras are desired */
39   #define VARIABILITY     21              /* level of light variability */
40   #define REPORT          22              /* report frequency and errfile */
41 + #define RAWFILE         23              /* raw picture file root name */
42 + #define ZFILE           24              /* distance file root name */
43                                  /* total number of variables */
44 < #define NVARS           23
44 > int NVARS = 25;
45  
46 < VARIABLE        vv[NVARS] = {           /* variable-value pairs */
46 > VARIABLE        vv[] = {                /* variable-value pairs */
47          {"objects",     3,      0,      NULL,   catvalues},
48          {"scene",       3,      0,      NULL,   catvalues},
49          {"materials",   3,      0,      NULL,   catvalues},
# Line 76 | Line 67 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
67          {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
68          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
69          {"REPORT",      3,      0,      NULL,   onevalue},
70 +        {"RAWFILE",     3,      0,      NULL,   onevalue},
71 +        {"ZFILE",       2,      0,      NULL,   onevalue},
72   };
73  
81 VARIABLE        *matchvar();
82 char    *nvalue();
83
84 #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
85
86 #define vnam(vc)        (vv[vc].name)
87 #define vdef(vc)        (vv[vc].nass)
88 #define vval(vc)        (vv[vc].value)
89 #define vint(vc)        atoi(vval(vc))
90 #define vlet(vc)        UPPER(vval(vc)[0])
91 #define vscale          vlet
92 #define vbool(vc)       (vlet(vc)=='T')
93
94 #define HIGH            'H'
95 #define MEDIUM          'M'
96 #define LOW             'L'
97
74                                  /* overture calculation file */
75   #ifdef NIX
76 < char    overfile[] = "overture.raw";
76 > char    overfile[] = "overture.unf";
77   #else
78   char    overfile[] = "/dev/null";
79   #endif
# Line 117 | Line 93 | time_t oct1date;               /* date of post-mkillum octree (>= m
93   int     nowarn = 0;             /* no warnings */
94   int     explicate = 0;          /* explicate variables */
95   int     silent = 0;             /* do work silently */
96 + int     touchonly = 0;          /* touch files only */
97   int     noaction = 0;           /* don't do anything */
98   int     sayview = 0;            /* print view out */
99   char    *rvdevice = NULL;       /* rview output device */
# Line 148 | Line 125 | char   *argv[];
125                  case 'n':
126                          noaction++;
127                          break;
128 +                case 't':
129 +                        touchonly++;
130 +                        break;
131                  case 'e':
132                          explicate++;
133                          break;
# Line 172 | Line 152 | char   *argv[];
152                                  /* assign Radiance root file name */
153          rootname(radname, rifname);
154                                  /* load variable values */
155 <        load(rifname);
155 >        loadvars(rifname);
156                                  /* get any additional assignments */
157          for (i++; i < argc; i++)
158                  setvariable(argv[i]);
# Line 184 | Line 164 | char   *argv[];
164          setdefaults();
165                                  /* print all values if requested */
166          if (explicate)
167 <                printvals();
167 >                printvars(stdout);
168                                  /* build octree (and run mkillum) */
169          oconv();
170                                  /* check date on ambient file */
# Line 199 | Line 179 | char   *argv[];
179          exit(0);
180   userr:
181          fprintf(stderr,
182 <        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
182 > "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
183                          progname);
184          exit(1);
185   }
# Line 220 | Line 200 | register char  *rn, *fn;
200   }
201  
202  
223 #define NOCHAR  127             /* constant for character to delete */
224
225
226 load(rfname)                    /* load Radiance simulation file */
227 char    *rfname;
228 {
229        FILE    *fp;
230        char    buf[512];
231        register char   *cp;
232
233        if (rfname == NULL)
234                fp = stdin;
235        else if ((fp = fopen(rfname, "r")) == NULL)
236                syserr(rfname);
237        while (fgetline(buf, sizeof(buf), fp) != NULL) {
238                for (cp = buf; *cp; cp++) {
239                        switch (*cp) {
240                        case '\\':
241                                *cp++ = NOCHAR;
242                                continue;
243                        case '#':
244                                *cp = '\0';
245                                break;
246                        default:
247                                continue;
248                        }
249                        break;
250                }
251                setvariable(buf);
252        }
253        fclose(fp);
254 }
255
256
257 setvariable(ass)                /* assign variable according to string */
258 register char   *ass;
259 {
260        char    varname[32];
261        int     n;
262        register char   *cp;
263        register VARIABLE       *vp;
264        register int    i;
265
266        while (isspace(*ass))           /* skip leading space */
267                ass++;
268        cp = varname;                   /* extract name */
269        while (cp < varname+sizeof(varname)-1
270                        && *ass && !isspace(*ass) && *ass != '=')
271                *cp++ = *ass++;
272        *cp = '\0';
273        if (!varname[0])
274                return;         /* no variable name! */
275                                        /* trim value */
276        while (isspace(*ass) || *ass == '=')
277                ass++;
278        for (n = strlen(ass); n > 0; n--)
279                if (!isspace(ass[n-1]))
280                        break;
281        if (!n && !nowarn) {
282                fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
283                                progname, varname);
284                return;
285        }
286                                        /* match variable from list */
287        vp = matchvar(varname);
288        if (vp == NULL) {
289                fprintf(stderr, "%s: unknown variable '%s'\n",
290                                progname, varname);
291                exit(1);
292        }
293                                        /* assign new value */
294        if (i = vp->nass) {
295                cp = vp->value;
296                while (i--)
297                        while (*cp++)
298                                ;
299                i = cp - vp->value;
300                vp->value = realloc(vp->value, i+n+1);
301        } else
302                vp->value = malloc(n+1);
303        if (vp->value == NULL)
304                syserr(progname);
305        cp = vp->value+i;               /* copy value, squeezing spaces */
306        *cp = *ass;
307        for (i = 1; i <= n; i++) {
308                if (ass[i] == NOCHAR)
309                        continue;
310                if (isspace(*cp))
311                        while (isspace(ass[i]))
312                                i++;
313                *++cp = ass[i];
314        }
315        if (isspace(*cp))               /* remove trailing space */
316                *cp = '\0';
317        vp->nass++;
318 }
319
320
321 VARIABLE *
322 matchvar(nam)                   /* match a variable by its name */
323 char    *nam;
324 {
325        int     n = strlen(nam);
326        register int    i;
327
328        for (i = 0; i < NVARS; i++)
329                if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n))
330                        return(vv+i);
331        return(NULL);
332 }
333
334
335 char *
336 nvalue(vp, n)                   /* return nth variable value */
337 VARIABLE        *vp;
338 register int    n;
339 {
340        register char   *cp;
341
342        if (vp == NULL | n < 0 | n >= vp->nass)
343                return(NULL);
344        cp = vp->value;
345        while (n--)
346                while (*cp++)
347                        ;
348        return(cp);
349 }
350
351
352 checkvalues()                   /* check assignments */
353 {
354        register int    i;
355
356        for (i = 0; i < NVARS; i++)
357                if (vv[i].fixval != NULL)
358                        (*vv[i].fixval)(vv+i);
359 }
360
361
362 onevalue(vp)                    /* only one assignment for this variable */
363 register VARIABLE       *vp;
364 {
365        if (vp->nass < 2)
366                return;
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;
373        while (--vp->nass > 1);
374 }
375
376
377 catvalues(vp)                   /* concatenate variable values */
378 register VARIABLE       *vp;
379 {
380        register char   *cp;
381
382        if (vp->nass < 2)
383                return;
384        for (cp = vp->value; vp->nass > 1; vp->nass--) {
385                while (*cp)
386                        cp++;
387                *cp++ = ' ';
388        }
389 }
390
391
392 int
393 badmatch(tv, cv)                /* case insensitive truncated comparison */
394 register char   *tv, *cv;
395 {
396        if (!*tv) return(1);            /* null string cannot match */
397        do
398                if (UPPER(*tv) != *cv++)
399                        return(1);
400        while (*++tv);
401        return(0);              /* OK */
402 }
403
404
405 boolvalue(vp)                   /* check boolean for legal values */
406 register VARIABLE       *vp;
407 {
408        if (!vp->nass) return;
409        onevalue(vp);
410        switch (UPPER(vp->value[0])) {
411        case 'T':
412                if (badmatch(vp->value, "TRUE")) break;
413                return;
414        case 'F':
415                if (badmatch(vp->value, "FALSE")) break;
416                return;
417        }
418        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
419                        progname, vp->name);
420        exit(1);
421 }
422
423
424 qualvalue(vp)                   /* check qualitative var. for legal values */
425 register VARIABLE       *vp;
426 {
427        if (!vp->nass) return;
428        onevalue(vp);
429        switch (UPPER(vp->value[0])) {
430        case 'L':
431                if (badmatch(vp->value, "LOW")) break;
432                return;
433        case 'M':
434                if (badmatch(vp->value, "MEDIUM")) break;
435                return;
436        case 'H':
437                if (badmatch(vp->value, "HIGH")) break;
438                return;
439        }
440        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
441                        progname, vp->name);
442        exit(1);
443 }
444
445
446 intvalue(vp)                    /* check integer variable for legal values */
447 register VARIABLE       *vp;
448 {
449        if (!vp->nass) return;
450        onevalue(vp);
451        if (isint(vp->value)) return;
452        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
453                        progname, vp->name);
454        exit(1);
455 }
456
457
458 fltvalue(vp)                    /* check float variable for legal values */
459 register VARIABLE       *vp;
460 {
461        if (!vp->nass) return;
462        onevalue(vp);
463        if (isflt(vp->value)) return;
464        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
465                        progname, vp->name);
466        exit(1);
467 }
468
469
203   time_t
204   checklast(fnames)                       /* check files and find most recent */
205   register char   *fnames;
# Line 555 | Line 288 | double org[3], *sizp;
288          extern FILE     *popen();
289          static double   oorg[3], osiz = 0.;
290          double  min[3], max[3];
291 <        char    buf[512];
291 >        char    buf[1024];
292          FILE    *fp;
293          register int    i;
294  
# Line 646 | Line 379 | setdefaults()                  /* set default values for unassigned v
379   }
380  
381  
649 printvals()                     /* print variable values */
650 {
651        int     i, j, clipline;
652        register char   *cp;
653        register int    k;
654
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
680
382   oconv()                         /* run oconv and mkillum if necessary */
383   {
384          static char     illumtmp[] = "ilXXXXXX";
385 <        char    combuf[512], ocopts[64], mkopts[64];
385 >        char    combuf[1024], ocopts[64], mkopts[64];
386  
387          oconvopts(ocopts);              /* get options */
388          if (octreedate < scenedate) {   /* check date on original octree */
389 <                                                /* build command */
390 <                if (vdef(MATERIAL))
391 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
392 <                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
393 <                else
394 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
395 <                                        vval(SCENE), vval(OCTREE));
396 <                
397 <                if (runcom(combuf)) {           /* run it */
398 <                        fprintf(stderr,
389 >                if (touchonly && octreedate)
390 >                        touch(vval(OCTREE));
391 >                else {                          /* build command */
392 >                        if (vdef(MATERIAL))
393 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
394 >                                                vval(MATERIAL), vval(SCENE),
395 >                                                vval(OCTREE));
396 >                        else
397 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
398 >                                                vval(SCENE), vval(OCTREE));
399 >                        
400 >                        if (runcom(combuf)) {           /* run it */
401 >                                fprintf(stderr,
402                                  "%s: error generating octree\n\t%s removed\n",
403 <                                        progname, vval(OCTREE));
404 <                        unlink(vval(OCTREE));
405 <                        exit(1);
403 >                                                progname, vval(OCTREE));
404 >                                unlink(vval(OCTREE));
405 >                                exit(1);
406 >                        }
407                  }
408                  octreedate = time((time_t *)NULL);
409                  if (octreedate < scenedate)     /* in case clock is off */
# Line 711 | Line 416 | oconv()                                /* run oconv and mkillum if necessary */
416                  return;
417                                                  /* make octree0 */
418          if (oct0date < scenedate | oct0date < illumdate) {
419 <                                                /* build command */
419 >                if (touchonly && oct0date)
420 >                        touch(oct0name);
421 >                else {                          /* build command */
422 >                        if (octreedate)
423 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
424 >                                        vval(OCTREE), vval(ILLUM), oct0name);
425 >                        else if (vdef(MATERIAL))
426 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
427 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
428 >                        else
429 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
430 >                                        vval(ILLUM), oct0name);
431 >                        if (runcom(combuf)) {           /* run it */
432 >                                fprintf(stderr,
433 >                                "%s: error generating octree\n\t%s removed\n",
434 >                                                progname, oct0name);
435 >                                unlink(oct0name);
436 >                                exit(1);
437 >                        }
438 >                }
439 >                oct0date = time((time_t *)NULL);
440 >                if (oct0date < octreedate)      /* in case clock is off */
441 >                        oct0date = octreedate;
442 >                if (oct0date < illumdate)       /* ditto */
443 >                        oct0date = illumdate;
444 >                }
445 >        if (touchonly && oct1date)
446 >                touch(oct1name);
447 >        else {
448 >                mkillumopts(mkopts);            /* build mkillum command */
449 >                mktemp(illumtmp);
450 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
451 >                                oct0name, vval(ILLUM), illumtmp);
452 >                if (runcom(combuf)) {                   /* run it */
453 >                        fprintf(stderr, "%s: error running mkillum\n",
454 >                                        progname);
455 >                        unlink(illumtmp);
456 >                        exit(1);
457 >                }
458 >                                                /* make octree1 (frozen) */
459                  if (octreedate)
460 <                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
461 <                                vval(OCTREE), vval(ILLUM), oct0name);
460 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
461 >                                vval(OCTREE), illumtmp, oct1name);
462                  else if (vdef(MATERIAL))
463 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
464 <                                vval(MATERIAL), vval(ILLUM), oct0name);
463 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
464 >                                vval(MATERIAL), illumtmp, oct1name);
465                  else
466 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
467 <                                vval(ILLUM), oct0name);
466 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
467 >                                illumtmp, oct1name);
468                  if (runcom(combuf)) {           /* run it */
469                          fprintf(stderr,
470                                  "%s: error generating octree\n\t%s removed\n",
471 <                                        progname, oct0name);
472 <                        unlink(oct0name);
471 >                                        progname, oct1name);
472 >                        unlink(oct1name);
473 >                        unlink(illumtmp);
474                          exit(1);
475                  }
476 <                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;
476 >                rmfile(illumtmp);
477          }
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        }
478          oct1date = time((time_t *)NULL);
479          if (oct1date < oct0date)        /* in case clock is off */
480                  oct1date = oct0date;
766        rmfile(illumtmp);
481   }
482  
483  
# Line 809 | Line 523 | checkambfile()                 /* check date on ambient file */
523          if (!(afdate = fdate(vval(AMBFILE))))
524                  return;
525          if (oct1date > afdate)
526 <                rmfile(vval(AMBFILE));
526 >                if (touchonly)
527 >                        touch(vval(AMBFILE));
528 >                else
529 >                        rmfile(vval(AMBFILE));
530   }
531  
532  
# Line 918 | Line 635 | medqopts(op, po)                       /* medium quality rendering options
635   register char   *op;
636   char    *po;
637   {
638 <        double  d, org[3], siz[3];
638 >        double  d, org[3], siz[3], asz;
639  
640          *op = '\0';
641          *po = '\0';
# Line 929 | Line 646 | char   *po;
646          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
647                  badvalue(ZONE);
648          getoctcube(org, &d);
649 <        d *= 3./(siz[0]+siz[1]+siz[2]);
649 >        asz = (siz[0]+siz[1]+siz[2])/3.;
650 >        d /= asz;
651          switch (vscale(DETAIL)) {
652          case LOW:
653                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
654                  op = addarg(op, "-dp 256");
655                  sprintf(op, " -ar %d", (int)(8*d));
656                  op += strlen(op);
657 +                sprintf(op, " -ms %.2g", asz/20.);
658 +                op += strlen(op);
659                  break;
660          case MEDIUM:
661                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
662                  op = addarg(op, "-dp 512");
663                  sprintf(op, " -ar %d", (int)(16*d));
664                  op += strlen(op);
665 +                sprintf(op, " -ms %.2g", asz/40.);
666 +                op += strlen(op);
667                  break;
668          case HIGH:
669                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
670                  op = addarg(op, "-dp 1024");
671                  sprintf(op, " -ar %d", (int)(32*d));
672                  op += strlen(op);
673 +                sprintf(op, " -ms %.2g", asz/80.);
674 +                op += strlen(op);
675                  break;
676          }
677          po = addarg(po, "-pt .08");
# Line 989 | Line 713 | hiqopts(op, po)                                /* high quality rendering options *
713   register char   *op;
714   char    *po;
715   {
716 <        double  d, org[3], siz[3];
716 >        double  d, org[3], siz[3], asz;
717  
718          *op = '\0';
719          *po = '\0';
# Line 1000 | Line 724 | char   *po;
724          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
725                  badvalue(ZONE);
726          getoctcube(org, &d);
727 <        d *= 3./(siz[0]+siz[1]+siz[2]);
727 >        asz = (siz[0]+siz[1]+siz[2])/3.;
728 >        d /= asz;
729          switch (vscale(DETAIL)) {
730          case LOW:
731                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
732                  op = addarg(op, "-dp 1024");
733                  sprintf(op, " -ar %d", (int)(16*d));
734                  op += strlen(op);
735 +                sprintf(op, " -ms %.2g", asz/40.);
736 +                op += strlen(op);
737                  break;
738          case MEDIUM:
739                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
740                  op = addarg(op, "-dp 2048");
741                  sprintf(op, " -ar %d", (int)(32*d));
742                  op += strlen(op);
743 +                sprintf(op, " -ms %.2g", asz/80.);
744 +                op += strlen(op);
745                  break;
746          case HIGH:
747                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
748                  op = addarg(op, "-dp 4096");
749                  sprintf(op, " -ar %d", (int)(64*d));
750                  op += strlen(op);
751 +                sprintf(op, " -ms %.2g", asz/160.);
752 +                op += strlen(op);
753                  break;
754          }
755          po = addarg(po, "-pt .04");
756          if (vbool(PENUMBRAS))
757 <                op = addarg(op, "-ds .1 -dj .7");
757 >                op = addarg(op, "-ds .1 -dj .65");
758          else
759                  op = addarg(op, "-ds .2");
760          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1065 | Line 796 | char   *ro;
796                  return;
797          if (vdef(OPTFILE)) {
798                  for (cp = ro; cp[1]; cp++)
799 <                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
799 >                        if (isspace(cp[1]) && (cp[2] == '@' ||
800 >                                        (cp[2] == '-' && isalpha(cp[3]))))
801                                  *cp = '\n';
802                          else
803                                  *cp = cp[1];
# Line 1160 | Line 892 | register char  *vs;
892                  zpos = -1; vs++;
893          }
894          viewtype = 'v';
895 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
895 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
896                  viewtype = *vs++;
897          cp = viewopts;
898          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1215 | Line 947 | register char  *vs;
947                  case 'h':
948                          cp = addarg(cp, "-vh 180 -vv 180");
949                          break;
950 +                case 'c':
951 +                        cp = addarg(cp, "-vh 180 -vv 90");
952 +                        break;
953                  }
954          } else {
955                  while (!isspace(*vs))           /* else skip id */
# Line 1342 | Line 1077 | char   *opts, *po;
1077          char    *vw;
1078          char    combuf[512];
1079                                          /* build command */
1080 <        if ((vw = getview(0, NULL)) == NULL)
1080 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1081                  return;
1082          if (sayview)
1083                  printview(vw);
# Line 1363 | Line 1098 | rpict(opts, po)                                /* run rpict and pfilt for each vie
1098   char    *opts, *po;
1099   {
1100          char    combuf[1024];
1101 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1101 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1102 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1103          char    pfopts[128];
1104          char    vs[32], *vw;
1105          int     vn, mult;
1106 +        time_t  rfdt, pfdt;
1107                                          /* get pfilt options */
1108          pfiltopts(pfopts);
1109                                          /* get resolution, reporting */
# Line 1415 | Line 1152 | char   *opts, *po;
1152                  if (!vs[0])
1153                          sprintf(vs, "%d", vn);
1154                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1155 +                if (vdef(ZFILE))
1156 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1157 +                else
1158 +                        zopt[0] = '\0';
1159                                                  /* check date on picture */
1160 <                if (fdate(picfile) >= oct1date)
1160 >                pfdt = fdate(picfile);
1161 >                if (pfdt >= oct1date)
1162                          continue;
1163 +                                                /* get raw file name */
1164 +                sprintf(rawfile, "%s_%s.unf",
1165 +                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1166 +                rfdt = fdate(rawfile);
1167 +                if (touchonly) {                /* update times only */
1168 +                        if (rfdt) {
1169 +                                if (rfdt < oct1date)
1170 +                                        touch(rawfile);
1171 +                        } else if (pfdt && pfdt < oct1date)
1172 +                                touch(picfile);
1173 +                        continue;
1174 +                }
1175                                                  /* build rpict command */
1176 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1177 <                if (fdate(rawfile) >= oct1date)         /* recover */
1178 <                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1425 <                                        rep, po, opts, rawfile, oct1name);
1176 >                if (rfdt >= oct1date)           /* recover */
1177 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1178 >                                rep, po, opts, zopt, rawfile, oct1name);
1179                  else {
1180                          if (overture) {         /* run overture calculation */
1181                                  sprintf(combuf,
# Line 1439 | Line 1192 | char   *opts, *po;
1192                                  rmfile(overfile);
1193   #endif
1194                          }
1195 <                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1196 <                                        rep, vw, res, po, opts,
1197 <                                oct1name, rawfile);
1195 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1196 >                                        rep, vw, res, po, opts, zopt,
1197 >                                        oct1name, rawfile);
1198                  }
1199                  if (runcom(combuf)) {           /* run rpict */
1200                          fprintf(stderr, "%s: error rendering view %s\n",
1201                                          progname, vs);
1202                          exit(1);
1203                  }
1204 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1205                                                  /* build pfilt command */
1206 <                if (mult > 1)
1207 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1206 >                        if (mult > 1)
1207 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1208                                          pfopts, mult, mult, rawfile, picfile);
1209 <                else
1210 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1211 <                                        rawfile, picfile);
1212 <                if (runcom(combuf)) {           /* run pfilt */
1213 <                        fprintf(stderr,
1214 <                        "%s: error filtering view %s\n\t%s removed\n",
1215 <                                        progname, vs, picfile);
1216 <                        unlink(picfile);
1217 <                        exit(1);
1209 >                        else
1210 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1211 >                                                rawfile, picfile);
1212 >                        if (runcom(combuf)) {           /* run pfilt */
1213 >                                fprintf(stderr,
1214 >                                "%s: error filtering view %s\n\t%s removed\n",
1215 >                                                progname, vs, picfile);
1216 >                                unlink(picfile);
1217 >                                exit(1);
1218 >                        }
1219                  }
1220 <                                                /* remove raw file */
1221 <                rmfile(rawfile);
1220 >                                                /* remove/rename raw file */
1221 >                if (vdef(RAWFILE)) {
1222 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1223 >                        mvfile(rawfile, combuf);
1224 >                } else
1225 >                        rmfile(rawfile);
1226          }
1227   }
1228  
1229  
1230 + touch(fn)                       /* update a file */
1231 + char    *fn;
1232 + {
1233 +        if (!silent)
1234 +                printf("\ttouch %s\n", fn);
1235 +        if (noaction)
1236 +                return(0);
1237 + #ifdef notused
1238 +        if (access(fn, F_OK) == -1)             /* create it */
1239 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1240 +                        return(-1);
1241 + #endif
1242 +        return(setfdate(fn, time((time_t *)NULL)));
1243 + }
1244 +
1245 +
1246   runcom(cs)                      /* run command */
1247   char    *cs;
1248   {
# Line 1492 | Line 1267 | char   *fn;
1267          if (noaction)
1268                  return(0);
1269          return(unlink(fn));
1270 + }
1271 +
1272 +
1273 + mvfile(fold, fnew)              /* move a file */
1274 + char    *fold, *fnew;
1275 + {
1276 +        if (!silent)
1277 + #ifdef MSDOS
1278 +                printf("\trename %s %s\n", fold, fnew);
1279 + #else
1280 +                printf("\tmv %s %s\n", fold, fnew);
1281 + #endif
1282 +        if (noaction)
1283 +                return(0);
1284 +        return(rename(fold, fnew));
1285   }
1286  
1287  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines