1 |
greg |
1.1 |
#ifndef lint |
2 |
greg |
2.45 |
static const char RCSid[] = "$Id: mkillum.c,v 2.44 2023/02/06 22:40:21 greg Exp $"; |
3 |
greg |
1.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* Make illum sources for optimizing rendering process |
6 |
|
|
*/ |
7 |
|
|
|
8 |
greg |
1.3 |
#include <signal.h> |
9 |
schorsch |
2.13 |
#include <ctype.h> |
10 |
greg |
1.3 |
|
11 |
greg |
2.41 |
#include "paths.h" /* win_popen() */ |
12 |
greg |
2.15 |
#include "mkillum.h" |
13 |
greg |
1.1 |
|
14 |
|
|
/* default parameters */ |
15 |
greg |
1.8 |
#define SAMPDENS 48 /* points per projected steradian */ |
16 |
greg |
1.1 |
#define NSAMPS 32 /* samples per point */ |
17 |
|
|
#define DFLMAT "illum_mat" /* material name */ |
18 |
greg |
1.10 |
#define DFLDAT "illum" /* data file name */ |
19 |
greg |
1.1 |
/* selection options */ |
20 |
|
|
#define S_NONE 0 /* select none */ |
21 |
|
|
#define S_ELEM 1 /* select specified element */ |
22 |
|
|
#define S_COMPL 2 /* select all but element */ |
23 |
|
|
#define S_ALL 3 /* select all */ |
24 |
|
|
|
25 |
greg |
1.2 |
struct illum_args thisillum = { /* our illum and default values */ |
26 |
|
|
0, |
27 |
|
|
DFLMAT, |
28 |
greg |
1.10 |
DFLDAT, |
29 |
greg |
1.2 |
0, |
30 |
|
|
VOIDID, |
31 |
greg |
1.3 |
SAMPDENS, |
32 |
greg |
1.2 |
NSAMPS, |
33 |
greg |
1.12 |
0., |
34 |
greg |
1.2 |
}; |
35 |
greg |
1.1 |
|
36 |
|
|
char matcheck[MAXSTR]; /* current material to include or exclude */ |
37 |
|
|
int matselect = S_ALL; /* selection criterion */ |
38 |
|
|
|
39 |
|
|
int gargc; /* global argc */ |
40 |
|
|
char **gargv; /* global argv */ |
41 |
|
|
|
42 |
|
|
int doneheader = 0; /* printed header yet? */ |
43 |
greg |
1.2 |
#define checkhead() if (!doneheader++) printhead(gargc,gargv) |
44 |
greg |
1.1 |
|
45 |
greg |
1.2 |
int warnings = 1; /* print warnings? */ |
46 |
|
|
|
47 |
greg |
2.28 |
void init(char *octnm, int np); |
48 |
greg |
2.42 |
void filter(FILE *infp, char *name); |
49 |
schorsch |
2.19 |
void xoptions(char *s, char *nm); |
50 |
|
|
void printopts(void); |
51 |
greg |
2.42 |
void printhead(int ac, char **av); |
52 |
schorsch |
2.19 |
void xobject(FILE *fp, char *nm); |
53 |
greg |
1.1 |
|
54 |
schorsch |
2.19 |
|
55 |
|
|
int |
56 |
|
|
main( /* compute illum distributions using rtrace */ |
57 |
|
|
int argc, |
58 |
|
|
char *argv[] |
59 |
|
|
) |
60 |
greg |
1.1 |
{ |
61 |
greg |
2.20 |
int nprocs = 1; |
62 |
greg |
1.3 |
FILE *fp; |
63 |
greg |
2.28 |
int rval; |
64 |
greg |
2.42 |
int i; |
65 |
greg |
1.1 |
/* set global arguments */ |
66 |
greg |
1.3 |
gargv = argv; |
67 |
greg |
2.28 |
progname = gargv[0]; |
68 |
|
|
/* set up rendering defaults */ |
69 |
greg |
2.35 |
dstrsrc = 0.5; |
70 |
greg |
2.28 |
directrelay = 3; |
71 |
|
|
ambounce = 2; |
72 |
|
|
/* get options from command line */ |
73 |
greg |
2.29 |
for (i = 1; i < argc; i++) { |
74 |
greg |
2.28 |
while ((rval = expandarg(&argc, &argv, i)) > 0) |
75 |
|
|
; |
76 |
|
|
if (rval < 0) { |
77 |
|
|
sprintf(errmsg, "cannot expand '%s'", argv[i]); |
78 |
|
|
error(SYSTEM, errmsg); |
79 |
|
|
} |
80 |
|
|
if (argv[i][0] != '-') |
81 |
greg |
1.3 |
break; |
82 |
greg |
2.28 |
if (!strcmp(argv[i], "-w")) { |
83 |
|
|
warnings = 0; |
84 |
|
|
continue; |
85 |
|
|
} |
86 |
|
|
if (!strcmp(argv[i], "-n")) { |
87 |
|
|
nprocs = atoi(argv[++i]); |
88 |
|
|
if (nprocs <= 0) |
89 |
|
|
error(USER, "illegal number of processes"); |
90 |
|
|
continue; |
91 |
|
|
} |
92 |
|
|
if (!strcmp(argv[i], "-defaults")) { |
93 |
|
|
printopts(); |
94 |
|
|
print_rdefaults(); |
95 |
|
|
quit(0); |
96 |
|
|
} |
97 |
|
|
rval = getrenderopt(argc-i, argv+i); |
98 |
|
|
if (rval < 0) { |
99 |
|
|
sprintf(errmsg, "bad render option at '%s'", argv[i]); |
100 |
|
|
error(USER, errmsg); |
101 |
greg |
1.1 |
} |
102 |
greg |
2.28 |
i += rval; |
103 |
greg |
1.1 |
} |
104 |
greg |
2.28 |
gargc = ++i; |
105 |
|
|
/* add "mandatory" render options */ |
106 |
|
|
do_irrad = 0; |
107 |
|
|
if (gargc > argc || argv[gargc-1][0] == '-') |
108 |
greg |
2.3 |
error(USER, "missing octree argument"); |
109 |
greg |
1.1 |
/* else initialize and run our calculation */ |
110 |
greg |
2.28 |
init(argv[gargc-1], nprocs); |
111 |
|
|
if (gargc < argc) { |
112 |
|
|
if (gargc == argc-1 || argv[gargc][0] != '<' || argv[gargc][1]) |
113 |
greg |
2.30 |
error(USER, "use '< file1 file2 ..' for multiple inputs"); |
114 |
greg |
1.3 |
for (i = gargc+1; i < argc; i++) { |
115 |
greg |
1.5 |
if ((fp = fopen(argv[i], "r")) == NULL) { |
116 |
greg |
1.3 |
sprintf(errmsg, |
117 |
|
|
"cannot open scene file \"%s\"", argv[i]); |
118 |
|
|
error(SYSTEM, errmsg); |
119 |
|
|
} |
120 |
|
|
filter(fp, argv[i]); |
121 |
|
|
fclose(fp); |
122 |
|
|
} |
123 |
greg |
2.28 |
} else |
124 |
greg |
1.3 |
filter(stdin, "standard input"); |
125 |
greg |
2.20 |
quit(0); |
126 |
schorsch |
2.27 |
return 0; /* pro forma return */ |
127 |
greg |
1.1 |
} |
128 |
|
|
|
129 |
schorsch |
2.26 |
|
130 |
greg |
2.11 |
void |
131 |
greg |
2.28 |
init(char *octnm, int np) /* start rendering process(es) */ |
132 |
greg |
1.3 |
{ |
133 |
|
|
/* set up signal handling */ |
134 |
greg |
2.25 |
signal(SIGINT, quit); |
135 |
|
|
#ifdef SIGHUP |
136 |
|
|
signal(SIGHUP, quit); |
137 |
|
|
#endif |
138 |
|
|
#ifdef SIGTERM |
139 |
|
|
signal(SIGTERM, quit); |
140 |
|
|
#endif |
141 |
|
|
#ifdef SIGPIPE |
142 |
greg |
1.3 |
signal(SIGPIPE, quit); |
143 |
schorsch |
2.13 |
#endif |
144 |
greg |
2.28 |
/* start rendering process(es) */ |
145 |
|
|
ray_pinit(octnm, np); |
146 |
greg |
1.1 |
} |
147 |
|
|
|
148 |
|
|
|
149 |
greg |
2.11 |
void |
150 |
schorsch |
2.19 |
eputs( /* put string to stderr */ |
151 |
greg |
2.44 |
const char *s |
152 |
schorsch |
2.19 |
) |
153 |
greg |
1.1 |
{ |
154 |
|
|
static int midline = 0; |
155 |
|
|
|
156 |
|
|
if (!*s) return; |
157 |
|
|
if (!midline) { |
158 |
|
|
fputs(progname, stderr); |
159 |
|
|
fputs(": ", stderr); |
160 |
|
|
} |
161 |
|
|
fputs(s, stderr); |
162 |
|
|
midline = s[strlen(s)-1] != '\n'; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
|
166 |
greg |
2.11 |
void |
167 |
greg |
2.44 |
wputs(const char *s) /* print warning if enabled */ |
168 |
greg |
1.2 |
{ |
169 |
|
|
if (warnings) |
170 |
|
|
eputs(s); |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
|
174 |
schorsch |
2.19 |
void |
175 |
greg |
2.44 |
quit(int ec) /* make sure exit is called */ |
176 |
greg |
2.36 |
{ |
177 |
|
|
if (ray_pnprocs > 0) /* close children if any */ |
178 |
greg |
2.43 |
ray_pclose(0); |
179 |
|
|
else if (ray_pnprocs < 0) |
180 |
|
|
_exit(ec); /* avoid flush() in child */ |
181 |
greg |
2.36 |
exit(ec); |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
|
185 |
|
|
void |
186 |
schorsch |
2.19 |
filter( /* process stream */ |
187 |
greg |
2.42 |
FILE *infp, |
188 |
schorsch |
2.19 |
char *name |
189 |
|
|
) |
190 |
greg |
1.1 |
{ |
191 |
|
|
char buf[512]; |
192 |
|
|
FILE *pfp; |
193 |
greg |
2.42 |
int c; |
194 |
greg |
1.1 |
|
195 |
|
|
while ((c = getc(infp)) != EOF) { |
196 |
|
|
if (isspace(c)) |
197 |
|
|
continue; |
198 |
|
|
if (c == '#') { /* comment/options */ |
199 |
|
|
buf[0] = c; |
200 |
|
|
fgets(buf+1, sizeof(buf)-1, infp); |
201 |
greg |
1.2 |
xoptions(buf, name); |
202 |
greg |
1.1 |
} else if (c == '!') { /* command */ |
203 |
|
|
buf[0] = c; |
204 |
|
|
fgetline(buf+1, sizeof(buf)-1, infp); |
205 |
|
|
if ((pfp = popen(buf+1, "r")) == NULL) { |
206 |
|
|
sprintf(errmsg, "cannot execute \"%s\"", buf); |
207 |
|
|
error(SYSTEM, errmsg); |
208 |
|
|
} |
209 |
greg |
1.2 |
filter(pfp, buf); |
210 |
greg |
2.45 |
if (pclose(pfp) != 0) { |
211 |
|
|
sprintf(errmsg, "bad status from \"%s\"", buf); |
212 |
|
|
error(USER, errmsg); |
213 |
|
|
} |
214 |
greg |
1.1 |
} else { /* object */ |
215 |
|
|
ungetc(c, infp); |
216 |
|
|
xobject(infp, name); |
217 |
|
|
} |
218 |
|
|
} |
219 |
|
|
} |
220 |
|
|
|
221 |
|
|
|
222 |
schorsch |
2.19 |
void |
223 |
|
|
xoptions( /* process options in string s */ |
224 |
|
|
char *s, |
225 |
|
|
char *nm |
226 |
|
|
) |
227 |
greg |
1.1 |
{ |
228 |
|
|
char buf[64]; |
229 |
greg |
2.30 |
int negax; |
230 |
greg |
1.1 |
int nerrs = 0; |
231 |
greg |
2.42 |
char *cp; |
232 |
greg |
1.1 |
|
233 |
greg |
1.2 |
if (strncmp(s, "#@mkillum", 9) || !isspace(s[9])) { |
234 |
|
|
fputs(s, stdout); /* not for us */ |
235 |
greg |
1.1 |
return; |
236 |
greg |
1.2 |
} |
237 |
greg |
1.1 |
cp = s+10; |
238 |
|
|
while (*cp) { |
239 |
|
|
switch (*cp) { |
240 |
|
|
case ' ': |
241 |
|
|
case '\t': |
242 |
|
|
case '\n': |
243 |
greg |
2.11 |
case '\r': |
244 |
|
|
case '\f': |
245 |
greg |
1.1 |
cp++; |
246 |
|
|
continue; |
247 |
|
|
case 'm': /* material name */ |
248 |
greg |
1.2 |
if (*++cp != '=') |
249 |
greg |
1.1 |
break; |
250 |
greg |
2.8 |
if (!*++cp || isspace(*cp)) |
251 |
greg |
1.2 |
break; |
252 |
greg |
1.1 |
atos(thisillum.matname, MAXSTR, cp); |
253 |
|
|
cp = sskip(cp); |
254 |
|
|
if (!(thisillum.flags & IL_DATCLB)) { |
255 |
|
|
strcpy(thisillum.datafile, thisillum.matname); |
256 |
|
|
thisillum.dfnum = 0; |
257 |
|
|
} |
258 |
|
|
continue; |
259 |
|
|
case 'f': /* data file name */ |
260 |
greg |
1.2 |
if (*++cp != '=') |
261 |
greg |
1.1 |
break; |
262 |
greg |
2.8 |
if (!*++cp || isspace(*cp)) { |
263 |
greg |
1.6 |
strcpy(thisillum.datafile,thisillum.matname); |
264 |
greg |
1.10 |
thisillum.dfnum = 0; |
265 |
greg |
1.1 |
thisillum.flags &= ~IL_DATCLB; |
266 |
|
|
continue; |
267 |
|
|
} |
268 |
|
|
atos(thisillum.datafile, MAXSTR, cp); |
269 |
|
|
cp = sskip(cp); |
270 |
|
|
thisillum.dfnum = 0; |
271 |
|
|
thisillum.flags |= IL_DATCLB; |
272 |
|
|
continue; |
273 |
|
|
case 'i': /* include material */ |
274 |
|
|
case 'e': /* exclude material */ |
275 |
greg |
1.6 |
if (cp[1] != '=') |
276 |
greg |
1.1 |
break; |
277 |
greg |
1.7 |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
278 |
|
|
cp += 2; |
279 |
|
|
atos(matcheck, MAXSTR, cp); |
280 |
greg |
1.1 |
cp = sskip(cp); |
281 |
|
|
continue; |
282 |
|
|
case 'a': /* use everything */ |
283 |
|
|
cp = sskip(cp); |
284 |
|
|
matselect = S_ALL; |
285 |
|
|
continue; |
286 |
|
|
case 'n': /* use nothing (passive) */ |
287 |
|
|
cp = sskip(cp); |
288 |
|
|
matselect = S_NONE; |
289 |
|
|
continue; |
290 |
|
|
case 'c': /* color calculation */ |
291 |
greg |
1.2 |
if (*++cp != '=') |
292 |
greg |
1.1 |
break; |
293 |
greg |
1.2 |
switch (*++cp) { |
294 |
greg |
1.1 |
case 'a': /* average */ |
295 |
greg |
1.6 |
thisillum.flags = (thisillum.flags|IL_COLAVG) |
296 |
|
|
& ~IL_COLDST; |
297 |
greg |
1.1 |
break; |
298 |
|
|
case 'd': /* distribution */ |
299 |
greg |
1.5 |
thisillum.flags |= (IL_COLDST|IL_COLAVG); |
300 |
greg |
1.1 |
break; |
301 |
|
|
case 'n': /* none */ |
302 |
|
|
thisillum.flags &= ~(IL_COLAVG|IL_COLDST); |
303 |
|
|
break; |
304 |
|
|
default: |
305 |
|
|
goto opterr; |
306 |
|
|
} |
307 |
|
|
cp = sskip(cp); |
308 |
|
|
continue; |
309 |
greg |
2.39 |
case 'd': /* sample density */ |
310 |
greg |
1.2 |
if (*++cp != '=') |
311 |
greg |
1.1 |
break; |
312 |
greg |
2.30 |
if (!*++cp || isspace(*cp)) |
313 |
|
|
continue; |
314 |
greg |
2.33 |
if (isintd(cp, " \t\n\r")) { |
315 |
greg |
2.30 |
thisillum.sampdens = atoi(cp); |
316 |
|
|
} else { |
317 |
greg |
2.39 |
error(WARNING, "direct BSDF input unsupported"); |
318 |
|
|
goto opterr; |
319 |
greg |
2.30 |
} |
320 |
greg |
1.1 |
cp = sskip(cp); |
321 |
|
|
continue; |
322 |
greg |
2.30 |
case 's': /* surface super-samples */ |
323 |
greg |
1.2 |
if (*++cp != '=') |
324 |
greg |
1.1 |
break; |
325 |
greg |
2.11 |
if (!isintd(++cp, " \t\n\r")) |
326 |
greg |
1.1 |
break; |
327 |
|
|
thisillum.nsamps = atoi(cp); |
328 |
|
|
cp = sskip(cp); |
329 |
|
|
continue; |
330 |
greg |
1.3 |
case 'l': /* light sources */ |
331 |
greg |
1.4 |
cp++; |
332 |
|
|
if (*cp == '+') |
333 |
greg |
1.3 |
thisillum.flags |= IL_LIGHT; |
334 |
greg |
1.4 |
else if (*cp == '-') |
335 |
|
|
thisillum.flags &= ~IL_LIGHT; |
336 |
greg |
1.3 |
else |
337 |
greg |
1.4 |
break; |
338 |
|
|
cp++; |
339 |
greg |
1.3 |
continue; |
340 |
greg |
1.12 |
case 'b': /* brightness */ |
341 |
|
|
if (*++cp != '=') |
342 |
|
|
break; |
343 |
greg |
2.11 |
if (!isfltd(++cp, " \t\n\r")) |
344 |
greg |
1.12 |
break; |
345 |
|
|
thisillum.minbrt = atof(cp); |
346 |
greg |
1.13 |
if (thisillum.minbrt < 0.) |
347 |
|
|
thisillum.minbrt = 0.; |
348 |
greg |
1.12 |
cp = sskip(cp); |
349 |
|
|
continue; |
350 |
greg |
1.1 |
case 'o': /* output file */ |
351 |
greg |
1.2 |
if (*++cp != '=') |
352 |
greg |
1.1 |
break; |
353 |
greg |
2.8 |
if (!*++cp || isspace(*cp)) |
354 |
greg |
1.2 |
break; |
355 |
greg |
1.1 |
atos(buf, sizeof(buf), cp); |
356 |
|
|
cp = sskip(cp); |
357 |
|
|
if (freopen(buf, "w", stdout) == NULL) { |
358 |
|
|
sprintf(errmsg, |
359 |
|
|
"cannot open output file \"%s\"", buf); |
360 |
|
|
error(SYSTEM, errmsg); |
361 |
|
|
} |
362 |
|
|
doneheader = 0; |
363 |
|
|
continue; |
364 |
greg |
1.6 |
case '!': /* processed file! */ |
365 |
greg |
1.7 |
sprintf(errmsg, "(%s): already processed!", nm); |
366 |
greg |
1.6 |
error(WARNING, errmsg); |
367 |
greg |
1.7 |
matselect = S_NONE; |
368 |
greg |
1.6 |
return; |
369 |
greg |
1.1 |
} |
370 |
|
|
opterr: /* skip faulty option */ |
371 |
greg |
2.9 |
while (*cp && !isspace(*cp)) |
372 |
|
|
cp++; |
373 |
greg |
1.1 |
nerrs++; |
374 |
|
|
} |
375 |
greg |
1.2 |
/* print header? */ |
376 |
|
|
checkhead(); |
377 |
|
|
/* issue warnings? */ |
378 |
greg |
1.1 |
if (nerrs) { |
379 |
|
|
sprintf(errmsg, "(%s): %d error(s) in option line:", |
380 |
|
|
nm, nerrs); |
381 |
|
|
error(WARNING, errmsg); |
382 |
greg |
1.2 |
wputs(s); |
383 |
|
|
printf("# %s: the following option line has %d error(s):\n", |
384 |
|
|
progname, nerrs); |
385 |
greg |
1.1 |
} |
386 |
greg |
1.2 |
/* print pure comment */ |
387 |
greg |
1.4 |
printf("# %s", s+2); |
388 |
greg |
1.9 |
} |
389 |
|
|
|
390 |
schorsch |
2.19 |
void |
391 |
|
|
printopts(void) /* print out option default values */ |
392 |
greg |
1.9 |
{ |
393 |
greg |
1.11 |
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
394 |
|
|
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
395 |
greg |
2.2 |
if (thisillum.flags & IL_COLAVG) |
396 |
|
|
if (thisillum.flags & IL_COLDST) |
397 |
|
|
printf("c=d\t\t\t\t# color distribution\n"); |
398 |
|
|
else |
399 |
|
|
printf("c=a\t\t\t\t# color average\n"); |
400 |
|
|
else |
401 |
|
|
printf("c=n\t\t\t\t# color none\n"); |
402 |
|
|
if (thisillum.flags & IL_LIGHT) |
403 |
|
|
printf("l+\t\t\t\t# light type on\n"); |
404 |
|
|
else |
405 |
|
|
printf("l-\t\t\t\t# light type off\n"); |
406 |
greg |
2.34 |
printf("d=%d\t\t\t\t# density of directions\n", thisillum.sampdens); |
407 |
|
|
printf("s=%d\t\t\t\t# samples per direction\n", thisillum.nsamps); |
408 |
greg |
1.12 |
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
409 |
greg |
1.1 |
} |
410 |
greg |
1.2 |
|
411 |
|
|
|
412 |
schorsch |
2.19 |
void |
413 |
|
|
printhead( /* print out header */ |
414 |
greg |
2.42 |
int ac, |
415 |
|
|
char **av |
416 |
schorsch |
2.19 |
) |
417 |
greg |
1.2 |
{ |
418 |
|
|
putchar('#'); |
419 |
|
|
while (ac-- > 0) { |
420 |
|
|
putchar(' '); |
421 |
|
|
fputs(*av++, stdout); |
422 |
|
|
} |
423 |
greg |
1.6 |
fputs("\n#@mkillum !\n", stdout); |
424 |
greg |
1.2 |
} |
425 |
|
|
|
426 |
|
|
|
427 |
schorsch |
2.19 |
void |
428 |
|
|
xobject( /* translate an object from fp */ |
429 |
|
|
FILE *fp, |
430 |
|
|
char *nm |
431 |
|
|
) |
432 |
greg |
1.2 |
{ |
433 |
|
|
OBJREC thisobj; |
434 |
|
|
char str[MAXSTR]; |
435 |
|
|
int doit; |
436 |
|
|
/* read the object */ |
437 |
|
|
if (fgetword(thisillum.altmat, MAXSTR, fp) == NULL) |
438 |
|
|
goto readerr; |
439 |
|
|
if (fgetword(str, MAXSTR, fp) == NULL) |
440 |
|
|
goto readerr; |
441 |
|
|
/* is it an alias? */ |
442 |
greg |
2.12 |
if (!strcmp(str, ALIASKEY)) { |
443 |
greg |
1.2 |
if (fgetword(str, MAXSTR, fp) == NULL) |
444 |
|
|
goto readerr; |
445 |
greg |
2.12 |
printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str); |
446 |
greg |
1.2 |
if (fgetword(str, MAXSTR, fp) == NULL) |
447 |
|
|
goto readerr; |
448 |
greg |
1.4 |
printf("\t%s\n", str); |
449 |
greg |
1.2 |
return; |
450 |
|
|
} |
451 |
greg |
1.4 |
thisobj.omod = OVOID; /* unused field */ |
452 |
greg |
1.2 |
if ((thisobj.otype = otype(str)) < 0) { |
453 |
|
|
sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str); |
454 |
|
|
error(USER, errmsg); |
455 |
|
|
} |
456 |
|
|
if (fgetword(str, MAXSTR, fp) == NULL) |
457 |
|
|
goto readerr; |
458 |
|
|
thisobj.oname = str; |
459 |
|
|
if (readfargs(&thisobj.oargs, fp) != 1) |
460 |
|
|
goto readerr; |
461 |
|
|
thisobj.os = NULL; |
462 |
|
|
/* check for translation */ |
463 |
|
|
switch (matselect) { |
464 |
|
|
case S_NONE: |
465 |
|
|
doit = 0; |
466 |
|
|
break; |
467 |
|
|
case S_ALL: |
468 |
greg |
1.4 |
doit = 1; |
469 |
greg |
1.2 |
break; |
470 |
|
|
case S_ELEM: |
471 |
|
|
doit = !strcmp(thisillum.altmat, matcheck); |
472 |
|
|
break; |
473 |
|
|
case S_COMPL: |
474 |
|
|
doit = strcmp(thisillum.altmat, matcheck); |
475 |
|
|
break; |
476 |
|
|
} |
477 |
greg |
1.4 |
doit = doit && issurface(thisobj.otype); |
478 |
greg |
1.2 |
/* print header? */ |
479 |
|
|
checkhead(); |
480 |
|
|
/* process object */ |
481 |
|
|
if (doit) |
482 |
greg |
2.28 |
switch (thisobj.otype) { |
483 |
|
|
case OBJ_FACE: |
484 |
|
|
my_face(&thisobj, &thisillum, nm); |
485 |
|
|
break; |
486 |
|
|
case OBJ_SPHERE: |
487 |
|
|
my_sphere(&thisobj, &thisillum, nm); |
488 |
|
|
break; |
489 |
|
|
case OBJ_RING: |
490 |
|
|
my_ring(&thisobj, &thisillum, nm); |
491 |
|
|
break; |
492 |
|
|
default: |
493 |
|
|
my_default(&thisobj, &thisillum, nm); |
494 |
|
|
break; |
495 |
|
|
} |
496 |
greg |
1.2 |
else |
497 |
|
|
printobj(thisillum.altmat, &thisobj); |
498 |
|
|
/* free arguments */ |
499 |
|
|
freefargs(&thisobj.oargs); |
500 |
|
|
return; |
501 |
|
|
readerr: |
502 |
greg |
2.28 |
sprintf(errmsg, "(%s): error reading input", nm); |
503 |
greg |
1.2 |
error(USER, errmsg); |
504 |
|
|
} |