56 |
|
printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n", |
57 |
|
inpfmt, outfmt, formstr(inpfmt), formstr(outfmt)); |
58 |
|
if (report_intvl > 0) |
59 |
< |
printf("-t %-9d\t\t\t# time between reports\n", report_intvl); |
59 |
> |
printf("-t %-9d\t\t\t# time between reports\n", report_intvl); |
60 |
|
printf(erract[WARNING].pf != NULL ? |
61 |
|
"-w+\t\t\t\t# warning messages on\n" : |
62 |
|
"-w-\t\t\t\t# warning messages off\n"); |
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 |
|
|
145 |
– |
|
162 |
|
int |
163 |
|
main(int argc, char *argv[]) |
164 |
|
{ |
189 |
|
/* initialize calcomp routines early */ |
190 |
|
initfunc(); |
191 |
|
calcontext(RCCONTEXT); |
192 |
+ |
/* set rcontrib defaults */ |
193 |
+ |
default_options(); |
194 |
|
/* option city */ |
195 |
|
for (i = 1; i < argc; i++) { |
196 |
|
/* expand arguments */ |
358 |
|
if (rval >= myRCmanager.GetRowMax()) { |
359 |
|
error(WARNING, "nothing left to compute"); |
360 |
|
quit(0); |
361 |
< |
} // add processes as requested |
344 |
< |
myRCmanager.SetThreadCount(nproc); |
345 |
< |
|
361 |
> |
} |
362 |
|
rxcontrib(rval); /* trace ray contributions (loop) */ |
363 |
|
|
364 |
|
quit(0); /* exit clean */ |
413 |
|
int n2go = myRCmanager.accum; |
414 |
|
|
415 |
|
switch (inpfmt) { |
416 |
< |
case 'a': // ASCII input |
416 |
> |
case 'a': // ASCII input |
417 |
|
if (!orig_dir) |
418 |
|
return skipWords(6*n2go); |
419 |
|
while (n2go-- > 0) { |
426 |
|
orig_dir += 2; |
427 |
|
} |
428 |
|
break; |
429 |
< |
case 'f': // float input |
429 |
> |
case 'f': // float input |
430 |
|
if (!orig_dir) |
431 |
|
return skipBytes(6*sizeof(float)*n2go); |
432 |
|
#ifdef SMLFLT |
433 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
434 |
|
return false; |
435 |
+ |
orig_dir += 2*n2go; |
436 |
|
#else |
437 |
|
while (n2go-- > 0) { |
438 |
|
float fvecs[6]; |
444 |
|
} |
445 |
|
#endif |
446 |
|
break; |
447 |
< |
case 'd': // double input |
447 |
> |
case 'd': // double input |
448 |
|
if (!orig_dir) |
449 |
|
return skipBytes(6*sizeof(double)*n2go); |
450 |
|
#ifndef SMLFLT |
451 |
|
if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) |
452 |
|
return false; |
453 |
+ |
orig_dir += 2*n2go; |
454 |
|
#else |
455 |
|
while (n2go-- > 0) { |
456 |
|
double dvecs[6]; |
466 |
|
error(INTERNAL, "unsupported format in getRayBundle()"); |
467 |
|
return false; |
468 |
|
} |
469 |
< |
int warned = 0; // normalize directions |
452 |
< |
n2go = myRCmanager.accum; |
469 |
> |
n2go = myRCmanager.accum; // normalize directions |
470 |
|
while (n2go-- > 0) { |
471 |
|
orig_dir -= 2; |
472 |
< |
if (normalize(orig_dir[1]) == 0) |
456 |
< |
if (!warned++) |
457 |
< |
error(WARNING, "zero ray direction on input"); |
472 |
> |
normalize(orig_dir[1]); |
473 |
|
} |
474 |
|
return true; |
475 |
|
} |
497 |
|
} |
498 |
|
last_report = tstart = time(0); |
499 |
|
} |
500 |
+ |
// start children as requested |
501 |
+ |
myRCmanager.SetThreadCount(nproc); |
502 |
+ |
|
503 |
|
while (r < totRows) { // loop until done |
504 |
|
time_t tnow; |
505 |
|
if (!getRayBundle(odarr)) |
509 |
|
r++; |
510 |
|
if (report_intvl <= 0) |
511 |
|
continue; |
512 |
< |
tnow = time(0); // time to report progress? |
513 |
< |
if (r == totRows) |
514 |
< |
myRCmanager.FlushQueue(); |
515 |
< |
else if (tnow < last_report+report_intvl) |
512 |
> |
if (r == totRows) // need to finish up? |
513 |
> |
myRCmanager.SetThreadCount(1); |
514 |
> |
tnow = time(0); |
515 |
> |
if ((r < totRows) & (tnow < last_report+report_intvl)) |
516 |
|
continue; |
517 |
|
sprintf(errmsg, "%.2f%% done after %.3f hours\n", |
518 |
|
100.*myRCmanager.GetRowFinished()/totRows, |