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-", "-ld-", "-ov", "-h-", |
34 |
> |
"-fff", "-y", "0", NULL }; |
35 |
|
|
36 |
|
struct rtproc rt; /* our rtrace process */ |
37 |
|
|
38 |
|
struct illum_args thisillum = { /* our illum and default values */ |
39 |
|
0, |
40 |
|
DFLMAT, |
41 |
< |
DFLMAT, |
41 |
> |
DFLDAT, |
42 |
|
0, |
43 |
|
VOIDID, |
44 |
|
SAMPDENS, |
45 |
|
NSAMPS, |
46 |
+ |
0., |
47 |
|
}; |
48 |
|
|
49 |
|
char matcheck[MAXSTR]; /* current material to include or exclude */ |
77 |
|
gargv = argv; |
78 |
|
/* set up rtrace command */ |
79 |
|
for (i = 1; i < argc; i++) { |
80 |
< |
if (argv[i][0] == '<' && !argv[i][1]) |
80 |
> |
if (argv[i][0] == '<' && argv[i][1] == '\0') |
81 |
|
break; |
82 |
|
rtargv[rtargc++] = argv[i]; |
83 |
|
if (argv[i][0] == '-' && argv[i][1] == 'w') |
84 |
< |
warnings = !warnings; |
84 |
> |
switch (argv[i][2]) { |
85 |
> |
case '\0': |
86 |
> |
warnings = !warnings; |
87 |
> |
break; |
88 |
> |
case '+': |
89 |
> |
case 'T': case 't': |
90 |
> |
case 'Y': case 'y': |
91 |
> |
case '1': |
92 |
> |
warnings = 1; |
93 |
> |
break; |
94 |
> |
case '-': |
95 |
> |
case 'F': case 'f': |
96 |
> |
case 'N': case 'n': |
97 |
> |
case '0': |
98 |
> |
warnings = 0; |
99 |
> |
break; |
100 |
> |
} |
101 |
|
} |
102 |
< |
if ((gargc = i) < 2) |
84 |
< |
error(USER, "too few arguments"); |
102 |
> |
gargc = i; |
103 |
|
rtargc--; |
104 |
|
for (i = 0; myrtopts[i] != NULL; i++) |
105 |
|
rtargv[rtargc++] = myrtopts[i]; |
107 |
|
rtargv[rtargc] = NULL; |
108 |
|
/* just asking for defaults? */ |
109 |
|
if (!strcmp(argv[gargc-1], "-defaults")) { |
110 |
+ |
printopts(); fflush(stdout); |
111 |
|
rtpath = getpath(rtargv[0], getenv("PATH"), X_OK); |
112 |
|
if (rtpath == NULL) { |
113 |
|
eputs(rtargv[0]); |
118 |
|
perror(rtpath); |
119 |
|
exit(1); |
120 |
|
} |
121 |
+ |
if (gargc < 2 || argv[gargc-1][0] == '-') |
122 |
+ |
error(USER, "missing octree argument"); |
123 |
|
/* else initialize and run our calculation */ |
124 |
|
init(); |
125 |
|
if (gargc+1 < argc) |
165 |
|
/* set up signal handling */ |
166 |
|
signal(SIGPIPE, quit); |
167 |
|
/* start rtrace process */ |
168 |
+ |
errno = 0; |
169 |
|
maxbytes = open_process(rt.pd, rtargv); |
170 |
|
if (maxbytes == 0) { |
171 |
|
eputs(rtargv[0]); |
181 |
|
error(SYSTEM, "out of memory in init"); |
182 |
|
rt.nrays = 0; |
183 |
|
/* set up urand */ |
184 |
< |
initurand(2048); |
184 |
> |
initurand(16384); |
185 |
|
} |
186 |
|
|
187 |
|
|
264 |
|
case 'm': /* material name */ |
265 |
|
if (*++cp != '=') |
266 |
|
break; |
267 |
< |
if (!*++cp) |
267 |
> |
if (!*++cp || isspace(*cp)) |
268 |
|
break; |
269 |
|
atos(thisillum.matname, MAXSTR, cp); |
270 |
|
cp = sskip(cp); |
276 |
|
case 'f': /* data file name */ |
277 |
|
if (*++cp != '=') |
278 |
|
break; |
279 |
< |
if (!*++cp) { |
279 |
> |
if (!*++cp || isspace(*cp)) { |
280 |
|
strcpy(thisillum.datafile,thisillum.matname); |
281 |
+ |
thisillum.dfnum = 0; |
282 |
|
thisillum.flags &= ~IL_DATCLB; |
283 |
|
continue; |
284 |
|
} |
349 |
|
break; |
350 |
|
cp++; |
351 |
|
continue; |
352 |
+ |
case 'b': /* brightness */ |
353 |
+ |
if (*++cp != '=') |
354 |
+ |
break; |
355 |
+ |
if (!isfltd(++cp, " \t\n")) |
356 |
+ |
break; |
357 |
+ |
thisillum.minbrt = atof(cp); |
358 |
+ |
if (thisillum.minbrt < 0.) |
359 |
+ |
thisillum.minbrt = 0.; |
360 |
+ |
cp = sskip(cp); |
361 |
+ |
continue; |
362 |
|
case 'o': /* output file */ |
363 |
|
if (*++cp != '=') |
364 |
|
break; |
365 |
< |
if (!*++cp) |
365 |
> |
if (!*++cp || isspace(*cp)) |
366 |
|
break; |
367 |
|
atos(buf, sizeof(buf), cp); |
368 |
|
cp = sskip(cp); |
380 |
|
return; |
381 |
|
} |
382 |
|
opterr: /* skip faulty option */ |
383 |
< |
cp = sskip(cp); |
383 |
> |
while (*cp && !isspace(*cp)) |
384 |
> |
cp++; |
385 |
|
nerrs++; |
386 |
|
} |
387 |
|
/* print header? */ |
397 |
|
} |
398 |
|
/* print pure comment */ |
399 |
|
printf("# %s", s+2); |
400 |
+ |
} |
401 |
+ |
|
402 |
+ |
|
403 |
+ |
printopts() /* print out option default values */ |
404 |
+ |
{ |
405 |
+ |
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
406 |
+ |
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
407 |
+ |
if (thisillum.flags & IL_COLAVG) |
408 |
+ |
if (thisillum.flags & IL_COLDST) |
409 |
+ |
printf("c=d\t\t\t\t# color distribution\n"); |
410 |
+ |
else |
411 |
+ |
printf("c=a\t\t\t\t# color average\n"); |
412 |
+ |
else |
413 |
+ |
printf("c=n\t\t\t\t# color none\n"); |
414 |
+ |
if (thisillum.flags & IL_LIGHT) |
415 |
+ |
printf("l+\t\t\t\t# light type on\n"); |
416 |
+ |
else |
417 |
+ |
printf("l-\t\t\t\t# light type off\n"); |
418 |
+ |
printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens); |
419 |
+ |
printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps); |
420 |
+ |
printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt); |
421 |
|
} |
422 |
|
|
423 |
|
|