| 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 (myRCmanager.xres > 0) |
| 51 |
< |
printf("-x %-9d\t\t\t# x resolution\n", myRCmanager.xres); |
| 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" : |
| 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(180); /* allow 3 minutes 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 |
|
|
| 99 |
– |
const char * |
| 100 |
– |
formstr(int f) // return format identifier |
| 101 |
– |
{ |
| 102 |
– |
switch (f) { |
| 103 |
– |
case 'a': return("ascii"); |
| 104 |
– |
case 'f': return("float"); |
| 105 |
– |
case 'd': return("double"); |
| 106 |
– |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
| 107 |
– |
} |
| 108 |
– |
return("unknown"); |
| 109 |
– |
} |
| 110 |
– |
|
| 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 |
|
|
| 157 |
– |
|
| 161 |
|
int |
| 162 |
|
main(int argc, char *argv[]) |
| 163 |
|
{ |
| 188 |
|
/* initialize calcomp routines early */ |
| 189 |
|
initfunc(); |
| 190 |
|
calcontext(RCCONTEXT); |
| 191 |
+ |
/* set rcontrib defaults */ |
| 192 |
+ |
default_options(); |
| 193 |
|
/* option city */ |
| 194 |
|
for (i = 1; i < argc; i++) { |
| 195 |
|
/* expand arguments */ |
| 354 |
|
// rval = # rows recovered |
| 355 |
|
rval = myRCmanager.PrepOutput(); |
| 356 |
|
// check if recovered everything |
| 357 |
< |
if (recover && rval >= myRCmanager.GetRowMax()) { |
| 357 |
> |
if (rval >= myRCmanager.GetRowMax()) { |
| 358 |
|
error(WARNING, "nothing left to compute"); |
| 359 |
|
quit(0); |
| 360 |
< |
} // add processes as requested |
| 356 |
< |
myRCmanager.SetThreadCount(nproc); |
| 357 |
< |
|
| 360 |
> |
} |
| 361 |
|
rxcontrib(rval); /* trace ray contributions (loop) */ |
| 362 |
|
|
| 363 |
|
quit(0); /* exit clean */ |
| 412 |
|
int n2go = myRCmanager.accum; |
| 413 |
|
|
| 414 |
|
switch (inpfmt) { |
| 415 |
< |
case 'a': // ASCII input |
| 415 |
> |
case 'a': // ASCII input |
| 416 |
|
if (!orig_dir) |
| 417 |
|
return skipWords(6*n2go); |
| 418 |
|
while (n2go-- > 0) { |
| 425 |
|
orig_dir += 2; |
| 426 |
|
} |
| 427 |
|
break; |
| 428 |
< |
case 'f': // float input |
| 428 |
> |
case 'f': // float input |
| 429 |
|
if (!orig_dir) |
| 430 |
|
return skipBytes(6*sizeof(float)*n2go); |
| 431 |
|
#ifdef SMLFLT |
| 432 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 433 |
|
return false; |
| 434 |
+ |
orig_dir += 2*n2go; |
| 435 |
|
#else |
| 436 |
|
while (n2go-- > 0) { |
| 437 |
|
float fvecs[6]; |
| 443 |
|
} |
| 444 |
|
#endif |
| 445 |
|
break; |
| 446 |
< |
case 'd': // double input |
| 446 |
> |
case 'd': // double input |
| 447 |
|
if (!orig_dir) |
| 448 |
|
return skipBytes(6*sizeof(double)*n2go); |
| 449 |
|
#ifndef SMLFLT |
| 450 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 451 |
|
return false; |
| 452 |
+ |
orig_dir += 2*n2go; |
| 453 |
|
#else |
| 454 |
|
while (n2go-- > 0) { |
| 455 |
|
double dvecs[6]; |
| 465 |
|
error(INTERNAL, "unsupported format in getRayBundle()"); |
| 466 |
|
return false; |
| 467 |
|
} |
| 468 |
< |
int warned = 0; // normalize directions |
| 464 |
< |
n2go = myRCmanager.accum; |
| 468 |
> |
n2go = myRCmanager.accum; // normalize directions |
| 469 |
|
while (n2go-- > 0) { |
| 470 |
|
orig_dir -= 2; |
| 471 |
< |
if (normalize(orig_dir[1]) == 0) |
| 468 |
< |
if (!warned++) |
| 469 |
< |
error(WARNING, "zero ray direction on input"); |
| 471 |
> |
normalize(orig_dir[1]); |
| 472 |
|
} |
| 473 |
|
return true; |
| 474 |
|
} |
| 496 |
|
} |
| 497 |
|
last_report = tstart = time(0); |
| 498 |
|
} |
| 499 |
< |
while (r < totRows) { // getting to work... |
| 499 |
> |
// start children as requested |
| 500 |
> |
myRCmanager.SetThreadCount(nproc); |
| 501 |
> |
|
| 502 |
> |
while (r < totRows) { // loop until done |
| 503 |
|
time_t tnow; |
| 504 |
|
if (!getRayBundle(odarr)) |
| 505 |
|
goto readerr; |
| 508 |
|
r++; |
| 509 |
|
if (report_intvl <= 0) |
| 510 |
|
continue; |
| 511 |
< |
if ((r < totRows) & ((tnow = time(0)) < last_report+report_intvl)) |
| 511 |
> |
if (r == totRows) // need to finish up? |
| 512 |
> |
myRCmanager.SetThreadCount(1); |
| 513 |
> |
tnow = time(0); |
| 514 |
> |
if ((r < totRows) & (tnow < last_report+report_intvl)) |
| 515 |
|
continue; |
| 516 |
|
sprintf(errmsg, "%.2f%% done after %.3f hours\n", |
| 517 |
< |
100.*r/totRows, (1./3600.)*(tnow - tstart)); |
| 517 |
> |
100.*myRCmanager.GetRowFinished()/totRows, |
| 518 |
> |
(1./3600.)*(tnow - tstart)); |
| 519 |
|
eputs(errmsg); |
| 520 |
|
last_report = tnow; |
| 521 |
|
} |
| 567 |
|
int code |
| 568 |
|
) |
| 569 |
|
{ |
| 570 |
< |
if (!code && myRCmanager.Ready()) // clean up on normal exit |
| 562 |
< |
code = myRCmanager.Cleanup(); |
| 570 |
> |
myRCmanager.FlushQueue(); // leave nothing in queue |
| 571 |
|
|
| 572 |
|
exit(code); |
| 573 |
|
} |