ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum.c
(Generate patch)

Comparing ray/src/gen/mkillum.c (file contents):
Revision 1.1 by greg, Tue Jul 23 12:00:29 1991 UTC vs.
Revision 2.25 by greg, Thu May 26 14:46:21 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Make illum sources for optimizing rendering process
6   */
7  
8 < #include  "standard.h"
8 > #include  <signal.h>
9 > #include  <ctype.h>
10  
11 < #include  "object.h"
11 > #include  "platform.h"
12 > #include  "mkillum.h"
13 > #include  "random.h"
14  
15 #include  "otypes.h"
16
15                                  /* default parameters */
16 < #define  SAMPDENS       128             /* points per projected steradian */
16 > #define  SAMPDENS       48              /* points per projected steradian */
17   #define  NSAMPS         32              /* samples per point */
18   #define  DFLMAT         "illum_mat"     /* material name */
19 + #define  DFLDAT         "illum"         /* data file name */
20                                  /* selection options */
21   #define  S_NONE         0               /* select none */
22   #define  S_ELEM         1               /* select specified element */
# Line 25 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24   #define  S_ALL          3               /* select all */
25  
26                                  /* rtrace command and defaults */
27 < char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2",
28 <                "-ad", "256", "-as", "128", "-aa", ".15" };
29 < int  rtargc = 13;
27 > char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-",
28 >                "-ab", "2", "-ad", "1024", "-as", "512", "-aa", ".1", };
29 > int  rtargc = 14;
30                                  /* overriding rtrace options */
31 < char  *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL };
31 > char  *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-",
32 >                        "-fff", "-y", "0", NULL };
33  
34 <                                /* illum flags */
35 < #define  IL_FLAT        0x1             /* flat surface */
36 < #define  IL_LIGHT       0x2             /* light rather than illum */
37 < #define  IL_COLDST      0x4             /* colored distribution */
38 < #define  IL_COLAVG      0x8             /* compute average color */
39 < #define  IL_DATCLB      0x10            /* OK to clobber data file */
34 > struct rtproc   rt0;            /* head of rtrace process list */
35  
36 < struct illum_args {
37 <        int     flags;                  /* flags from list above */
38 <        char    matname[MAXSTR];        /* illum material name */
39 <        char    datafile[MAXSTR];       /* distribution data file name */
40 <        int     dfnum;                  /* data file number */
41 <        char    altmatname[MAXSTR];     /* alternate material name */
42 <        int     nsamps;                 /* # of samples in each direction */
43 <        int     nalt, nazi;             /* # of altitude and azimuth angles */
44 <        FVECT   orient;                 /* coordinate system orientation */
45 < } thisillum = {                 /* default values */
51 <        0,
52 <        DFLMAT,
53 <        DFLMAT,
54 <        0,
55 <        VOIDID,
56 <        NSAMPS,
57 < };
36 > struct illum_args  thisillum = {        /* our illum and default values */
37 >                0,
38 >                DFLMAT,
39 >                DFLDAT,
40 >                0,
41 >                VOIDID,
42 >                SAMPDENS,
43 >                NSAMPS,
44 >                0.,
45 >        };
46  
59 int     sampdens = SAMPDENS;    /* sample point density */
47   char    matcheck[MAXSTR];       /* current material to include or exclude */
48   int     matselect = S_ALL;      /* selection criterion */
49  
50 < int     rt_pd[3];               /* rtrace pipe descriptors */
64 < float   *rt_buf;                /* rtrace i/o buffer */
65 < int     rt_bsiz;                /* maximum rays for rtrace buffer */
66 < int     rt_nrays;               /* current length of rtrace buffer */
50 > FUN     ofun[NUMOTYPE] = INIT_OTYPE;    /* object types */
51  
52 + char    persistfn[] = "pfXXXXXX";       /* persist file name */
53 +
54   int     gargc;                  /* global argc */
55   char    **gargv;                /* global argv */
56   #define  progname       gargv[0]
57  
58   int     doneheader = 0;         /* printed header yet? */
59 + #define  checkhead()    if (!doneheader++) printhead(gargc,gargv)
60  
61 < extern char     *fgetline(), *fgetword(), *sskip(),
75 <                *atos(), *iskip(), *fskip();
76 < extern FILE     *popen();
61 > int     warnings = 1;           /* print warnings? */
62  
63 + int done_rprocs(struct rtproc *rtp);
64 + void init(int np);
65 + void filter(register FILE       *infp, char     *name);
66 + void xoptions(char      *s, char        *nm);
67 + void printopts(void);
68 + void printhead(register int  ac, register char  **av);
69 + void xobject(FILE  *fp, char  *nm);
70  
71 < main(argc, argv)                /* compute illum distributions using rtrace */
72 < int     argc;
73 < char    *argv[];
71 >
72 > int
73 > main(           /* compute illum distributions using rtrace */
74 >        int     argc,
75 >        char    *argv[]
76 > )
77   {
78 <        extern char     *getenv(), *getpath();
78 >        int     nprocs = 1;
79          char    *rtpath;
80 +        FILE    *fp;
81          register int    i;
82                                  /* set global arguments */
83 <        gargc = argc; gargv = argv;
83 >        gargv = argv;
84 >                                /* check for -n option */
85 >        if (!strcmp(argv[1], "-n")) {
86 >                nprocs = atoi(argv[2]);
87 >                if (nprocs <= 0)
88 >                        error(USER, "illegal number of processes");
89 >                i = 3;
90 >        } else
91 >                i = 1;
92                                  /* set up rtrace command */
93 <        if (argc < 2)
94 <                error(USER, "too few arguments");
95 <        for (i = 1; i < argc-1; i++)
93 >        for ( ; i < argc; i++) {
94 >                if (argv[i][0] == '<' && argv[i][1] == '\0')
95 >                        break;
96                  rtargv[rtargc++] = argv[i];
97 +                if (argv[i][0] == '-' && argv[i][1] == 'w')
98 +                        switch (argv[i][2]) {
99 +                        case '\0':
100 +                                warnings = !warnings;
101 +                                break;
102 +                        case '+':
103 +                        case 'T': case 't':
104 +                        case 'Y': case 'y':
105 +                        case '1':
106 +                                warnings = 1;
107 +                                break;
108 +                        case '-':
109 +                        case 'F': case 'f':
110 +                        case 'N': case 'n':
111 +                        case '0':
112 +                                warnings = 0;
113 +                                break;
114 +                        }
115 +        }
116 +        gargc = i;
117 +        if (!strcmp(rtargv[--rtargc], "-defaults"))
118 +                nprocs = 0;
119 +        if (nprocs > 1) {       /* add persist file if parallel invocation */
120 +                rtargv[rtargc++] = "-PP";
121 +                rtargv[rtargc++] = mktemp(persistfn);
122 +        }
123 +                                /* add "mandatory" rtrace options */
124          for (i = 0; myrtopts[i] != NULL; i++)
125                  rtargv[rtargc++] = myrtopts[i];
126 <        rtargv[rtargc++] = argv[argc-1];
126 >                                /* finally, put back final argument */
127 >        rtargv[rtargc++] = argv[gargc-1];
128          rtargv[rtargc] = NULL;
129 <                                /* just asking for defaults? */
130 <        if (!strcmp(argv[argc-1], "-defaults")) {
129 >        if (!nprocs) {          /* just asking for defaults? */
130 >                printopts(); fflush(stdout);
131                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
132                  if (rtpath == NULL) {
133                          eputs(rtargv[0]);
# Line 103 | Line 135 | char   *argv[];
135                          exit(1);
136                  }
137                  execv(rtpath, rtargv);
138 <                perror(rtpath);
138 >                perror(rtpath); /* execv() should not return */
139                  exit(1);
140          }
141 +        if (gargc < 2 || argv[gargc-1][0] == '-')
142 +                error(USER, "missing octree argument");
143                                  /* else initialize and run our calculation */
144 <        init();
145 <        mkillum(stdin, "standard input");
146 <        exit(cleanup());        /* cleanup returns rtrace status */
144 >        init(nprocs);
145 >        if (gargc+1 < argc)
146 >                for (i = gargc+1; i < argc; i++) {
147 >                        if ((fp = fopen(argv[i], "r")) == NULL) {
148 >                                sprintf(errmsg,
149 >                                "cannot open scene file \"%s\"", argv[i]);
150 >                                error(SYSTEM, errmsg);
151 >                        }
152 >                        filter(fp, argv[i]);
153 >                        fclose(fp);
154 >                }
155 >        else
156 >                filter(stdin, "standard input");
157 >        quit(0);
158   }
159  
160 + static void
161 + killpersist(void)                       /* kill persistent rtrace process */
162 + {
163 +        FILE    *fp = fopen(persistfn, "r");
164 +        int     pid;
165  
166 < init()                          /* start rtrace and set up buffers */
166 >        if (fp == NULL)
167 >                return;
168 >        if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0)
169 >                unlink(persistfn);
170 >        fclose(fp);
171 > }
172 >
173 > int
174 > done_rprocs(struct rtproc *rtp)
175   {
176 <        int     maxbytes;
176 >        int     st0, st1 = 0;
177  
178 <        maxbytes = open_process(rt_pd, rtargv);
179 <        if (maxbytes == 0) {
180 <                eputs(rtargv[0]);
181 <                eputs(": command not found\n");
124 <                exit(1);
178 >        if (rtp->next != NULL) {        /* close last opened first! */
179 >                st1 = done_rprocs(rtp->next);
180 >                free((void *)rtp->next);
181 >                rtp->next = NULL;
182          }
183 <        if (maxbytes < 0)
184 <                error(SYSTEM, "cannot start rtrace process");
185 <        rt_bsiz = maxbytes/(6*sizeof(float));
186 <        rt_buf = (float *)malloc(rt_bsiz*(6*sizeof(float)));
187 <        if (rt_buf == NULL)
188 <                error(SYSTEM, "out of memory in init");
132 <        rt_bsiz--;                      /* allow for flush ray */
133 <        rt_nrays = 0;
183 >        st0 = close_process(&rtp->pd);
184 >        if (st0 < 0)
185 >                error(WARNING, "unknown return status from rtrace process");
186 >        else if (st0 > 0)
187 >                return(st0);
188 >        return(st1);
189   }
190  
191 <
192 < int
138 < cleanup()                       /* close rtrace process and return status */
191 > void
192 > quit(int status)                        /* exit with status */
193   {
194 <        int     status;
194 >        int     rtstat;
195  
196 <        free((char *)rt_buf);
197 <        rt_bsiz = 0;
198 <        status = close_process(rt_pd);
199 <        if (status < 0)
200 <                return(0);              /* unknown status */
201 <        return(status);
196 >        if (rt0.next != NULL)           /* terminate persistent rtrace */
197 >                killpersist();
198 >                                        /* clean up rtrace process(es) */
199 >        rtstat = done_rprocs(&rt0);
200 >        if (status == 0)
201 >                status = rtstat;
202 >        exit(status);
203   }
204  
205 + void
206 + init(int np)                            /* start rtrace and set up buffers */
207 + {
208 +        struct rtproc   *rtp;
209 +        int     i;
210 +        int     maxbytes;
211 +                                        /* set up object functions */
212 +        ofun[OBJ_FACE].funp = o_face;
213 +        ofun[OBJ_SPHERE].funp = o_sphere;
214 +        ofun[OBJ_RING].funp = o_ring;
215 +                                        /* set up signal handling */
216 +        signal(SIGINT, quit);
217 + #ifdef SIGHUP
218 +        signal(SIGHUP, quit);
219 + #endif
220 + #ifdef SIGTERM
221 +        signal(SIGTERM, quit);
222 + #endif
223 + #ifdef SIGPIPE
224 +        signal(SIGPIPE, quit);
225 + #endif
226 +        rtp = &rt0;                     /* start rtrace process(es) */
227 +        for (i = 0; i++ < np; ) {
228 +                errno = 0;
229 +                maxbytes = open_process(&rtp->pd, rtargv);
230 +                if (maxbytes == 0) {
231 +                        eputs(rtargv[0]);
232 +                        eputs(": command not found\n");
233 +                        exit(1);
234 +                }
235 +                if (maxbytes < 0)
236 +                        error(SYSTEM, "cannot start rtrace process");
237 +                rtp->bsiz = maxbytes/(6*sizeof(float));
238 +                rtp->buf = (float *)malloc(6*sizeof(float)*rtp->bsiz--);
239 +                rtp->dest = (float **)calloc(rtp->bsiz, sizeof(float *));
240 +                if (rtp->buf == NULL || rtp->dest == NULL)
241 +                        error(SYSTEM, "out of memory in init");
242 +                rtp->nrays = 0;
243 +                if (i == np)            /* last process? */
244 +                        break;
245 +                if (np > 1)
246 +                        sleep(2);       /* wait for persist file */
247 +                rtp->next = (struct rtproc *)malloc(sizeof(struct rtproc));
248 +                if (rtp->next == NULL)
249 +                        error(SYSTEM, "out of memory in init");
250 +                rtp = rtp->next;
251 +        }
252 +        rtp->next = NULL;
253 +                                        /* set up urand */
254 +        initurand(16384);
255 + }
256  
257 < eputs(s)                                /* put string to stderr */
258 < register char  *s;
257 >
258 > void
259 > eputs(                          /* put string to stderr */
260 >        register char  *s
261 > )
262   {
263          static int  midline = 0;
264  
# Line 163 | Line 272 | register char  *s;
272   }
273  
274  
275 < mkillum(infp, name)             /* process stream */
276 < register FILE   *infp;
277 < char    *name;
275 > void
276 > wputs(s)                        /* print warning if enabled */
277 > char  *s;
278   {
279 +        if (warnings)
280 +                eputs(s);
281 + }
282 +
283 +
284 + void
285 + filter(         /* process stream */
286 +        register FILE   *infp,
287 +        char    *name
288 + )
289 + {
290          char    buf[512];
291          FILE    *pfp;
292          register int    c;
# Line 177 | Line 297 | char   *name;
297                  if (c == '#') {                         /* comment/options */
298                          buf[0] = c;
299                          fgets(buf+1, sizeof(buf)-1, infp);
300 <                        fputs(buf, stdout);
181 <                        getoptions(buf, name);
300 >                        xoptions(buf, name);
301                  } else if (c == '!') {                  /* command */
302                          buf[0] = c;
303                          fgetline(buf+1, sizeof(buf)-1, infp);
# Line 186 | Line 305 | char   *name;
305                                  sprintf(errmsg, "cannot execute \"%s\"", buf);
306                                  error(SYSTEM, errmsg);
307                          }
308 <                        mkillum(pfp, buf);
308 >                        filter(pfp, buf);
309                          pclose(pfp);
310                  } else {                                /* object */
311                          ungetc(c, infp);
# Line 196 | Line 315 | char   *name;
315   }
316  
317  
318 < getoptions(s, nm)               /* get options from string s */
319 < char    *s;
320 < char    *nm;
318 > void
319 > xoptions(                       /* process options in string s */
320 >        char    *s,
321 >        char    *nm
322 > )
323   {
324          extern FILE     *freopen();
325          char    buf[64];
326          int     nerrs = 0;
327          register char   *cp;
328  
329 <        if (strncmp(s, "#@mkillum", 9) || !isspace(s[9]))
329 >        if (strncmp(s, "#@mkillum", 9) || !isspace(s[9])) {
330 >                fputs(s, stdout);               /* not for us */
331                  return;
332 +        }
333          cp = s+10;
334          while (*cp) {
335                  switch (*cp) {
336                  case ' ':
337                  case '\t':
338                  case '\n':
339 +                case '\r':
340 +                case '\f':
341                          cp++;
342                          continue;
343                  case 'm':                       /* material name */
344 <                        cp++;
220 <                        if (*cp != '=')
344 >                        if (*++cp != '=')
345                                  break;
346 <                        cp++;
346 >                        if (!*++cp || isspace(*cp))
347 >                                break;
348                          atos(thisillum.matname, MAXSTR, cp);
349                          cp = sskip(cp);
350                          if (!(thisillum.flags & IL_DATCLB)) {
# Line 228 | Line 353 | char   *nm;
353                          }
354                          continue;
355                  case 'f':                       /* data file name */
356 <                        cp++;
232 <                        if (*cp != '=')
356 >                        if (*++cp != '=')
357                                  break;
358 <                        cp++;
359 <                        if (*cp == '\0') {
358 >                        if (!*++cp || isspace(*cp)) {
359 >                                strcpy(thisillum.datafile,thisillum.matname);
360 >                                thisillum.dfnum = 0;
361                                  thisillum.flags &= ~IL_DATCLB;
362                                  continue;
363                          }
# Line 243 | Line 368 | char   *nm;
368                          continue;
369                  case 'i':                       /* include material */
370                  case 'e':                       /* exclude material */
371 <                        matselect = (*cp++ == 'i') ? S_ELEM : S_COMPL;
247 <                        if (*cp != '=')
371 >                        if (cp[1] != '=')
372                                  break;
373 <                        cp++;
373 >                        matselect = (*cp == 'i') ? S_ELEM : S_COMPL;
374 >                        cp += 2;
375                          atos(matcheck, MAXSTR, cp);
376                          cp = sskip(cp);
377                          continue;
# Line 259 | Line 384 | char   *nm;
384                          matselect = S_NONE;
385                          continue;
386                  case 'c':                       /* color calculation */
387 <                        cp++;
263 <                        if (*cp != '=')
387 >                        if (*++cp != '=')
388                                  break;
389 <                        cp++;
266 <                        switch (*cp) {
389 >                        switch (*++cp) {
390                          case 'a':                       /* average */
391 <                                thisillum.flags |= IL_COLAVG;
392 <                                thisillum.flags &= ~IL_COLDST;
391 >                                thisillum.flags = (thisillum.flags|IL_COLAVG)
392 >                                                        & ~IL_COLDST;
393                                  break;
394                          case 'd':                       /* distribution */
395 <                                thisillum.flags |= IL_COLDST;
273 <                                thisillum.flags &= ~IL_COLAVG;
395 >                                thisillum.flags |= (IL_COLDST|IL_COLAVG);
396                                  break;
397                          case 'n':                       /* none */
398                                  thisillum.flags &= ~(IL_COLAVG|IL_COLDST);
# Line 281 | Line 403 | char   *nm;
403                          cp = sskip(cp);
404                          continue;
405                  case 'd':                       /* point sample density */
406 <                        cp++;
285 <                        if (*cp != '=')
406 >                        if (*++cp != '=')
407                                  break;
408 <                        cp++;
288 <                        if (!isintd(cp, " \t\n"))
408 >                        if (!isintd(++cp, " \t\n\r"))
409                                  break;
410 <                        sampdens = atoi(cp);
410 >                        thisillum.sampdens = atoi(cp);
411                          cp = sskip(cp);
412                          continue;
413                  case 's':                       /* point super-samples */
414 <                        cp++;
295 <                        if (*cp != '=')
414 >                        if (*++cp != '=')
415                                  break;
416 <                        cp++;
298 <                        if (!isintd(cp, " \t\n"))
416 >                        if (!isintd(++cp, " \t\n\r"))
417                                  break;
418                          thisillum.nsamps = atoi(cp);
419                          cp = sskip(cp);
420                          continue;
421 <                case 'o':                       /* output file */
421 >                case 'l':                       /* light sources */
422                          cp++;
423 <                        if (*cp != '=')
423 >                        if (*cp == '+')
424 >                                thisillum.flags |= IL_LIGHT;
425 >                        else if (*cp == '-')
426 >                                thisillum.flags &= ~IL_LIGHT;
427 >                        else
428                                  break;
429                          cp++;
430 +                        continue;
431 +                case 'b':                       /* brightness */
432 +                        if (*++cp != '=')
433 +                                break;
434 +                        if (!isfltd(++cp, " \t\n\r"))
435 +                                break;
436 +                        thisillum.minbrt = atof(cp);
437 +                        if (thisillum.minbrt < 0.)
438 +                                thisillum.minbrt = 0.;
439 +                        cp = sskip(cp);
440 +                        continue;
441 +                case 'o':                       /* output file */
442 +                        if (*++cp != '=')
443 +                                break;
444 +                        if (!*++cp || isspace(*cp))
445 +                                break;
446                          atos(buf, sizeof(buf), cp);
447                          cp = sskip(cp);
448                          if (freopen(buf, "w", stdout) == NULL) {
# Line 314 | Line 452 | char   *nm;
452                          }
453                          doneheader = 0;
454                          continue;
455 +                case '!':                       /* processed file! */
456 +                        sprintf(errmsg, "(%s): already processed!", nm);
457 +                        error(WARNING, errmsg);
458 +                        matselect = S_NONE;
459 +                        return;
460                  }
461          opterr:                                 /* skip faulty option */
462 <                cp = sskip(cp);
462 >                while (*cp && !isspace(*cp))
463 >                        cp++;
464                  nerrs++;
465          }
466 +                                                /* print header? */
467 +        checkhead();
468 +                                                /* issue warnings? */
469          if (nerrs) {
470                  sprintf(errmsg, "(%s): %d error(s) in option line:",
471                                  nm, nerrs);
472                  error(WARNING, errmsg);
473 <                eputs(s);
473 >                wputs(s);
474 >                printf("# %s: the following option line has %d error(s):\n",
475 >                                progname, nerrs);
476          }
477 +                                                /* print pure comment */
478 +        printf("# %s", s+2);
479 + }
480 +
481 + void
482 + printopts(void)                 /* print out option default values */
483 + {
484 +        printf("m=%-15s\t\t# material name\n", thisillum.matname);
485 +        printf("f=%-15s\t\t# data file name\n", thisillum.datafile);
486 +        if (thisillum.flags & IL_COLAVG)
487 +                if (thisillum.flags & IL_COLDST)
488 +                        printf("c=d\t\t\t\t# color distribution\n");
489 +                else
490 +                        printf("c=a\t\t\t\t# color average\n");
491 +        else
492 +                printf("c=n\t\t\t\t# color none\n");
493 +        if (thisillum.flags & IL_LIGHT)
494 +                printf("l+\t\t\t\t# light type on\n");
495 +        else
496 +                printf("l-\t\t\t\t# light type off\n");
497 +        printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens);
498 +        printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps);
499 +        printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt);
500 + }
501 +
502 +
503 + void
504 + printhead(                      /* print out header */
505 +        register int  ac,
506 +        register char  **av
507 + )
508 + {
509 +        putchar('#');
510 +        while (ac-- > 0) {
511 +                putchar(' ');
512 +                fputs(*av++, stdout);
513 +        }
514 +        fputs("\n#@mkillum !\n", stdout);
515 + }
516 +
517 +
518 + void
519 + xobject(                                /* translate an object from fp */
520 +        FILE  *fp,
521 +        char  *nm
522 + )
523 + {
524 +        OBJREC  thisobj;
525 +        char  str[MAXSTR];
526 +        int  doit;
527 +                                        /* read the object */
528 +        if (fgetword(thisillum.altmat, MAXSTR, fp) == NULL)
529 +                goto readerr;
530 +        if (fgetword(str, MAXSTR, fp) == NULL)
531 +                goto readerr;
532 +                                        /* is it an alias? */
533 +        if (!strcmp(str, ALIASKEY)) {
534 +                if (fgetword(str, MAXSTR, fp) == NULL)
535 +                        goto readerr;
536 +                printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str);
537 +                if (fgetword(str, MAXSTR, fp) == NULL)
538 +                        goto readerr;
539 +                printf("\t%s\n", str);
540 +                return;
541 +        }
542 +        thisobj.omod = OVOID;           /* unused field */
543 +        if ((thisobj.otype = otype(str)) < 0) {
544 +                sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str);
545 +                error(USER, errmsg);
546 +        }
547 +        if (fgetword(str, MAXSTR, fp) == NULL)
548 +                goto readerr;
549 +        thisobj.oname = str;
550 +        if (readfargs(&thisobj.oargs, fp) != 1)
551 +                goto readerr;
552 +        thisobj.os = NULL;
553 +                                        /* check for translation */
554 +        switch (matselect) {
555 +        case S_NONE:
556 +                doit = 0;
557 +                break;
558 +        case S_ALL:
559 +                doit = 1;
560 +                break;
561 +        case S_ELEM:
562 +                doit = !strcmp(thisillum.altmat, matcheck);
563 +                break;
564 +        case S_COMPL:
565 +                doit = strcmp(thisillum.altmat, matcheck);
566 +                break;
567 +        }
568 +        doit = doit && issurface(thisobj.otype);
569 +                                                /* print header? */
570 +        checkhead();
571 +                                                /* process object */
572 +        if (doit)
573 +                (*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt0, nm);
574 +        else
575 +                printobj(thisillum.altmat, &thisobj);
576 +                                                /* free arguments */
577 +        freefargs(&thisobj.oargs);
578 +        return;
579 + readerr:
580 +        sprintf(errmsg, "(%s): error reading scene", nm);
581 +        error(USER, errmsg);
582   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines