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