| 1 |
– |
/* Copyright (c) 1995 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 |
|
|
| 11 |
– |
#include "mkillum.h" |
| 12 |
– |
|
| 8 |
|
#include <signal.h> |
| 14 |
– |
|
| 9 |
|
#include <ctype.h> |
| 10 |
|
|
| 11 |
+ |
#include "platform.h" |
| 12 |
+ |
#include "mkillum.h" |
| 13 |
+ |
#include "random.h" |
| 14 |
+ |
|
| 15 |
|
/* default parameters */ |
| 16 |
|
#define SAMPDENS 48 /* points per projected steradian */ |
| 17 |
|
#define NSAMPS 32 /* samples per point */ |
| 25 |
|
|
| 26 |
|
/* rtrace command and defaults */ |
| 27 |
|
char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-", |
| 28 |
< |
"-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", }; |
| 28 |
> |
"-ab", "2", "-ad", "1024", "-as", "512", "-aa", ".1", }; |
| 29 |
|
int rtargc = 14; |
| 30 |
|
/* overriding rtrace options */ |
| 31 |
|
char *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-", |
| 58 |
|
|
| 59 |
|
int warnings = 1; /* print warnings? */ |
| 60 |
|
|
| 61 |
< |
extern char *fgetline(), *fgetword(), *sskip(), |
| 62 |
< |
*atos(), *iskip(), *fskip(), *strcpy(); |
| 63 |
< |
extern FILE *popen(); |
| 61 |
> |
void init(void); |
| 62 |
> |
void filter(register FILE *infp, char *name); |
| 63 |
> |
void xoptions(char *s, char *nm); |
| 64 |
> |
void printopts(void); |
| 65 |
> |
void printhead(register int ac, register char **av); |
| 66 |
> |
void xobject(FILE *fp, char *nm); |
| 67 |
|
|
| 68 |
|
|
| 69 |
< |
main(argc, argv) /* compute illum distributions using rtrace */ |
| 70 |
< |
int argc; |
| 71 |
< |
char *argv[]; |
| 69 |
> |
int |
| 70 |
> |
main( /* compute illum distributions using rtrace */ |
| 71 |
> |
int argc, |
| 72 |
> |
char *argv[] |
| 73 |
> |
) |
| 74 |
|
{ |
| 72 |
– |
extern char *getenv(), *getpath(); |
| 75 |
|
char *rtpath; |
| 76 |
|
FILE *fp; |
| 77 |
|
register int i; |
| 136 |
|
} |
| 137 |
|
else |
| 138 |
|
filter(stdin, "standard input"); |
| 139 |
< |
quit(0); |
| 139 |
> |
return 0; |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
+ |
void |
| 144 |
|
quit(status) /* exit with status */ |
| 145 |
|
int status; |
| 146 |
|
{ |
| 147 |
|
int rtstat; |
| 148 |
|
|
| 149 |
< |
rtstat = close_process(rt.pd); |
| 150 |
< |
if (status == 0) |
| 149 |
> |
rtstat = close_process(&(rt.pd)); |
| 150 |
> |
if (status == 0) { |
| 151 |
|
if (rtstat < 0) |
| 152 |
|
error(WARNING, |
| 153 |
|
"unknown return status from rtrace process"); |
| 154 |
|
else |
| 155 |
|
status = rtstat; |
| 156 |
+ |
} |
| 157 |
|
exit(status); |
| 158 |
|
} |
| 159 |
|
|
| 160 |
< |
|
| 161 |
< |
init() /* start rtrace and set up buffers */ |
| 160 |
> |
void |
| 161 |
> |
init(void) /* start rtrace and set up buffers */ |
| 162 |
|
{ |
| 163 |
|
extern int o_face(), o_sphere(), o_ring(); |
| 164 |
|
int maxbytes; |
| 167 |
|
ofun[OBJ_SPHERE].funp = o_sphere; |
| 168 |
|
ofun[OBJ_RING].funp = o_ring; |
| 169 |
|
/* set up signal handling */ |
| 170 |
+ |
#ifdef SIGPIPE /* not present on Windows */ |
| 171 |
|
signal(SIGPIPE, quit); |
| 172 |
+ |
#endif |
| 173 |
|
/* start rtrace process */ |
| 174 |
|
errno = 0; |
| 175 |
< |
maxbytes = open_process(rt.pd, rtargv); |
| 175 |
> |
maxbytes = open_process(&(rt.pd), rtargv); |
| 176 |
|
if (maxbytes == 0) { |
| 177 |
|
eputs(rtargv[0]); |
| 178 |
|
eputs(": command not found\n"); |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
|
| 194 |
< |
eputs(s) /* put string to stderr */ |
| 195 |
< |
register char *s; |
| 194 |
> |
void |
| 195 |
> |
eputs( /* put string to stderr */ |
| 196 |
> |
register char *s |
| 197 |
> |
) |
| 198 |
|
{ |
| 199 |
|
static int midline = 0; |
| 200 |
|
|
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
|
| 211 |
+ |
void |
| 212 |
|
wputs(s) /* print warning if enabled */ |
| 213 |
|
char *s; |
| 214 |
|
{ |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
< |
filter(infp, name) /* process stream */ |
| 221 |
< |
register FILE *infp; |
| 222 |
< |
char *name; |
| 220 |
> |
void |
| 221 |
> |
filter( /* process stream */ |
| 222 |
> |
register FILE *infp, |
| 223 |
> |
char *name |
| 224 |
> |
) |
| 225 |
|
{ |
| 226 |
|
char buf[512]; |
| 227 |
|
FILE *pfp; |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
|
| 254 |
< |
xoptions(s, nm) /* process options in string s */ |
| 255 |
< |
char *s; |
| 256 |
< |
char *nm; |
| 254 |
> |
void |
| 255 |
> |
xoptions( /* process options in string s */ |
| 256 |
> |
char *s, |
| 257 |
> |
char *nm |
| 258 |
> |
) |
| 259 |
|
{ |
| 260 |
|
extern FILE *freopen(); |
| 261 |
|
char buf[64]; |
| 272 |
|
case ' ': |
| 273 |
|
case '\t': |
| 274 |
|
case '\n': |
| 275 |
+ |
case '\r': |
| 276 |
+ |
case '\f': |
| 277 |
|
cp++; |
| 278 |
|
continue; |
| 279 |
|
case 'm': /* material name */ |
| 341 |
|
case 'd': /* point sample density */ |
| 342 |
|
if (*++cp != '=') |
| 343 |
|
break; |
| 344 |
< |
if (!isintd(++cp, " \t\n")) |
| 344 |
> |
if (!isintd(++cp, " \t\n\r")) |
| 345 |
|
break; |
| 346 |
|
thisillum.sampdens = atoi(cp); |
| 347 |
|
cp = sskip(cp); |
| 349 |
|
case 's': /* point super-samples */ |
| 350 |
|
if (*++cp != '=') |
| 351 |
|
break; |
| 352 |
< |
if (!isintd(++cp, " \t\n")) |
| 352 |
> |
if (!isintd(++cp, " \t\n\r")) |
| 353 |
|
break; |
| 354 |
|
thisillum.nsamps = atoi(cp); |
| 355 |
|
cp = sskip(cp); |
| 367 |
|
case 'b': /* brightness */ |
| 368 |
|
if (*++cp != '=') |
| 369 |
|
break; |
| 370 |
< |
if (!isfltd(++cp, " \t\n")) |
| 370 |
> |
if (!isfltd(++cp, " \t\n\r")) |
| 371 |
|
break; |
| 372 |
|
thisillum.minbrt = atof(cp); |
| 373 |
|
if (thisillum.minbrt < 0.) |
| 414 |
|
printf("# %s", s+2); |
| 415 |
|
} |
| 416 |
|
|
| 417 |
< |
|
| 418 |
< |
printopts() /* print out option default values */ |
| 417 |
> |
void |
| 418 |
> |
printopts(void) /* print out option default values */ |
| 419 |
|
{ |
| 420 |
|
printf("m=%-15s\t\t# material name\n", thisillum.matname); |
| 421 |
|
printf("f=%-15s\t\t# data file name\n", thisillum.datafile); |
| 436 |
|
} |
| 437 |
|
|
| 438 |
|
|
| 439 |
< |
printhead(ac, av) /* print out header */ |
| 440 |
< |
register int ac; |
| 441 |
< |
register char **av; |
| 439 |
> |
void |
| 440 |
> |
printhead( /* print out header */ |
| 441 |
> |
register int ac, |
| 442 |
> |
register char **av |
| 443 |
> |
) |
| 444 |
|
{ |
| 445 |
|
putchar('#'); |
| 446 |
|
while (ac-- > 0) { |
| 451 |
|
} |
| 452 |
|
|
| 453 |
|
|
| 454 |
< |
xobject(fp, nm) /* translate an object from fp */ |
| 455 |
< |
FILE *fp; |
| 456 |
< |
char *nm; |
| 454 |
> |
void |
| 455 |
> |
xobject( /* translate an object from fp */ |
| 456 |
> |
FILE *fp, |
| 457 |
> |
char *nm |
| 458 |
> |
) |
| 459 |
|
{ |
| 460 |
|
OBJREC thisobj; |
| 461 |
|
char str[MAXSTR]; |
| 466 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 467 |
|
goto readerr; |
| 468 |
|
/* is it an alias? */ |
| 469 |
< |
if (!strcmp(str, ALIASID)) { |
| 469 |
> |
if (!strcmp(str, ALIASKEY)) { |
| 470 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 471 |
|
goto readerr; |
| 472 |
< |
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
| 472 |
> |
printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str); |
| 473 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 474 |
|
goto readerr; |
| 475 |
|
printf("\t%s\n", str); |