diff --git a/doc/man/man1/rcontrib.1 b/doc/man/man1/rcontrib.1 index df494eef9..91155b8de 100644 --- a/doc/man/man1/rcontrib.1 +++ b/doc/man/man1/rcontrib.1 @@ -1,4 +1,4 @@ -.\" RCSid "$Id: rcontrib.1,v 1.17 2020/03/14 16:25:46 greg Exp $" +.\" RCSid "$Id: rcontrib.1,v 1.18 2020/09/09 21:28:19 greg Exp $" .TH RCONTRIB 1 5/25/05 RADIANCE .SH NAME rcontrib - compute contribution coefficients in a RADIANCE scene @@ -9,6 +9,8 @@ rcontrib - compute contribution coefficients in a RADIANCE scene ][ .B \-V ][ +.B "\-t secs" +][ .B "\-c count" ][ .B \-fo @@ -119,6 +121,11 @@ Note that output flushing via zero-direction rays is disabled with .I \-c set to zero. .PP +If progress reports are desired, the +.I \-t +option specifies a time interval in seconds for reports sent to +standard error. +.PP The output of .I rcontrib has many potential uses. diff --git a/doc/notes/ReleaseNotes b/doc/notes/ReleaseNotes index 3e0e952e1..bab38db01 100644 --- a/doc/notes/ReleaseNotes +++ b/doc/notes/ReleaseNotes @@ -2387,3 +2387,6 @@ Version 5.4 Added rcollate -c option to force operation to continue even if it seems unnecessary. Made tool more robust. + +Added -t option to rcontrib (and rfluxmtx) to report progress after the +given number of seconds. diff --git a/src/rt/rc3.c b/src/rt/rc3.c index 4be0f8394..3ff7d3291 100644 --- a/src/rt/rc3.c +++ b/src/rt/rc3.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rc3.c,v 2.23 2018/05/27 18:35:57 greg Exp $"; +static const char RCSid[] = "$Id: rc3.c,v 2.24 2020/09/09 21:28:19 greg Exp $"; #endif /* * Accumulate ray contributions for a set of materials @@ -444,7 +444,7 @@ parental_loop() } put_zero_record(++lastray); } - if (raysleft && !--raysleft) + if (!morays()) break; /* preemptive EOI */ } while (next_child_nq(1) >= 0) /* empty results queue */ @@ -529,7 +529,7 @@ feeder_loop() lastdone = lastray = 0; ninq = 0; } - if (raysleft && !--raysleft) + if (!morays()) break; /* preemptive EOI */ } if (ninq) { /* polish off input */ diff --git a/src/rt/rcmain.c b/src/rt/rcmain.c index e0fbac5f0..a0607d6a3 100644 --- a/src/rt/rcmain.c +++ b/src/rt/rcmain.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcmain.c,v 2.18 2018/01/18 19:43:43 greg Exp $"; +static const char RCSid[] = "$Id: rcmain.c,v 2.19 2020/09/09 21:28:19 greg Exp $"; #endif /* * rcmain.c - main for rtcontrib ray contribution tracer @@ -43,6 +43,8 @@ int using_stdout = 0; /* are we using stdout? */ int imm_irrad = 0; /* compute immediate irradiance? */ int lim_dist = 0; /* limit distance? */ +int report_intvl = 0; /* reporting interval (seconds) */ + const char *modname[MAXMODLIST]; /* ordered modifier name list */ int nmods = 0; /* number of modifiers */ @@ -295,6 +297,10 @@ main(int argc, char *argv[]) check(2,"s"); addmodfile(argv[++i], curout, prms, binval, bincnt); break; + case 't': /* reporting interval */ + check(2,"i"); + report_intvl = atoi(argv[++i]); + break; default: goto badopt; } diff --git a/src/rt/rcontrib.c b/src/rt/rcontrib.c index 9c029a4ca..480912cbc 100644 --- a/src/rt/rcontrib.c +++ b/src/rt/rcontrib.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcontrib.c,v 2.36 2020/07/20 15:54:29 greg Exp $"; +static const char RCSid[] = "$Id: rcontrib.c,v 2.37 2020/09/09 21:28:19 greg Exp $"; #endif /* * Accumulate ray contributions for a set of materials @@ -172,8 +172,35 @@ addmodfile(char *fname, char *outf, char *prms, char *binv, int bincnt) } +/* Check if we have any more rays left (and report progress) */ +int +morays(void) +{ + static RNUMBER total_rays; + static time_t tstart, last_report; + time_t tnow; + + if (!raysleft) + return(1); /* unknown total, so nothing to do or say */ + + if (report_intvl > 0 && (tnow = time(0)) >= last_report+report_intvl) { + if (!total_rays) { + total_rays = raysleft; + tstart = tnow; + } + sprintf(errmsg, "%.2f%% done after %.3f hours", + 100.-100.*raysleft/total_rays, + (1./3600.)*(tnow - tstart)); + eputs(errmsg); + last_report = tnow; + } + return(--raysleft); +} + + +/* Quit program */ void -quit( /* quit program */ +quit( int code ) { @@ -364,7 +391,7 @@ rcontrib(void) } done_contrib(); /* accumulate/output */ ++lastdone; - if (raysleft && !--raysleft) + if (!morays()) break; /* preemptive EOI */ } if (nchild != -1 && (accumulate <= 0) | (account < accumulate)) { diff --git a/src/rt/rcontrib.h b/src/rt/rcontrib.h index 195480975..7a6109778 100644 --- a/src/rt/rcontrib.h +++ b/src/rt/rcontrib.h @@ -1,4 +1,4 @@ -/* RCSid $Id: rcontrib.h,v 2.15 2016/09/12 20:31:34 greg Exp $ */ +/* RCSid $Id: rcontrib.h,v 2.16 2020/09/09 21:28:19 greg Exp $ */ /* * Header file for rcontrib modules @@ -42,6 +42,8 @@ extern long waitflush; /* how long until next flush */ extern RNUMBER lastray; /* last ray number sent */ extern RNUMBER lastdone; /* last ray processed */ +extern int report_intvl; /* reporting interval (seconds) */ + typedef double DCOLOR[3]; /* double-precision color */ /* @@ -121,6 +123,8 @@ extern void end_children(int immed); extern void put_zero_record(int ndx); +extern int morays(void); /* reached end of input? */ + extern void parental_loop(void); /* controlling process */ extern void feeder_loop(void); /* feeder process */ diff --git a/src/util/rfluxmtx.c b/src/util/rfluxmtx.c index 3e8142e75..3d4d32527 100644 --- a/src/util/rfluxmtx.c +++ b/src/util/rfluxmtx.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rfluxmtx.c,v 2.52 2020/09/07 04:06:17 greg Exp $"; +static const char RCSid[] = "$Id: rfluxmtx.c,v 2.53 2020/09/09 21:28:19 greg Exp $"; #endif /* * Calculate flux transfer matrix or matrices using rcontrib @@ -1308,6 +1308,7 @@ main(int argc, char *argv[]) case 'n': /* options with 1 argument */ case 's': case 'o': + case 't': na = 2; break; case 'b': /* special case */