Skip to content

Commit

Permalink
feat(rcontrib,rfluxmtx): Added -t option to specify progress report i…
Browse files Browse the repository at this point in the history
…nterval
  • Loading branch information
Gregungory committed Sep 9, 2020
1 parent 5b400b7 commit 3bcddd1
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 10 deletions.
9 changes: 8 additions & 1 deletion doc/man/man1/rcontrib.1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,6 +9,8 @@ rcontrib - compute contribution coefficients in a RADIANCE scene
][
.B \-V
][
.B "\-t secs"
][
.B "\-c count"
][
.B \-fo
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions doc/notes/ReleaseNotes
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 3 additions & 3 deletions src/rt/rc3.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -529,7 +529,7 @@ feeder_loop()
lastdone = lastray = 0;
ninq = 0;
}
if (raysleft && !--raysleft)
if (!morays())
break; /* preemptive EOI */
}
if (ninq) { /* polish off input */
Expand Down
8 changes: 7 additions & 1 deletion src/rt/rcmain.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
}
Expand Down
33 changes: 30 additions & 3 deletions src/rt/rcontrib.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
)
{
Expand Down Expand Up @@ -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)) {
Expand Down
6 changes: 5 additions & 1 deletion src/rt/rcontrib.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */

/*
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion src/util/rfluxmtx.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 3bcddd1

Please sign in to comment.