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.41 by greg, Mon Oct 24 13:49:16 1994 UTC vs.
Revision 2.53 by greg, Thu Mar 20 12:50:07 1997 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 176 | 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]);
158 >                if (setvariable(argv[i], matchvar) < 0) {
159 >                        fprintf(stderr, "%s: unknown variable: %s\n",
160 >                                        progname, argv[i]);
161 >                        quit(1);
162 >                }
163                                  /* check assignments */
164          checkvalues();
165                                  /* check files and dates */
# Line 188 | Line 168 | char   *argv[];
168          setdefaults();
169                                  /* print all values if requested */
170          if (explicate)
171 <                printvals();
171 >                printvars(stdout);
172                                  /* build octree (and run mkillum) */
173          oconv();
174                                  /* check date on ambient file */
# Line 200 | Line 180 | char   *argv[];
180                  rview(ropts, popts);
181          else
182                  rpict(ropts, popts);
183 <        exit(0);
183 >        quit(0);
184   userr:
185          fprintf(stderr,
186   "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
187                          progname);
188 <        exit(1);
188 >        quit(1);
189   }
190  
191  
# Line 224 | Line 204 | register char  *rn, *fn;
204   }
205  
206  
227 #define NOCHAR  127             /* constant for character to delete */
228
229
230 load(rfname)                    /* load Radiance simulation file */
231 char    *rfname;
232 {
233        FILE    *fp;
234        char    buf[512];
235        register char   *cp;
236
237        if (rfname == NULL)
238                fp = stdin;
239        else if ((fp = fopen(rfname, "r")) == NULL)
240                syserr(rfname);
241        while (fgetline(buf, sizeof(buf), fp) != NULL) {
242                for (cp = buf; *cp; cp++) {
243                        switch (*cp) {
244                        case '\\':
245                                *cp++ = NOCHAR;
246                                continue;
247                        case '#':
248                                *cp = '\0';
249                                break;
250                        default:
251                                continue;
252                        }
253                        break;
254                }
255                setvariable(buf);
256        }
257        fclose(fp);
258 }
259
260
261 setvariable(ass)                /* assign variable according to string */
262 register char   *ass;
263 {
264        char    varname[32];
265        int     n;
266        register char   *cp;
267        register VARIABLE       *vp;
268        register int    i;
269
270        while (isspace(*ass))           /* skip leading space */
271                ass++;
272        cp = varname;                   /* extract name */
273        while (cp < varname+sizeof(varname)-1
274                        && *ass && !isspace(*ass) && *ass != '=')
275                *cp++ = *ass++;
276        *cp = '\0';
277        if (!varname[0])
278                return;         /* no variable name! */
279                                        /* trim value */
280        while (isspace(*ass) || *ass == '=')
281                ass++;
282        for (n = strlen(ass); n > 0; n--)
283                if (!isspace(ass[n-1]))
284                        break;
285        if (!n && !nowarn) {
286                fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
287                                progname, varname);
288                return;
289        }
290                                        /* match variable from list */
291        vp = matchvar(varname);
292        if (vp == NULL) {
293                fprintf(stderr, "%s: unknown variable '%s'\n",
294                                progname, varname);
295                exit(1);
296        }
297                                        /* assign new value */
298        if (i = vp->nass) {
299                cp = vp->value;
300                while (i--)
301                        while (*cp++)
302                                ;
303                i = cp - vp->value;
304                vp->value = realloc(vp->value, i+n+1);
305        } else
306                vp->value = malloc(n+1);
307        if (vp->value == NULL)
308                syserr(progname);
309        cp = vp->value+i;               /* copy value, squeezing spaces */
310        *cp = *ass;
311        for (i = 1; i <= n; i++) {
312                if (ass[i] == NOCHAR)
313                        continue;
314                if (isspace(*cp))
315                        while (isspace(ass[i]))
316                                i++;
317                *++cp = ass[i];
318        }
319        if (isspace(*cp))               /* remove trailing space */
320                *cp = '\0';
321        vp->nass++;
322 }
323
324
325 VARIABLE *
326 matchvar(nam)                   /* match a variable by its name */
327 char    *nam;
328 {
329        int     n = strlen(nam);
330        register int    i;
331
332        for (i = 0; i < NVARS; i++)
333                if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n))
334                        return(vv+i);
335        return(NULL);
336 }
337
338
339 char *
340 nvalue(vp, n)                   /* return nth variable value */
341 VARIABLE        *vp;
342 register int    n;
343 {
344        register char   *cp;
345
346        if (vp == NULL | n < 0 | n >= vp->nass)
347                return(NULL);
348        cp = vp->value;
349        while (n--)
350                while (*cp++)
351                        ;
352        return(cp);
353 }
354
355
356 checkvalues()                   /* check assignments */
357 {
358        register int    i;
359
360        for (i = 0; i < NVARS; i++)
361                if (vv[i].fixval != NULL)
362                        (*vv[i].fixval)(vv+i);
363 }
364
365
366 onevalue(vp)                    /* only one assignment for this variable */
367 register VARIABLE       *vp;
368 {
369        if (vp->nass < 2)
370                return;
371        if (!nowarn)
372                fprintf(stderr,
373                "%s: warning - multiple assignment of variable '%s'\n",
374                        progname, vp->name);
375        do
376                vp->value += strlen(vp->value)+1;
377        while (--vp->nass > 1);
378 }
379
380
381 catvalues(vp)                   /* concatenate variable values */
382 register VARIABLE       *vp;
383 {
384        register char   *cp;
385
386        if (vp->nass < 2)
387                return;
388        for (cp = vp->value; vp->nass > 1; vp->nass--) {
389                while (*cp)
390                        cp++;
391                *cp++ = ' ';
392        }
393 }
394
395
396 int
397 badmatch(tv, cv)                /* case insensitive truncated comparison */
398 register char   *tv, *cv;
399 {
400        if (!*tv) return(1);            /* null string cannot match */
401        do
402                if (UPPER(*tv) != *cv++)
403                        return(1);
404        while (*++tv);
405        return(0);              /* OK */
406 }
407
408
409 boolvalue(vp)                   /* check boolean for legal values */
410 register VARIABLE       *vp;
411 {
412        if (!vp->nass) return;
413        onevalue(vp);
414        switch (UPPER(vp->value[0])) {
415        case 'T':
416                if (badmatch(vp->value, "TRUE")) break;
417                return;
418        case 'F':
419                if (badmatch(vp->value, "FALSE")) break;
420                return;
421        }
422        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
423                        progname, vp->name);
424        exit(1);
425 }
426
427
428 qualvalue(vp)                   /* check qualitative var. for legal values */
429 register VARIABLE       *vp;
430 {
431        if (!vp->nass) return;
432        onevalue(vp);
433        switch (UPPER(vp->value[0])) {
434        case 'L':
435                if (badmatch(vp->value, "LOW")) break;
436                return;
437        case 'M':
438                if (badmatch(vp->value, "MEDIUM")) break;
439                return;
440        case 'H':
441                if (badmatch(vp->value, "HIGH")) break;
442                return;
443        }
444        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
445                        progname, vp->name);
446        exit(1);
447 }
448
449
450 intvalue(vp)                    /* check integer variable for legal values */
451 register VARIABLE       *vp;
452 {
453        if (!vp->nass) return;
454        onevalue(vp);
455        if (isint(vp->value)) return;
456        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
457                        progname, vp->name);
458        exit(1);
459 }
460
461
462 fltvalue(vp)                    /* check float variable for legal values */
463 register VARIABLE       *vp;
464 {
465        if (!vp->nass) return;
466        onevalue(vp);
467        if (isflt(vp->value)) return;
468        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
469                        progname, vp->name);
470        exit(1);
471 }
472
473
207   time_t
208   checklast(fnames)                       /* check files and find most recent */
209   register char   *fnames;
# Line 547 | Line 280 | checkfiles()                   /* check for existence and modified tim
280          if (!octreedate & !scenedate & !illumdate) {
281                  fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
282                                  vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
283 <                exit(1);
283 >                quit(1);
284          }
285          matdate = checklast(vval(MATERIAL));
286   }      
# Line 559 | Line 292 | double org[3], *sizp;
292          extern FILE     *popen();
293          static double   oorg[3], osiz = 0.;
294          double  min[3], max[3];
295 <        char    buf[512];
295 >        char    buf[1024];
296          FILE    *fp;
297          register int    i;
298  
# Line 577 | Line 310 | double org[3], *sizp;
310                                  fprintf(stderr,
311                          "%s: error reading bounding box from getbbox\n",
312                                                  progname);
313 <                                exit(1);
313 >                                quit(1);
314                          }
315                          for (i = 0; i < 3; i++)
316                                  if (max[i] - min[i] > osiz)
# Line 595 | Line 328 | double org[3], *sizp;
328                                  fprintf(stderr,
329                          "%s: error reading bounding cube from getinfo\n",
330                                                  progname);
331 <                                exit(1);
331 >                                quit(1);
332                          }
333                          pclose(fp);
334                  }
# Line 650 | Line 383 | setdefaults()                  /* set default values for unassigned v
383   }
384  
385  
653 printvals()                     /* print variable values */
654 {
655        int     i, j, clipline;
656        register char   *cp;
657        register int    k;
658
659        for (i = 0; i < NVARS; i++)             /* print each variable */
660            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
661                fputs(vnam(i), stdout);
662                fputs("= ", stdout);
663                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
664                                - strlen(vnam(i)) ;
665                cp = nvalue(vv+i, j);
666                while (*cp) {
667                    putchar(*cp++);
668                    if (--k <= 0) {             /* line too long */
669                        while (*cp && !isspace(*cp))
670                            putchar(*cp++);     /* finish this word */
671                        if (*cp) {              /* start new line */
672                            putchar('\n');
673                            fputs(vnam(i), stdout);
674                            putchar('=');
675                            k = clipline;
676                        }
677                    }
678                }
679                putchar('\n');
680            }
681        fflush(stdout);
682 }
683
684
386   oconv()                         /* run oconv and mkillum if necessary */
387   {
388          static char     illumtmp[] = "ilXXXXXX";
389 <        char    combuf[512], ocopts[64], mkopts[64];
389 >        char    combuf[1024], ocopts[64], mkopts[64];
390  
391          oconvopts(ocopts);              /* get options */
392          if (octreedate < scenedate) {   /* check date on original octree */
# Line 705 | Line 406 | oconv()                                /* run oconv and mkillum if necessary */
406                                  "%s: error generating octree\n\t%s removed\n",
407                                                  progname, vval(OCTREE));
408                                  unlink(vval(OCTREE));
409 <                                exit(1);
409 >                                quit(1);
410                          }
411                  }
412                  octreedate = time((time_t *)NULL);
# Line 736 | Line 437 | oconv()                                /* run oconv and mkillum if necessary */
437                                  "%s: error generating octree\n\t%s removed\n",
438                                                  progname, oct0name);
439                                  unlink(oct0name);
440 <                                exit(1);
440 >                                quit(1);
441                          }
442                  }
443                  oct0date = time((time_t *)NULL);
# Line 756 | Line 457 | oconv()                                /* run oconv and mkillum if necessary */
457                          fprintf(stderr, "%s: error running mkillum\n",
458                                          progname);
459                          unlink(illumtmp);
460 <                        exit(1);
460 >                        quit(1);
461                  }
462                                                  /* make octree1 (frozen) */
463                  if (octreedate)
# Line 773 | Line 474 | oconv()                                /* run oconv and mkillum if necessary */
474                                  "%s: error generating octree\n\t%s removed\n",
475                                          progname, oct1name);
476                          unlink(oct1name);
477 <                        exit(1);
477 >                        unlink(illumtmp);
478 >                        quit(1);
479                  }
480                  rmfile(illumtmp);
481          }
# Line 837 | Line 539 | ambval()                               /* compute ambient value */
539   {
540          if (vdef(EXPOSURE)) {
541                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
542 <                        return(.5/pow(2.,atof(vval(EXPOSURE))));
543 <                return(.5/atof(vval(EXPOSURE)));
542 >                        return(.5/pow(2.,vflt(EXPOSURE)));
543 >                return(.5/vflt(EXPOSURE));
544          }
545          if (vlet(ZONE) == 'E')
546                  return(10.);
# Line 914 | Line 616 | char   *po;
616                  overture = 0;
617          switch (vscale(VARIABILITY)) {
618          case LOW:
619 <                op = addarg(op, "-aa .4 -ad 64");
619 >                op = addarg(op, "-aw 128 -aa .4 -ad 64");
620                  break;
621          case MEDIUM:
622 <                op = addarg(op, "-aa .3 -ad 128");
622 >                op = addarg(op, "-aw 1024 -aa .3 -ad 128");
623                  break;
624          case HIGH:
625                  op = addarg(op, "-aa .25 -ad 256");
# Line 937 | Line 639 | medqopts(op, po)                       /* medium quality rendering options
639   register char   *op;
640   char    *po;
641   {
642 <        double  d, org[3], siz[3];
642 >        double  d, org[3], siz[3], asz;
643  
644          *op = '\0';
645          *po = '\0';
# Line 948 | Line 650 | char   *po;
650          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
651                  badvalue(ZONE);
652          getoctcube(org, &d);
653 <        d *= 3./(siz[0]+siz[1]+siz[2]);
653 >        asz = (siz[0]+siz[1]+siz[2])/3.;
654 >        d /= asz;
655          switch (vscale(DETAIL)) {
656          case LOW:
657                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
658                  op = addarg(op, "-dp 256");
659                  sprintf(op, " -ar %d", (int)(8*d));
660                  op += strlen(op);
661 +                sprintf(op, " -ms %.2g", asz/20.);
662 +                op += strlen(op);
663                  break;
664          case MEDIUM:
665                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
666                  op = addarg(op, "-dp 512");
667                  sprintf(op, " -ar %d", (int)(16*d));
668                  op += strlen(op);
669 +                sprintf(op, " -ms %.2g", asz/40.);
670 +                op += strlen(op);
671                  break;
672          case HIGH:
673                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
674                  op = addarg(op, "-dp 1024");
675                  sprintf(op, " -ar %d", (int)(32*d));
676                  op += strlen(op);
677 +                sprintf(op, " -ms %.2g", asz/80.);
678 +                op += strlen(op);
679                  break;
680          }
681          po = addarg(po, "-pt .08");
# Line 986 | Line 695 | char   *po;
695                  overture = 0;
696          switch (vscale(VARIABILITY)) {
697          case LOW:
698 <                op = addarg(op, "-aa .25 -ad 196 -as 0");
698 >                op = addarg(op, "-aw 128 -aa .25 -ad 196 -as 0");
699                  break;
700          case MEDIUM:
701 <                op = addarg(op, "-aa .2 -ad 400 -as 64");
701 >                op = addarg(op, "-aw 1024 -aa .2 -ad 400 -as 64");
702                  break;
703          case HIGH:
704                  op = addarg(op, "-aa .15 -ad 768 -as 196");
# Line 1008 | Line 717 | hiqopts(op, po)                                /* high quality rendering options *
717   register char   *op;
718   char    *po;
719   {
720 <        double  d, org[3], siz[3];
720 >        double  d, org[3], siz[3], asz;
721  
722          *op = '\0';
723          *po = '\0';
# Line 1019 | Line 728 | char   *po;
728          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
729                  badvalue(ZONE);
730          getoctcube(org, &d);
731 <        d *= 3./(siz[0]+siz[1]+siz[2]);
731 >        asz = (siz[0]+siz[1]+siz[2])/3.;
732 >        d /= asz;
733          switch (vscale(DETAIL)) {
734          case LOW:
735                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
736                  op = addarg(op, "-dp 1024");
737                  sprintf(op, " -ar %d", (int)(16*d));
738                  op += strlen(op);
739 +                sprintf(op, " -ms %.2g", asz/40.);
740 +                op += strlen(op);
741                  break;
742          case MEDIUM:
743                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
744                  op = addarg(op, "-dp 2048");
745                  sprintf(op, " -ar %d", (int)(32*d));
746                  op += strlen(op);
747 +                sprintf(op, " -ms %.2g", asz/80.);
748 +                op += strlen(op);
749                  break;
750          case HIGH:
751                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
752                  op = addarg(op, "-dp 4096");
753                  sprintf(op, " -ar %d", (int)(64*d));
754                  op += strlen(op);
755 +                sprintf(op, " -ms %.2g", asz/160.);
756 +                op += strlen(op);
757                  break;
758          }
759          po = addarg(po, "-pt .04");
760          if (vbool(PENUMBRAS))
761 <                op = addarg(op, "-ds .1 -dj .7");
761 >                op = addarg(op, "-ds .1 -dj .65");
762          else
763                  op = addarg(op, "-ds .2");
764          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1055 | Line 771 | char   *po;
771                  overture = 0;
772          switch (vscale(VARIABILITY)) {
773          case LOW:
774 <                op = addarg(op, "-aa .15 -ad 256 -as 0");
774 >                op = addarg(op, "-aw 128 -aa .15 -ad 256 -as 0");
775                  break;
776          case MEDIUM:
777 <                op = addarg(op, "-aa .125 -ad 512 -as 256");
777 >                op = addarg(op, "-aw 1024 -aa .125 -ad 512 -as 256");
778                  break;
779          case HIGH:
780                  op = addarg(op, "-aa .08 -ad 1024 -as 512");
# Line 1084 | Line 800 | char   *ro;
800                  return;
801          if (vdef(OPTFILE)) {
802                  for (cp = ro; cp[1]; cp++)
803 <                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
803 >                        if (isspace(cp[1]) && (cp[2] == '@' ||
804 >                                        (cp[2] == '-' && isalpha(cp[3]))))
805                                  *cp = '\n';
806                          else
807                                  *cp = cp[1];
# Line 1179 | Line 896 | register char  *vs;
896                  zpos = -1; vs++;
897          }
898          viewtype = 'v';
899 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
899 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
900                  viewtype = *vs++;
901          cp = viewopts;
902          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1234 | Line 951 | register char  *vs;
951                  case 'h':
952                          cp = addarg(cp, "-vh 180 -vv 180");
953                          break;
954 +                case 'c':
955 +                        cp = addarg(cp, "-vh 180 -vv 90");
956 +                        break;
957                  }
958          } else {
959                  while (!isspace(*vs))           /* else skip id */
# Line 1279 | Line 999 | char   *vn;            /* returned view name */
999                  }
1000                                                  /* view number? */
1001                  if (isint(viewselect))
1002 <                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1002 >                        return(specview(nvalue(VIEW, atoi(viewselect)-1)));
1003                                                  /* check list */
1004 <                while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1004 >                while ((mv = nvalue(VIEW, n++)) != NULL)
1005                          if (matchword(viewselect, mv))
1006                                  return(specview(mv));
1007                  return(specview(viewselect));   /* standard view? */
1008          }
1009 <        mv = nvalue(vv+VIEW, n);                /* use view n */
1009 >        mv = nvalue(VIEW, n);           /* use view n */
1010          if (vn != NULL & mv != NULL) {
1011                  register char   *mv2 = mv;
1012                  if (*mv2 != '-')
# Line 1373 | Line 1093 | char   *opts, *po;
1093          strcat(combuf, oct1name);
1094          if (runcom(combuf)) {           /* run it */
1095                  fprintf(stderr, "%s: error running rview\n", progname);
1096 <                exit(1);
1096 >                quit(1);
1097          }
1098   }
1099  
# Line 1382 | Line 1102 | rpict(opts, po)                                /* run rpict and pfilt for each vie
1102   char    *opts, *po;
1103   {
1104          char    combuf[1024];
1105 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1105 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1106 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1107          char    pfopts[128];
1108          char    vs[32], *vw;
1109          int     vn, mult;
# Line 1435 | Line 1156 | char   *opts, *po;
1156                  if (!vs[0])
1157                          sprintf(vs, "%d", vn);
1158                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1159 +                if (vdef(ZFILE))
1160 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1161 +                else
1162 +                        zopt[0] = '\0';
1163                                                  /* check date on picture */
1164                  pfdt = fdate(picfile);
1165                  if (pfdt >= oct1date)
1166                          continue;
1167                                                  /* get raw file name */
1168 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1168 >                sprintf(rawfile, "%s_%s.unf",
1169 >                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1170                  rfdt = fdate(rawfile);
1171                  if (touchonly) {                /* update times only */
1172                          if (rfdt) {
# Line 1452 | Line 1178 | char   *opts, *po;
1178                  }
1179                                                  /* build rpict command */
1180                  if (rfdt >= oct1date)           /* recover */
1181 <                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1182 <                                        rep, po, opts, rawfile, oct1name);
1181 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1182 >                                rep, po, opts, zopt, rawfile, oct1name);
1183                  else {
1184                          if (overture) {         /* run overture calculation */
1185                                  sprintf(combuf,
# Line 1464 | Line 1190 | char   *opts, *po;
1190                                          fprintf(stderr,
1191                                          "%s: error in overture for view %s\n",
1192                                                  progname, vs);
1193 <                                        exit(1);
1193 >                                        quit(1);
1194                                  }
1195   #ifdef NIX
1196                                  rmfile(overfile);
1197   #endif
1198                          }
1199 <                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1200 <                                        rep, vw, res, po, opts,
1201 <                                oct1name, rawfile);
1199 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1200 >                                        rep, vw, res, po, opts, zopt,
1201 >                                        oct1name, rawfile);
1202                  }
1203                  if (runcom(combuf)) {           /* run rpict */
1204                          fprintf(stderr, "%s: error rendering view %s\n",
1205                                          progname, vs);
1206 <                        exit(1);
1206 >                        quit(1);
1207                  }
1208 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1209                                                  /* build pfilt command */
1210 <                if (mult > 1)
1211 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1210 >                        if (mult > 1)
1211 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1212                                          pfopts, mult, mult, rawfile, picfile);
1213 <                else
1214 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1215 <                                        rawfile, picfile);
1216 <                if (runcom(combuf)) {           /* run pfilt */
1217 <                        fprintf(stderr,
1218 <                        "%s: error filtering view %s\n\t%s removed\n",
1219 <                                        progname, vs, picfile);
1220 <                        unlink(picfile);
1221 <                        exit(1);
1213 >                        else
1214 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1215 >                                                rawfile, picfile);
1216 >                        if (runcom(combuf)) {           /* run pfilt */
1217 >                                fprintf(stderr,
1218 >                                "%s: error filtering view %s\n\t%s removed\n",
1219 >                                                progname, vs, picfile);
1220 >                                unlink(picfile);
1221 >                                quit(1);
1222 >                        }
1223                  }
1224 <                                                /* remove raw file */
1225 <                rmfile(rawfile);
1224 >                                                /* remove/rename raw file */
1225 >                if (vdef(RAWFILE)) {
1226 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1227 >                        mvfile(rawfile, combuf);
1228 >                } else
1229 >                        rmfile(rawfile);
1230          }
1231   }
1232  
# Line 1542 | Line 1274 | char   *fn;
1274   }
1275  
1276  
1277 + mvfile(fold, fnew)              /* move a file */
1278 + char    *fold, *fnew;
1279 + {
1280 +        if (!silent)
1281   #ifdef MSDOS
1282 +                printf("\trename %s %s\n", fold, fnew);
1283 + #else
1284 +                printf("\tmv %s %s\n", fold, fnew);
1285 + #endif
1286 +        if (noaction)
1287 +                return(0);
1288 +        return(rename(fold, fnew));
1289 + }
1290 +
1291 +
1292 + #ifdef MSDOS
1293   setenv(vname, value)            /* set an environment variable */
1294   char    *vname, *value;
1295   {
# Line 1554 | Line 1301 | char   *vname, *value;
1301          sprintf(evp, "%s=%s", vname, value);
1302          if (putenv(evp) != 0) {
1303                  fprintf(stderr, "%s: out of environment space\n", progname);
1304 <                exit(1);
1304 >                quit(1);
1305          }
1306          if (!silent)
1307                  printf("set %s\n", evp);
# Line 1567 | Line 1314 | int    vc;
1314   {
1315          fprintf(stderr, "%s: bad value for variable '%s'\n",
1316                          progname, vnam(vc));
1317 <        exit(1);
1317 >        quit(1);
1318   }
1319  
1320  
# Line 1575 | Line 1322 | syserr(s)                      /* report a system error and exit */
1322   char    *s;
1323   {
1324          perror(s);
1325 <        exit(1);
1325 >        quit(1);
1326 > }
1327 >
1328 >
1329 > quit(ec)                        /* exit program */
1330 > int     ec;
1331 > {
1332 >        exit(ec);
1333   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines