| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include "rholo.h" |
| 12 |
+ |
#include "random.h" |
| 13 |
|
#include "paths.h" |
| 14 |
|
#include <signal.h> |
| 15 |
|
#include <sys/types.h> |
| 26 |
|
|
| 27 |
|
int nowarn = 0; /* turn warnings off? */ |
| 28 |
|
|
| 28 |
– |
double expval = 1.; /* global exposure value */ |
| 29 |
– |
|
| 29 |
|
int ncprocs = 0; /* desired number of compute processes */ |
| 30 |
|
|
| 31 |
|
char *outdev = NULL; /* output device name */ |
| 60 |
|
int force = 0; |
| 61 |
|
/* mark start time */ |
| 62 |
|
starttime = time(NULL); |
| 63 |
+ |
initurand(10240); /* initialize urand */ |
| 64 |
|
progname = argv[0]; /* get arguments */ |
| 65 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
| 66 |
|
switch (argv[i][1]) { |
| 113 |
|
creatholo(&hdg); |
| 114 |
|
} else { /* else load holodeck */ |
| 115 |
|
loadholo(); |
| 116 |
< |
if (vdef(RIF)) /* load RIF if any */ |
| 116 |
> |
/* check settings */ |
| 117 |
> |
checkvalues(); |
| 118 |
> |
/* load RIF if any */ |
| 119 |
> |
if (vdef(RIF)) |
| 120 |
|
getradfile(vval(RIF)); |
| 121 |
+ |
/* set defaults */ |
| 122 |
+ |
setdefaults(NULL); |
| 123 |
|
} |
| 124 |
|
/* initialize */ |
| 125 |
|
initrholo(); |
| 126 |
< |
/* run */ |
| 126 |
> |
/* main loop */ |
| 127 |
|
while (rholo()) |
| 128 |
|
; |
| 129 |
|
/* done */ |
| 338 |
|
sprintf(errmsg, "ignoring all but first %s", vnam(SECTION)); |
| 339 |
|
error(WARNING, errmsg); |
| 340 |
|
} |
| 341 |
+ |
if (!vdef(OCTREE)) { |
| 342 |
+ |
if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL) |
| 343 |
+ |
error(SYSTEM, "out of memory"); |
| 344 |
+ |
sprintf(vval(OCTREE), "%s.oct", froot); |
| 345 |
+ |
vdef(OCTREE)++; |
| 346 |
+ |
} |
| 347 |
+ |
if (!vdef(OBSTRUCTIONS)) { |
| 348 |
+ |
vval(OBSTRUCTIONS) = "T"; |
| 349 |
+ |
vdef(OBSTRUCTIONS)++; |
| 350 |
+ |
} |
| 351 |
+ |
if (!vdef(VDIST)) { |
| 352 |
+ |
vval(VDIST) = "F"; |
| 353 |
+ |
vdef(VDIST)++; |
| 354 |
+ |
} |
| 355 |
+ |
if (!vdef(OCCUPANCY)) { |
| 356 |
+ |
vval(OCCUPANCY) = "U"; |
| 357 |
+ |
vdef(OCCUPANCY)++; |
| 358 |
+ |
} |
| 359 |
+ |
/* append rendering options */ |
| 360 |
+ |
if (vdef(RENDER)) |
| 361 |
+ |
rtargc += wordstring(rtargv+rtargc, vval(RENDER)); |
| 362 |
+ |
|
| 363 |
+ |
if (gp == NULL) /* already initialized? */ |
| 364 |
+ |
return; |
| 365 |
+ |
/* set grid parameters */ |
| 366 |
|
if (sscanf(vval(SECTION), |
| 367 |
|
"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", |
| 368 |
|
&gp->orig[0], &gp->orig[1], &gp->orig[2], |
| 383 |
|
badvalue(GRID); |
| 384 |
|
for (i = 0; i < 3; i++) |
| 385 |
|
gp->grid[i] = len[i]/d + (1.-FTINY); |
| 356 |
– |
if (!vdef(EXPOSURE)) { |
| 357 |
– |
sprintf(errmsg, "%s must be defined", vnam(EXPOSURE)); |
| 358 |
– |
error(USER, errmsg); |
| 359 |
– |
} |
| 360 |
– |
expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ? |
| 361 |
– |
pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE); |
| 362 |
– |
if (!vdef(OCTREE)) { |
| 363 |
– |
if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL) |
| 364 |
– |
error(SYSTEM, "out of memory"); |
| 365 |
– |
sprintf(vval(OCTREE), "%s.oct", froot); |
| 366 |
– |
vdef(OCTREE)++; |
| 367 |
– |
} |
| 368 |
– |
if (!vdef(OBSTRUCTIONS)) { |
| 369 |
– |
vval(OBSTRUCTIONS) = "T"; |
| 370 |
– |
vdef(OBSTRUCTIONS)++; |
| 371 |
– |
} |
| 372 |
– |
if (!vdef(OCCUPANCY)) { |
| 373 |
– |
vval(OCCUPANCY) = "U"; |
| 374 |
– |
vdef(OCCUPANCY)++; |
| 375 |
– |
} |
| 376 |
– |
/* append rendering options */ |
| 377 |
– |
if (vdef(RENDER)) |
| 378 |
– |
rtargc += wordstring(rtargv+rtargc, vval(RENDER)); |
| 386 |
|
} |
| 387 |
|
|
| 388 |
|
|
| 500 |
|
getradfile(rfargs) /* run rad and get needed variables */ |
| 501 |
|
char *rfargs; |
| 502 |
|
{ |
| 503 |
< |
static short mvar[] = {OCTREE,EXPOSURE,-1}; |
| 503 |
> |
static short mvar[] = {OCTREE,-1}; |
| 504 |
|
static char tf1[] = TEMPLATE; |
| 505 |
|
char tf2[64]; |
| 506 |
|
char combuf[256]; |