| 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); |
| 52 |
< |
printf("-y %-9d\t\t\t# y resolution\n", yres); |
| 50 |
> |
if (myRCmanager.xres > 0) |
| 51 |
> |
printf("-x %-9d\t\t\t# x resolution\n", myRCmanager.xres); |
| 52 |
> |
printf("-y %-9d\t\t\t# y resolution\n", myRCmanager.yres); |
| 53 |
|
printf(myRCmanager.HasFlag(RTlimDist) ? |
| 54 |
|
"-ld+\t\t\t\t# limit distance on\n" : |
| 55 |
|
"-ld-\t\t\t\t# limit distance off\n"); |
| 75 |
|
_exit(signo); |
| 76 |
|
|
| 77 |
|
#ifdef SIGALRM |
| 78 |
< |
alarm(15); /* allow 15 seconds to clean up */ |
| 78 |
> |
alarm(180); /* allow 3 minutes to clean up */ |
| 79 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
| 80 |
|
#endif |
| 81 |
|
eputs("signal - "); |
| 96 |
|
sigerr[signo] = msg; |
| 97 |
|
} |
| 98 |
|
|
| 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 |
– |
|
| 99 |
|
/* set input/output format */ |
| 100 |
|
static void |
| 101 |
|
setformat(const char *fmt) |
| 132 |
|
error(USER, errmsg); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
+ |
/* Set default options */ |
| 136 |
+ |
static void |
| 137 |
+ |
default_options(void) |
| 138 |
+ |
{ |
| 139 |
+ |
rand_samp = 1; |
| 140 |
+ |
dstrsrc = 0.9; |
| 141 |
+ |
directrelay = 3; |
| 142 |
+ |
vspretest = 512; |
| 143 |
+ |
srcsizerat = .2; |
| 144 |
+ |
specthresh = .02; |
| 145 |
+ |
specjitter = 1.; |
| 146 |
+ |
maxdepth = -10; |
| 147 |
+ |
minweight = 2e-3; |
| 148 |
+ |
ambres = 256; |
| 149 |
+ |
ambdiv = 350; |
| 150 |
+ |
ambounce = 1; |
| 151 |
+ |
} |
| 152 |
|
|
| 153 |
|
/* Set overriding options */ |
| 154 |
|
static void |
| 159 |
|
ambacc = 0; |
| 160 |
|
} |
| 161 |
|
|
| 156 |
– |
|
| 162 |
|
int |
| 163 |
|
main(int argc, char *argv[]) |
| 164 |
|
{ |
| 189 |
|
/* initialize calcomp routines early */ |
| 190 |
|
initfunc(); |
| 191 |
|
calcontext(RCCONTEXT); |
| 192 |
< |
esupport &= ~E_REDEFW; /* temporary */ |
| 192 |
> |
/* set rcontrib defaults */ |
| 193 |
> |
default_options(); |
| 194 |
|
/* option city */ |
| 195 |
|
for (i = 1; i < argc; i++) { |
| 196 |
|
/* expand arguments */ |
| 225 |
|
nproc = 1; |
| 226 |
|
break; |
| 227 |
|
case 'V': /* output contributions? */ |
| 228 |
< |
check_bool(2,contrib); |
| 228 |
> |
rval = myRCmanager.HasFlag(RCcontrib); |
| 229 |
> |
check_bool(2,rval); |
| 230 |
> |
myRCmanager.SetFlag(RCcontrib, rval); |
| 231 |
|
break; |
| 232 |
|
case 'x': /* x resolution */ |
| 233 |
|
check(2,"i"); |
| 234 |
< |
xres = atoi(argv[++i]); |
| 234 |
> |
myRCmanager.xres = atoi(argv[++i]); |
| 235 |
|
break; |
| 236 |
|
case 'y': /* y resolution */ |
| 237 |
|
check(2,"i"); |
| 238 |
< |
yres = atoi(argv[++i]); |
| 238 |
> |
myRCmanager.yres = atoi(argv[++i]); |
| 239 |
|
break; |
| 240 |
|
case 'w': /* warnings on/off */ |
| 241 |
|
rval = (erract[WARNING].pf != NULL); |
| 315 |
|
if (i != argc-1) |
| 316 |
|
error(USER, "expected single octree argument"); |
| 317 |
|
|
| 310 |
– |
esupport |= E_REDEFW; |
| 318 |
|
override_options(); /* override some option settings */ |
| 319 |
|
|
| 320 |
|
if (!myRCmanager.GetOutput()) // check that we have work to do |
| 355 |
|
// rval = # rows recovered |
| 356 |
|
rval = myRCmanager.PrepOutput(); |
| 357 |
|
// check if recovered everything |
| 358 |
< |
if (recover && rval >= myRCmanager.GetRowMax()) { |
| 358 |
> |
if (rval >= myRCmanager.GetRowMax()) { |
| 359 |
|
error(WARNING, "nothing left to compute"); |
| 360 |
|
quit(0); |
| 361 |
|
} // add processes as requested |
| 415 |
|
int n2go = myRCmanager.accum; |
| 416 |
|
|
| 417 |
|
switch (inpfmt) { |
| 418 |
< |
case 'a': // ASCII input |
| 418 |
> |
case 'a': // ASCII input |
| 419 |
|
if (!orig_dir) |
| 420 |
|
return skipWords(6*n2go); |
| 421 |
|
while (n2go-- > 0) { |
| 428 |
|
orig_dir += 2; |
| 429 |
|
} |
| 430 |
|
break; |
| 431 |
< |
case 'f': // float input |
| 431 |
> |
case 'f': // float input |
| 432 |
|
if (!orig_dir) |
| 433 |
|
return skipBytes(6*sizeof(float)*n2go); |
| 434 |
|
#ifdef SMLFLT |
| 435 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 436 |
|
return false; |
| 437 |
+ |
orig_dir += 2*n2go; |
| 438 |
|
#else |
| 439 |
|
while (n2go-- > 0) { |
| 440 |
|
float fvecs[6]; |
| 446 |
|
} |
| 447 |
|
#endif |
| 448 |
|
break; |
| 449 |
< |
case 'd': // double input |
| 449 |
> |
case 'd': // double input |
| 450 |
|
if (!orig_dir) |
| 451 |
|
return skipBytes(6*sizeof(double)*n2go); |
| 452 |
|
#ifndef SMLFLT |
| 453 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
| 454 |
|
return false; |
| 455 |
+ |
orig_dir += 2*n2go; |
| 456 |
|
#else |
| 457 |
|
while (n2go-- > 0) { |
| 458 |
|
double dvecs[6]; |
| 468 |
|
error(INTERNAL, "unsupported format in getRayBundle()"); |
| 469 |
|
return false; |
| 470 |
|
} |
| 471 |
< |
int warned = 0; // normalize directions |
| 463 |
< |
n2go = myRCmanager.accum; |
| 471 |
> |
n2go = myRCmanager.accum; // normalize directions |
| 472 |
|
while (n2go-- > 0) { |
| 473 |
|
orig_dir -= 2; |
| 474 |
< |
if (normalize(orig_dir[1]) == 0) |
| 467 |
< |
if (!warned++) |
| 468 |
< |
error(WARNING, "zero ray direction on input"); |
| 474 |
> |
normalize(orig_dir[1]); |
| 475 |
|
} |
| 476 |
|
return true; |
| 477 |
|
} |
| 499 |
|
} |
| 500 |
|
last_report = tstart = time(0); |
| 501 |
|
} |
| 502 |
< |
while (r < totRows) { // getting to work... |
| 502 |
> |
while (r < totRows) { // loop until done |
| 503 |
|
time_t tnow; |
| 504 |
|
if (!getRayBundle(odarr)) |
| 505 |
|
goto readerr; |
| 506 |
< |
if (myRCmanager.ComputeRecord(odarr) < 0) |
| 506 |
> |
if (myRCmanager.ComputeRecord(odarr) <= 0) |
| 507 |
|
return; // error reported, hopefully... |
| 508 |
|
r++; |
| 509 |
|
if (report_intvl <= 0) |
| 510 |
|
continue; |
| 511 |
< |
if ((r < totRows) & ((tnow = time(0)) < last_report+report_intvl)) |
| 511 |
> |
tnow = time(0); // time to report progress? |
| 512 |
> |
if (r == totRows) |
| 513 |
> |
myRCmanager.FlushQueue(); |
| 514 |
> |
else if (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 |
|
} |