| 41 |
|
printdefaults(void) /* print default values to stdout */ |
| 42 |
|
{ |
| 43 |
|
printf("-c %-5d\t\t\t# accumulated rays per record\n", myRCmanager.accum); |
| 44 |
< |
printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-', |
| 45 |
< |
contrib ? "contributions" : "coefficients"); |
| 44 |
> |
printf(myRCmanager.HasFlag(RCcontrib) ? |
| 45 |
> |
"-V+\t\t\t\t# output contributions\n" : |
| 46 |
> |
"-V-\t\t\t\t# output coefficients\n"); |
| 47 |
|
if (myRCmanager.HasFlag(RTimmIrrad)) |
| 48 |
|
printf("-I+\t\t\t\t# immediate irradiance on\n"); |
| 49 |
|
printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); |
| 50 |
< |
if (xres > 0) |
| 51 |
< |
printf("-x %-9d\t\t\t# x resolution\n", xres); |
| 51 |
< |
printf("-y %-9d\t\t\t# y resolution\n", yres); |
| 50 |
> |
printf("-x %-9d\t\t\t# x resolution\n", myRCmanager.xres); |
| 51 |
> |
printf("-y %-9d\t\t\t# y resolution\n", myRCmanager.yres); |
| 52 |
|
printf(myRCmanager.HasFlag(RTlimDist) ? |
| 53 |
|
"-ld+\t\t\t\t# limit distance on\n" : |
| 54 |
|
"-ld-\t\t\t\t# limit distance off\n"); |
| 55 |
|
printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n", |
| 56 |
|
inpfmt, outfmt, formstr(inpfmt), formstr(outfmt)); |
| 57 |
|
if (report_intvl > 0) |
| 58 |
< |
printf("-t %-9d\t\t\t# time between reports\n", report_intvl); |
| 58 |
> |
printf("-t %-9d\t\t\t# time between reports\n", report_intvl); |
| 59 |
|
printf(erract[WARNING].pf != NULL ? |
| 60 |
|
"-w+\t\t\t\t# warning messages on\n" : |
| 61 |
|
"-w-\t\t\t\t# warning messages off\n"); |
| 74 |
|
_exit(signo); |
| 75 |
|
|
| 76 |
|
#ifdef SIGALRM |
| 77 |
< |
alarm(15); /* allow 15 seconds to clean up */ |
| 77 |
> |
alarm(600); /* allow 10 minutes to clean up */ |
| 78 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
| 79 |
|
#endif |
| 80 |
|
eputs("signal - "); |
| 95 |
|
sigerr[signo] = msg; |
| 96 |
|
} |
| 97 |
|
|
| 98 |
– |
const char * |
| 99 |
– |
formstr(int f) // return format identifier |
| 100 |
– |
{ |
| 101 |
– |
switch (f) { |
| 102 |
– |
case 'a': return("ascii"); |
| 103 |
– |
case 'f': return("float"); |
| 104 |
– |
case 'd': return("double"); |
| 105 |
– |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
| 106 |
– |
} |
| 107 |
– |
return("unknown"); |
| 108 |
– |
} |
| 109 |
– |
|
| 98 |
|
/* set input/output format */ |
| 99 |
|
static void |
| 100 |
|
setformat(const char *fmt) |
| 131 |
|
error(USER, errmsg); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
+ |
/* Set default options */ |
| 135 |
+ |
static void |
| 136 |
+ |
default_options(void) |
| 137 |
+ |
{ |
| 138 |
+ |
rand_samp = 1; |
| 139 |
+ |
dstrsrc = 0.9; |
| 140 |
+ |
directrelay = 3; |
| 141 |
+ |
vspretest = 512; |
| 142 |
+ |
srcsizerat = .2; |
| 143 |
+ |
specthresh = .02; |
| 144 |
+ |
specjitter = 1.; |
| 145 |
+ |
maxdepth = -10; |
| 146 |
+ |
minweight = 2e-3; |
| 147 |
+ |
ambres = 256; |
| 148 |
+ |
ambdiv = 350; |
| 149 |
+ |
ambounce = 1; |
| 150 |
+ |
} |
| 151 |
|
|
| 152 |
|
/* Set overriding options */ |
| 153 |
|
static void |
| 158 |
|
ambacc = 0; |
| 159 |
|
} |
| 160 |
|
|
| 156 |
– |
|
| 161 |
|
int |
| 162 |
|
main(int argc, char *argv[]) |
| 163 |
|
{ |
| 188 |
|
/* initialize calcomp routines early */ |
| 189 |
|
initfunc(); |
| 190 |
|
calcontext(RCCONTEXT); |
| 191 |
< |
esupport &= ~E_REDEFW; /* temporary */ |
| 191 |
> |
/* set rcontrib defaults */ |
| 192 |
> |
default_options(); |
| 193 |
|
/* option city */ |
| 194 |
|
for (i = 1; i < argc; i++) { |
| 195 |
|
/* expand arguments */ |
| 224 |
|
nproc = 1; |
| 225 |
|
break; |
| 226 |
|
case 'V': /* output contributions? */ |
| 227 |
< |
check_bool(2,contrib); |
| 227 |
> |
rval = myRCmanager.HasFlag(RCcontrib); |
| 228 |
> |
check_bool(2,rval); |
| 229 |
> |
myRCmanager.SetFlag(RCcontrib, rval); |
| 230 |
|
break; |
| 231 |
|
case 'x': /* x resolution */ |
| 232 |
|
check(2,"i"); |
| 233 |
< |
xres = atoi(argv[++i]); |
| 233 |
> |
myRCmanager.xres = atoi(argv[++i]); |
| 234 |
|
break; |
| 235 |
|
case 'y': /* y resolution */ |
| 236 |
|
check(2,"i"); |
| 237 |
< |
yres = atoi(argv[++i]); |
| 237 |
> |
myRCmanager.yres = atoi(argv[++i]); |
| 238 |
|
break; |
| 239 |
|
case 'w': /* warnings on/off */ |
| 240 |
|
rval = (erract[WARNING].pf != NULL); |
| 314 |
|
if (i != argc-1) |
| 315 |
|
error(USER, "expected single octree argument"); |
| 316 |
|
|
| 310 |
– |
esupport |= E_REDEFW; |
| 317 |
|
override_options(); /* override some option settings */ |
| 318 |
|
|
| 319 |
|
if (!myRCmanager.GetOutput()) // check that we have work to do |
| 344 |
|
myRCmanager.LoadOctree(argv[argc-1]); |
| 345 |
|
// add to header |
| 346 |
|
myRCmanager.AddHeader(argc-1, argv); |
| 347 |
+ |
{ |
| 348 |
+ |
char buf[128] = "SOFTWARE= "; |
| 349 |
+ |
strcpy(buf+10, VersionID); |
| 350 |
+ |
myRCmanager.AddHeader(buf); |
| 351 |
+ |
} |
| 352 |
|
// prepare output files |
| 353 |
|
if (recover) |
| 354 |
|
myRCmanager.outOp = RCOrecover; |
| 359 |
|
// rval = # rows recovered |
| 360 |
|
rval = myRCmanager.PrepOutput(); |
| 361 |
|
// check if recovered everything |
| 362 |
< |
if (recover && rval >= myRCmanager.GetRowMax()) { |
| 362 |
> |
if (rval >= myRCmanager.GetRowMax()) { |
| 363 |
|
error(WARNING, "nothing left to compute"); |
| 364 |
|
quit(0); |
| 365 |
< |
} // add processes as requested |
| 355 |
< |
myRCmanager.SetThreadCount(nproc); |
| 356 |
< |
|
| 365 |
> |
} |
| 366 |
|
rxcontrib(rval); /* trace ray contributions (loop) */ |
| 367 |
|
|
| 368 |
|
quit(0); /* exit clean */ |
| 417 |
|
int n2go = myRCmanager.accum; |
| 418 |
|
|
| 419 |
|
switch (inpfmt) { |
| 420 |
< |
case 'a': // ASCII input |
| 420 |
> |
case 'a': // ASCII input |
| 421 |
|
if (!orig_dir) |
| 422 |
|
return skipWords(6*n2go); |
| 423 |
|
while (n2go-- > 0) { |
| 430 |
|
orig_dir += 2; |
| 431 |
|
} |
| 432 |
|
break; |
| 433 |
< |
case 'f': // float input |
| 433 |
> |
case 'f': // float input |
| 434 |
|
if (!orig_dir) |
| 435 |
|
return skipBytes(6*sizeof(float)*n2go); |
| 436 |
|
#ifdef SMLFLT |
| 437 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 438 |
|
return false; |
| 439 |
+ |
orig_dir += 2*n2go; |
| 440 |
|
#else |
| 441 |
|
while (n2go-- > 0) { |
| 442 |
|
float fvecs[6]; |
| 448 |
|
} |
| 449 |
|
#endif |
| 450 |
|
break; |
| 451 |
< |
case 'd': // double input |
| 451 |
> |
case 'd': // double input |
| 452 |
|
if (!orig_dir) |
| 453 |
|
return skipBytes(6*sizeof(double)*n2go); |
| 454 |
|
#ifndef SMLFLT |
| 455 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 456 |
|
return false; |
| 457 |
+ |
orig_dir += 2*n2go; |
| 458 |
|
#else |
| 459 |
|
while (n2go-- > 0) { |
| 460 |
|
double dvecs[6]; |
| 470 |
|
error(INTERNAL, "unsupported format in getRayBundle()"); |
| 471 |
|
return false; |
| 472 |
|
} |
| 473 |
< |
int warned = 0; // normalize directions |
| 463 |
< |
n2go = myRCmanager.accum; |
| 473 |
> |
n2go = myRCmanager.accum; // normalize directions |
| 474 |
|
while (n2go-- > 0) { |
| 475 |
|
orig_dir -= 2; |
| 476 |
< |
if (normalize(orig_dir[1]) == 0) |
| 467 |
< |
if (!warned++) |
| 468 |
< |
error(WARNING, "zero ray direction on input"); |
| 476 |
> |
normalize(orig_dir[1]); |
| 477 |
|
} |
| 478 |
|
return true; |
| 479 |
|
} |
| 501 |
|
} |
| 502 |
|
last_report = tstart = time(0); |
| 503 |
|
} |
| 504 |
< |
while (r < totRows) { // getting to work... |
| 504 |
> |
// start children as requested |
| 505 |
> |
myRCmanager.SetThreadCount(nproc); |
| 506 |
> |
|
| 507 |
> |
while (r < totRows) { // loop until done |
| 508 |
|
time_t tnow; |
| 509 |
|
if (!getRayBundle(odarr)) |
| 510 |
|
goto readerr; |
| 511 |
< |
if (myRCmanager.ComputeRecord(odarr) < 0) |
| 511 |
> |
if (myRCmanager.ComputeRecord(odarr) <= 0) |
| 512 |
|
return; // error reported, hopefully... |
| 513 |
|
r++; |
| 514 |
|
if (report_intvl <= 0) |
| 515 |
|
continue; |
| 516 |
< |
if ((r < totRows) & ((tnow = time(0)) < last_report+report_intvl)) |
| 516 |
> |
if (r == totRows) // need to finish up? |
| 517 |
> |
myRCmanager.SetThreadCount(1); |
| 518 |
> |
tnow = time(0); |
| 519 |
> |
if ((r < totRows) & (tnow < last_report+report_intvl)) |
| 520 |
|
continue; |
| 521 |
|
sprintf(errmsg, "%.2f%% done after %.3f hours\n", |
| 522 |
< |
100.*r/totRows, (1./3600.)*(tnow - tstart)); |
| 522 |
> |
100.*myRCmanager.GetRowFinished()/totRows, |
| 523 |
> |
(1./3600.)*(tnow - tstart)); |
| 524 |
|
eputs(errmsg); |
| 525 |
|
last_report = tnow; |
| 526 |
|
} |
| 572 |
|
int code |
| 573 |
|
) |
| 574 |
|
{ |
| 575 |
< |
if (!code && myRCmanager.Ready()) // clean up on normal exit |
| 561 |
< |
code = myRCmanager.Cleanup(); |
| 575 |
> |
myRCmanager.FlushQueue(); // leave nothing in queue |
| 576 |
|
|
| 577 |
|
exit(code); |
| 578 |
|
} |