1 |
< |
/* Copyright (c) 1991 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"; |
15 |
|
#include <ctype.h> |
16 |
|
|
17 |
|
/* default parameters */ |
18 |
< |
#define SAMPDENS 128 /* points per projected steradian */ |
18 |
> |
#define SAMPDENS 48 /* points per projected steradian */ |
19 |
|
#define NSAMPS 32 /* samples per point */ |
20 |
|
#define DFLMAT "illum_mat" /* material name */ |
21 |
+ |
#define DFLDAT "illum" /* data file name */ |
22 |
|
/* selection options */ |
23 |
|
#define S_NONE 0 /* select none */ |
24 |
|
#define S_ELEM 1 /* select specified element */ |
26 |
|
#define S_ALL 3 /* select all */ |
27 |
|
|
28 |
|
/* rtrace command and defaults */ |
29 |
< |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-di+", |
29 |
> |
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-", |
30 |
|
"-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", }; |
31 |
|
int rtargc = 14; |
32 |
|
/* overriding rtrace options */ |
33 |
< |
char *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", NULL }; |
33 |
> |
char *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", "-y", "0", NULL }; |
34 |
|
|
35 |
|
struct rtproc rt; /* our rtrace process */ |
36 |
|
|
37 |
|
struct illum_args thisillum = { /* our illum and default values */ |
38 |
|
0, |
39 |
|
DFLMAT, |
40 |
< |
DFLMAT, |
40 |
> |
DFLDAT, |
41 |
|
0, |
42 |
|
VOIDID, |
43 |
|
SAMPDENS, |
44 |
|
NSAMPS, |
45 |
+ |
0., |
46 |
|
}; |
47 |
|
|
48 |
|
char matcheck[MAXSTR]; /* current material to include or exclude */ |
76 |
|
gargv = argv; |
77 |
|
/* set up rtrace command */ |
78 |
|
for (i = 1; i < argc; i++) { |
79 |
< |
if (argv[i][0] == '<' && !argv[i][1]) |
79 |
> |
if (argv[i][0] == '<' && argv[i][1] == '\0') |
80 |
|
break; |
81 |
|
rtargv[rtargc++] = argv[i]; |
82 |
|
if (argv[i][0] == '-' && argv[i][1] == 'w') |
83 |
< |
warnings = !warnings; |
83 |
> |
switch (argv[i][2]) { |
84 |
> |
case '\0': |
85 |
> |
warnings = !warnings; |
86 |
> |
break; |
87 |
> |
case '+': |
88 |
> |
case 'T': case 't': |
89 |
> |
case 'Y': case 'y': |
90 |
> |
case '1': |
91 |
> |
warnings = 1; |
92 |
> |
break; |
93 |
> |
case '-': |
94 |
> |
case 'F': case 'f': |
95 |
> |
case 'N': case 'n': |
96 |
> |
case '0': |
97 |
> |
warnings = 0; |
98 |
> |
break; |
99 |
> |
} |
100 |
|
} |
101 |
< |
if ((gargc = i) < 2) |
84 |
< |
error(USER, "too few arguments"); |
101 |
> |
gargc = i; |
102 |
|
rtargc--; |
103 |
|
for (i = 0; myrtopts[i] != NULL; i++) |
104 |
|
rtargv[rtargc++] = myrtopts[i]; |
106 |
|
rtargv[rtargc] = NULL; |
107 |
|
/* just asking for defaults? */ |
108 |
|
if (!strcmp(argv[gargc-1], "-defaults")) { |
109 |
+ |
printopts(); fflush(stdout); |
110 |
|
rtpath = getpath(rtargv[0], getenv("PATH"), X_OK); |
111 |
|
if (rtpath == NULL) { |
112 |
|
eputs(rtargv[0]); |
117 |
|
perror(rtpath); |
118 |
|
exit(1); |
119 |
|
} |
120 |
+ |
if (gargc < 2 || argv[gargc-1][0] == '-') |
121 |
+ |
error(USER, "missing octree argument"); |
122 |
|
/* else initialize and run our calculation */ |
123 |
|
init(); |
124 |
|
if (gargc+1 < argc) |
164 |
|
/* set up signal handling */ |
165 |
|
signal(SIGPIPE, quit); |
166 |
|
/* start rtrace process */ |
167 |
+ |
errno = 0; |
168 |
|
maxbytes = open_process(rt.pd, rtargv); |
169 |
|
if (maxbytes == 0) { |
170 |
|
eputs(rtargv[0]); |
180 |
|
error(SYSTEM, "out of memory in init"); |
181 |
|
rt.nrays = 0; |
182 |
|
/* set up urand */ |
183 |
< |
initurand(2048); |
183 |
> |
initurand(16384); |
184 |
|
} |
185 |
|
|
186 |
|
|
263 |
|
case 'm': /* material name */ |
264 |
|
if (*++cp != '=') |
265 |
|
break; |
266 |
< |
if (!*++cp) |
266 |
> |
if (!*++cp || isspace(*cp)) |
267 |
|
break; |
268 |
|
atos(thisillum.matname, MAXSTR, cp); |
269 |
|
cp = sskip(cp); |
275 |
|
case 'f': /* data file name */ |
276 |
|
if (*++cp != '=') |
277 |
|
break; |
278 |
< |
if (!*++cp) { |
278 |
> |
if (!*++cp || isspace(*cp)) { |
279 |
|
strcpy(thisillum.datafile,thisillum.matname); |
280 |
+ |
thisillum.dfnum = 0; |
281 |
|
thisillum.flags &= ~IL_DATCLB; |
282 |
|
continue; |
283 |
|
} |
290 |
|
case 'e': /* exclude material */ |
291 |
|
if (cp[1] != '=') |
292 |
|
break; |
293 |
< |
matselect = (*++cp == 'i') ? S_ELEM : S_COMPL; |
294 |
< |
atos(matcheck, MAXSTR, ++cp); |
293 |
> |
matselect = (*cp == 'i') ? S_ELEM : S_COMPL; |
294 |
> |
cp += 2; |
295 |
> |
atos(matcheck, MAXSTR, cp); |
296 |
|
cp = sskip(cp); |
297 |
|
continue; |
298 |
|
case 'a': /* use everything */ |
348 |
|
break; |
349 |
|
cp++; |
350 |
|
continue; |
351 |
+ |
case 'b': /* brightness */ |
352 |
+ |
if (*++cp != '=') |
353 |
+ |
break; |
354 |
+ |
if (!isfltd(++cp, " \t\n")) |
355 |
+ |
break; |
356 |
+ |
thisillum.minbrt = atof(cp); |
357 |
+ |
if (thisillum.minbrt < 0.) |
358 |
+ |
thisillum.minbrt = 0.; |
359 |
+ |
cp = sskip(cp); |
360 |
+ |
continue; |
361 |
|
case 'o': /* output file */ |
362 |
|
if (*++cp != '=') |
363 |
|
break; |
364 |
< |
if (!*++cp) |
364 |
> |
if (!*++cp || isspace(*cp)) |
365 |
|
break; |
366 |
|
atos(buf, sizeof(buf), cp); |
367 |
|
cp = sskip(cp); |
373 |
|
doneheader = 0; |
374 |
|
continue; |
375 |
|
case '!': /* processed file! */ |
376 |
< |
sprintf(errmsg, "(%s): processed by mkillum already!", |
344 |
< |
nm); |
376 |
> |
sprintf(errmsg, "(%s): already processed!", nm); |
377 |
|
error(WARNING, errmsg); |
378 |
+ |
matselect = S_NONE; |
379 |
|
return; |
380 |
|
} |
381 |
|
opterr: /* skip faulty option */ |
382 |
< |
cp = sskip(cp); |
382 |
> |
while (*cp && !isspace(*cp)) |
383 |
> |
cp++; |
384 |
|
nerrs++; |
385 |
|
} |
386 |
|
/* print header? */ |
396 |
|
} |
397 |
|
/* print pure comment */ |
398 |
|
printf("# %s", s+2); |
399 |
+ |
} |
400 |
+ |
|
401 |
+ |
|
402 |
+ |
printopts() /* print out option default values */ |
403 |
+ |
{ |
404 |
+ |
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
405 |
+ |
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
406 |
+ |
if (thisillum.flags & IL_COLAVG) |
407 |
+ |
if (thisillum.flags & IL_COLDST) |
408 |
+ |
printf("c=d\t\t\t\t# color distribution\n"); |
409 |
+ |
else |
410 |
+ |
printf("c=a\t\t\t\t# color average\n"); |
411 |
+ |
else |
412 |
+ |
printf("c=n\t\t\t\t# color none\n"); |
413 |
+ |
if (thisillum.flags & IL_LIGHT) |
414 |
+ |
printf("l+\t\t\t\t# light type on\n"); |
415 |
+ |
else |
416 |
+ |
printf("l-\t\t\t\t# light type off\n"); |
417 |
+ |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
418 |
+ |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
419 |
+ |
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
420 |
|
} |
421 |
|
|
422 |
|
|