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.50 by greg, Fri Jan 5 14:43:03 1996 UTC vs.
Revision 2.55 by gregl, Fri Jan 23 17:17:32 1998 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include "standard.h"
12 + #include "view.h"
13   #include "paths.h"
14   #include "vars.h"
15   #include <ctype.h>
# Line 23 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24   #define RENDER          5               /* rendering options */
25   #define OCONV           6               /* oconv options */
26   #define PFILT           7               /* pfilt options */
27 < #define VIEW            8               /* view(s) for picture(s) */
27 > #define VIEWS           8               /* view(s) for picture(s) */
28   #define ZONE            9               /* simulation zone */
29   #define QUALITY         10              /* desired rendering quality */
30   #define OCTREE          11              /* octree file name */
# Line 155 | Line 156 | char   *argv[];
156          loadvars(rifname);
157                                  /* get any additional assignments */
158          for (i++; i < argc; i++)
159 <                setvariable(argv[i]);
159 >                if (setvariable(argv[i], matchvar) < 0) {
160 >                        fprintf(stderr, "%s: unknown variable: %s\n",
161 >                                        progname, argv[i]);
162 >                        quit(1);
163 >                }
164                                  /* check assignments */
165          checkvalues();
166                                  /* check files and dates */
# Line 176 | Line 181 | char   *argv[];
181                  rview(ropts, popts);
182          else
183                  rpict(ropts, popts);
184 <        exit(0);
184 >        quit(0);
185   userr:
186          fprintf(stderr,
187   "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
188                          progname);
189 <        exit(1);
189 >        quit(1);
190   }
191  
192  
# Line 276 | Line 281 | checkfiles()                   /* check for existence and modified tim
281          if (!octreedate & !scenedate & !illumdate) {
282                  fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
283                                  vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
284 <                exit(1);
284 >                quit(1);
285          }
286          matdate = checklast(vval(MATERIAL));
287   }      
# Line 306 | Line 311 | double org[3], *sizp;
311                                  fprintf(stderr,
312                          "%s: error reading bounding box from getbbox\n",
313                                                  progname);
314 <                                exit(1);
314 >                                quit(1);
315                          }
316                          for (i = 0; i < 3; i++)
317                                  if (max[i] - min[i] > osiz)
# Line 324 | Line 329 | double org[3], *sizp;
329                                  fprintf(stderr,
330                          "%s: error reading bounding cube from getinfo\n",
331                                                  progname);
332 <                                exit(1);
332 >                                quit(1);
333                          }
334                          pclose(fp);
335                  }
# Line 360 | Line 365 | setdefaults()                  /* set default values for unassigned v
365                  vval(PICTURE) = radname;
366                  vdef(PICTURE)++;
367          }
368 <        if (!vdef(VIEW)) {
369 <                vval(VIEW) = "X";
370 <                vdef(VIEW)++;
368 >        if (!vdef(VIEWS)) {
369 >                vval(VIEWS) = "X";
370 >                vdef(VIEWS)++;
371          }
372          if (!vdef(DETAIL)) {
373                  vval(DETAIL) = "M";
# Line 402 | Line 407 | oconv()                                /* run oconv and mkillum if necessary */
407                                  "%s: error generating octree\n\t%s removed\n",
408                                                  progname, vval(OCTREE));
409                                  unlink(vval(OCTREE));
410 <                                exit(1);
410 >                                quit(1);
411                          }
412                  }
413                  octreedate = time((time_t *)NULL);
# Line 433 | Line 438 | oconv()                                /* run oconv and mkillum if necessary */
438                                  "%s: error generating octree\n\t%s removed\n",
439                                                  progname, oct0name);
440                                  unlink(oct0name);
441 <                                exit(1);
441 >                                quit(1);
442                          }
443                  }
444                  oct0date = time((time_t *)NULL);
# Line 453 | Line 458 | oconv()                                /* run oconv and mkillum if necessary */
458                          fprintf(stderr, "%s: error running mkillum\n",
459                                          progname);
460                          unlink(illumtmp);
461 <                        exit(1);
461 >                        quit(1);
462                  }
463                                                  /* make octree1 (frozen) */
464                  if (octreedate)
# Line 471 | Line 476 | oconv()                                /* run oconv and mkillum if necessary */
476                                          progname, oct1name);
477                          unlink(oct1name);
478                          unlink(illumtmp);
479 <                        exit(1);
479 >                        quit(1);
480                  }
481                  rmfile(illumtmp);
482          }
# Line 995 | Line 1000 | char   *vn;            /* returned view name */
1000                  }
1001                                                  /* view number? */
1002                  if (isint(viewselect))
1003 <                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1003 >                        return(specview(nvalue(VIEWS, atoi(viewselect)-1)));
1004                                                  /* check list */
1005 <                while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1005 >                while ((mv = nvalue(VIEWS, n++)) != NULL)
1006                          if (matchword(viewselect, mv))
1007                                  return(specview(mv));
1008                  return(specview(viewselect));   /* standard view? */
1009          }
1010 <        mv = nvalue(vv+VIEW, n);                /* use view n */
1010 >        mv = nvalue(VIEWS, n);          /* use view n */
1011          if (vn != NULL & mv != NULL) {
1012                  register char   *mv2 = mv;
1013                  if (*mv2 != '-')
# Line 1017 | Line 1022 | char   *vn;            /* returned view name */
1022   printview(vopts)                        /* print out selected view */
1023   register char   *vopts;
1024   {
1025 <        extern char     *atos(), *getenv();
1026 <        char    buf[256];
1027 <        FILE    *fp;
1025 >        extern char     *strstr(), *atos(), *getenv();
1026 >        VIEW    vwr;
1027 >        char    buf[128];
1028          register char   *cp;
1029 <
1029 > again:
1030          if (vopts == NULL)
1031                  return(-1);
1027        fputs("VIEW=", stdout);
1028        do {
1029                if (matchword(vopts, "-vf")) {          /* expand view file */
1030                        vopts = sskip(vopts);
1031                        if (!*atos(buf, sizeof(buf), vopts))
1032                                return(-1);
1033                        if ((fp = fopen(buf, "r")) == NULL)
1034                                return(-1);
1035                        for (buf[sizeof(buf)-2] = '\n';
1036                                        fgets(buf, sizeof(buf), fp) != NULL &&
1037                                                buf[0] != '\n';
1038                                        buf[sizeof(buf)-2] = '\n') {
1039                                if (buf[sizeof(buf)-2] != '\n') {
1040                                        ungetc(buf[sizeof(buf)-2], fp);
1041                                        buf[sizeof(buf)-2] = '\0';
1042                                }
1043                                if (matchword(buf, "VIEW=") ||
1044                                                matchword(buf, "rview")) {
1045                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1046                                                putchar(*cp);
1047                                }
1048                        }
1049                        fclose(fp);
1050                        vopts = sskip(vopts);
1051                } else {
1052                        while (isspace(*vopts))
1053                                vopts++;
1054                        putchar(' ');
1032   #ifdef MSDOS
1033 <                        if (*vopts == '$') {            /* expand env. var. */
1034 <                                if (!*atos(buf, sizeof(buf), vopts+1))
1035 <                                        return(-1);
1036 <                                if ((cp = getenv(buf)) == NULL)
1060 <                                        return(-1);
1061 <                                fputs(cp, stdout);
1062 <                                vopts = sskip(vopts);
1063 <                        } else
1033 >        if (vopts[0] == '$') {
1034 >                vopts = getenv(vopts+1);
1035 >                goto again;
1036 >        }
1037   #endif
1038 <                                while (*vopts && !isspace(*vopts))
1039 <                                        putchar(*vopts++);
1040 <                }
1041 <        } while (*vopts++);
1042 <        putchar('\n');
1038 >        copystruct(&vwr, &stdview);
1039 >        cp = vopts;                             /* get -vf files first */
1040 >        while ((cp = strstr(cp, "-vf ")) != NULL &&
1041 >                        *atos(buf, sizeof(buf), cp += 4))
1042 >                viewfile(buf, &vwr, NULL);
1043 >        sscanview(&vwr, vopts);                 /* get the rest */
1044 >        fputs(VIEWSTR, stdout);
1045 >        fprintview(&vwr, stdout);               /* print full spec. */
1046 >        fputc('\n', stdout);
1047          return(0);
1048   }
1049  
# Line 1089 | Line 1066 | char   *opts, *po;
1066          strcat(combuf, oct1name);
1067          if (runcom(combuf)) {           /* run it */
1068                  fprintf(stderr, "%s: error running rview\n", progname);
1069 <                exit(1);
1069 >                quit(1);
1070          }
1071   }
1072  
# Line 1186 | Line 1163 | char   *opts, *po;
1163                                          fprintf(stderr,
1164                                          "%s: error in overture for view %s\n",
1165                                                  progname, vs);
1166 <                                        exit(1);
1166 >                                        quit(1);
1167                                  }
1168   #ifdef NIX
1169                                  rmfile(overfile);
# Line 1199 | Line 1176 | char   *opts, *po;
1176                  if (runcom(combuf)) {           /* run rpict */
1177                          fprintf(stderr, "%s: error rendering view %s\n",
1178                                          progname, vs);
1179 <                        exit(1);
1179 >                        quit(1);
1180                  }
1181                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1182                                                  /* build pfilt command */
# Line 1214 | Line 1191 | char   *opts, *po;
1191                                  "%s: error filtering view %s\n\t%s removed\n",
1192                                                  progname, vs, picfile);
1193                                  unlink(picfile);
1194 <                                exit(1);
1194 >                                quit(1);
1195                          }
1196                  }
1197                                                  /* remove/rename raw file */
# Line 1297 | Line 1274 | char   *vname, *value;
1274          sprintf(evp, "%s=%s", vname, value);
1275          if (putenv(evp) != 0) {
1276                  fprintf(stderr, "%s: out of environment space\n", progname);
1277 <                exit(1);
1277 >                quit(1);
1278          }
1279          if (!silent)
1280                  printf("set %s\n", evp);
# Line 1310 | Line 1287 | int    vc;
1287   {
1288          fprintf(stderr, "%s: bad value for variable '%s'\n",
1289                          progname, vnam(vc));
1290 <        exit(1);
1290 >        quit(1);
1291   }
1292  
1293  
# Line 1318 | Line 1295 | syserr(s)                      /* report a system error and exit */
1295   char    *s;
1296   {
1297          perror(s);
1298 <        exit(1);
1298 >        quit(1);
1299 > }
1300 >
1301 >
1302 > quit(ec)                        /* exit program */
1303 > int     ec;
1304 > {
1305 >        exit(ec);
1306   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines