| 1 |
– |
/* Copyright (c) 1991 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 |
+ |
#include <stdio.h> |
| 11 |
|
|
| 12 |
+ |
#include "standard.h" |
| 13 |
+ |
#include "platform.h" |
| 14 |
+ |
#include "mkillum.h" |
| 15 |
+ |
|
| 16 |
|
/* default parameters */ |
| 17 |
|
#define SAMPDENS 48 /* points per projected steradian */ |
| 18 |
|
#define NSAMPS 32 /* samples per point */ |
| 29 |
|
"-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", }; |
| 30 |
|
int rtargc = 14; |
| 31 |
|
/* overriding rtrace options */ |
| 32 |
< |
char *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", "-y", "0", NULL }; |
| 32 |
> |
char *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-", |
| 33 |
> |
"-fff", "-y", "0", NULL }; |
| 34 |
|
|
| 35 |
|
struct rtproc rt; /* our rtrace process */ |
| 36 |
|
|
| 59 |
|
|
| 60 |
|
int warnings = 1; /* print warnings? */ |
| 61 |
|
|
| 62 |
– |
extern char *fgetline(), *fgetword(), *sskip(), |
| 63 |
– |
*atos(), *iskip(), *fskip(), *strcpy(); |
| 64 |
– |
extern FILE *popen(); |
| 62 |
|
|
| 66 |
– |
|
| 63 |
|
main(argc, argv) /* compute illum distributions using rtrace */ |
| 64 |
|
int argc; |
| 65 |
|
char *argv[]; |
| 66 |
|
{ |
| 71 |
– |
extern char *getenv(), *getpath(); |
| 67 |
|
char *rtpath; |
| 68 |
|
FILE *fp; |
| 69 |
|
register int i; |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
|
| 135 |
+ |
void |
| 136 |
|
quit(status) /* exit with status */ |
| 137 |
|
int status; |
| 138 |
|
{ |
| 139 |
|
int rtstat; |
| 140 |
|
|
| 141 |
< |
rtstat = close_process(rt.pd); |
| 141 |
> |
rtstat = close_process(&(rt.pd)); |
| 142 |
|
if (status == 0) |
| 143 |
|
if (rtstat < 0) |
| 144 |
|
error(WARNING, |
| 158 |
|
ofun[OBJ_SPHERE].funp = o_sphere; |
| 159 |
|
ofun[OBJ_RING].funp = o_ring; |
| 160 |
|
/* set up signal handling */ |
| 161 |
+ |
#ifdef SIGPIPE /* not present on Windows */ |
| 162 |
|
signal(SIGPIPE, quit); |
| 163 |
+ |
#endif |
| 164 |
|
/* start rtrace process */ |
| 165 |
|
errno = 0; |
| 166 |
< |
maxbytes = open_process(rt.pd, rtargv); |
| 166 |
> |
maxbytes = open_process(&(rt.pd), rtargv); |
| 167 |
|
if (maxbytes == 0) { |
| 168 |
|
eputs(rtargv[0]); |
| 169 |
|
eputs(": command not found\n"); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
+ |
void |
| 186 |
|
eputs(s) /* put string to stderr */ |
| 187 |
|
register char *s; |
| 188 |
|
{ |
| 198 |
|
} |
| 199 |
|
|
| 200 |
|
|
| 201 |
+ |
void |
| 202 |
|
wputs(s) /* print warning if enabled */ |
| 203 |
|
char *s; |
| 204 |
|
{ |
| 258 |
|
case ' ': |
| 259 |
|
case '\t': |
| 260 |
|
case '\n': |
| 261 |
+ |
case '\r': |
| 262 |
+ |
case '\f': |
| 263 |
|
cp++; |
| 264 |
|
continue; |
| 265 |
|
case 'm': /* material name */ |
| 266 |
|
if (*++cp != '=') |
| 267 |
|
break; |
| 268 |
< |
if (!*++cp) |
| 268 |
> |
if (!*++cp || isspace(*cp)) |
| 269 |
|
break; |
| 270 |
|
atos(thisillum.matname, MAXSTR, cp); |
| 271 |
|
cp = sskip(cp); |
| 277 |
|
case 'f': /* data file name */ |
| 278 |
|
if (*++cp != '=') |
| 279 |
|
break; |
| 280 |
< |
if (!*++cp) { |
| 280 |
> |
if (!*++cp || isspace(*cp)) { |
| 281 |
|
strcpy(thisillum.datafile,thisillum.matname); |
| 282 |
|
thisillum.dfnum = 0; |
| 283 |
|
thisillum.flags &= ~IL_DATCLB; |
| 327 |
|
case 'd': /* point sample density */ |
| 328 |
|
if (*++cp != '=') |
| 329 |
|
break; |
| 330 |
< |
if (!isintd(++cp, " \t\n")) |
| 330 |
> |
if (!isintd(++cp, " \t\n\r")) |
| 331 |
|
break; |
| 332 |
|
thisillum.sampdens = atoi(cp); |
| 333 |
|
cp = sskip(cp); |
| 335 |
|
case 's': /* point super-samples */ |
| 336 |
|
if (*++cp != '=') |
| 337 |
|
break; |
| 338 |
< |
if (!isintd(++cp, " \t\n")) |
| 338 |
> |
if (!isintd(++cp, " \t\n\r")) |
| 339 |
|
break; |
| 340 |
|
thisillum.nsamps = atoi(cp); |
| 341 |
|
cp = sskip(cp); |
| 353 |
|
case 'b': /* brightness */ |
| 354 |
|
if (*++cp != '=') |
| 355 |
|
break; |
| 356 |
< |
if (!isfltd(++cp, " \t\n")) |
| 356 |
> |
if (!isfltd(++cp, " \t\n\r")) |
| 357 |
|
break; |
| 358 |
|
thisillum.minbrt = atof(cp); |
| 359 |
|
if (thisillum.minbrt < 0.) |
| 363 |
|
case 'o': /* output file */ |
| 364 |
|
if (*++cp != '=') |
| 365 |
|
break; |
| 366 |
< |
if (!*++cp) |
| 366 |
> |
if (!*++cp || isspace(*cp)) |
| 367 |
|
break; |
| 368 |
|
atos(buf, sizeof(buf), cp); |
| 369 |
|
cp = sskip(cp); |
| 381 |
|
return; |
| 382 |
|
} |
| 383 |
|
opterr: /* skip faulty option */ |
| 384 |
< |
cp = sskip(cp); |
| 384 |
> |
while (*cp && !isspace(*cp)) |
| 385 |
> |
cp++; |
| 386 |
|
nerrs++; |
| 387 |
|
} |
| 388 |
|
/* print header? */ |
| 448 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 449 |
|
goto readerr; |
| 450 |
|
/* is it an alias? */ |
| 451 |
< |
if (!strcmp(str, ALIASID)) { |
| 451 |
> |
if (!strcmp(str, ALIASKEY)) { |
| 452 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 453 |
|
goto readerr; |
| 454 |
< |
printf("\n%s %s %s", thisillum.altmat, ALIASID, str); |
| 454 |
> |
printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str); |
| 455 |
|
if (fgetword(str, MAXSTR, fp) == NULL) |
| 456 |
|
goto readerr; |
| 457 |
|
printf("\t%s\n", str); |