--- ray/src/rt/rxcmain.cpp 2024/11/06 19:45:59 2.6 +++ ray/src/rt/rxcmain.cpp 2024/12/23 16:15:38 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rxcmain.cpp,v 2.6 2024/11/06 19:45:59 greg Exp $"; +static const char RCSid[] = "$Id: rxcmain.cpp,v 2.11 2024/12/23 16:15:38 greg Exp $"; #endif /* * rxcmain.c - main for rxcontrib ray contribution tracer @@ -42,8 +42,8 @@ printdefaults(void) /* print default values to stdou { printf("-c %-5d\t\t\t# accumulated rays per record\n", myRCmanager.accum); printf(myRCmanager.HasFlag(RCcontrib) ? - "-V+\t\t\t\t# output contributions" : - "-V-\t\t\t\t# output coefficients"); + "-V+\t\t\t\t# output contributions\n" : + "-V-\t\t\t\t# output coefficients\n"); if (myRCmanager.HasFlag(RTimmIrrad)) printf("-I+\t\t\t\t# immediate irradiance on\n"); printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc); @@ -96,18 +96,6 @@ sigdie( /* set fatal signal */ sigerr[signo] = msg; } -const char * -formstr(int f) // return format identifier -{ - switch (f) { - case 'a': return("ascii"); - case 'f': return("float"); - case 'd': return("double"); - case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); - } - return("unknown"); -} - /* set input/output format */ static void setformat(const char *fmt) @@ -144,6 +132,23 @@ fmterr: error(USER, errmsg); } +/* Set default options */ +static void +default_options(void) +{ + rand_samp = 1; + dstrsrc = 0.9; + directrelay = 3; + vspretest = 512; + srcsizerat = .2; + specthresh = .02; + specjitter = 1.; + maxdepth = -10; + minweight = 2e-3; + ambres = 256; + ambdiv = 350; + ambounce = 1; +} /* Set overriding options */ static void @@ -154,7 +159,6 @@ override_options(void) ambacc = 0; } - int main(int argc, char *argv[]) { @@ -185,6 +189,8 @@ main(int argc, char *argv[]) /* initialize calcomp routines early */ initfunc(); calcontext(RCCONTEXT); + /* set rcontrib defaults */ + default_options(); /* option city */ for (i = 1; i < argc; i++) { /* expand arguments */ @@ -349,7 +355,7 @@ main(int argc, char *argv[]) // rval = # rows recovered rval = myRCmanager.PrepOutput(); // check if recovered everything - if (recover && rval >= myRCmanager.GetRowMax()) { + if (rval >= myRCmanager.GetRowMax()) { error(WARNING, "nothing left to compute"); quit(0); } // add processes as requested @@ -409,7 +415,7 @@ getRayBundle(FVECT *orig_dir = NULL) int n2go = myRCmanager.accum; switch (inpfmt) { - case 'a': // ASCII input + case 'a': // ASCII input if (!orig_dir) return skipWords(6*n2go); while (n2go-- > 0) { @@ -422,12 +428,13 @@ getRayBundle(FVECT *orig_dir = NULL) orig_dir += 2; } break; - case 'f': // float input + case 'f': // float input if (!orig_dir) return skipBytes(6*sizeof(float)*n2go); #ifdef SMLFLT if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) return false; + orig_dir += 2*n2go; #else while (n2go-- > 0) { float fvecs[6]; @@ -439,12 +446,13 @@ getRayBundle(FVECT *orig_dir = NULL) } #endif break; - case 'd': // double input + case 'd': // double input if (!orig_dir) return skipBytes(6*sizeof(double)*n2go); #ifndef SMLFLT if (getbinary(orig_dir, sizeof(FVECT), 2*n2go, stdin) != 2*n2go) return false; + orig_dir += 2*n2go; #else while (n2go-- > 0) { double dvecs[6]; @@ -460,13 +468,10 @@ getRayBundle(FVECT *orig_dir = NULL) error(INTERNAL, "unsupported format in getRayBundle()"); return false; } - int warned = 0; // normalize directions - n2go = myRCmanager.accum; + n2go = myRCmanager.accum; // normalize directions while (n2go-- > 0) { orig_dir -= 2; - if (normalize(orig_dir[1]) == 0) - if (!warned++) - error(WARNING, "zero ray direction on input"); + normalize(orig_dir[1]); } return true; } @@ -494,7 +499,7 @@ rxcontrib(const int rstart) } last_report = tstart = time(0); } - while (r < totRows) { // getting to work... + while (r < totRows) { // loop until done time_t tnow; if (!getRayBundle(odarr)) goto readerr; @@ -503,10 +508,14 @@ rxcontrib(const int rstart) r++; if (report_intvl <= 0) continue; - if ((r < totRows) & ((tnow = time(0)) < last_report+report_intvl)) + tnow = time(0); // time to report progress? + if (r == totRows) + myRCmanager.FlushQueue(); + else if (tnow < last_report+report_intvl) continue; sprintf(errmsg, "%.2f%% done after %.3f hours\n", - 100.*r/totRows, (1./3600.)*(tnow - tstart)); + 100.*myRCmanager.GetRowFinished()/totRows, + (1./3600.)*(tnow - tstart)); eputs(errmsg); last_report = tnow; }