--- ray/src/util/rtcontrib.c 2008/05/01 16:42:06 1.50 +++ ray/src/util/rtcontrib.c 2009/12/09 21:43:35 1.55 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtcontrib.c,v 1.50 2008/05/01 16:42:06 greg Exp $"; +static const char RCSid[] = "$Id: rtcontrib.c,v 1.55 2009/12/09 21:43:35 greg Exp $"; #endif /* * Gather rtrace output to compute contributions from particular sources @@ -99,7 +99,7 @@ struct rtproc { /* rtrace command and defaults */ char *rtargv[256+2*MAXMODLIST] = { "rtrace", - "-dj", ".5", "-dr", "3", + "-dj", ".9", "-dr", "3", "-ab", "1", "-ad", "350", }; int rtargc = 9; @@ -246,7 +246,7 @@ main(int argc, char *argv[]) while ((j = expandarg(&argc, &argv, i)) > 0) ; if (j < 0) { - fprintf(stderr, "%s: cannot expand '%s'", + fprintf(stderr, "%s: cannot expand '%s'\n", argv[0], argv[i]); exit(1); } @@ -340,7 +340,7 @@ main(int argc, char *argv[]) case 'b': /* bin expression/count */ if (i >= argc-2) break; if (argv[i][2] == 'n') { - bincnt = atoi(argv[++i]); + bincnt = (int)(eval(argv[++i]) + .5); continue; } if (argv[i][2]) break; @@ -580,7 +580,7 @@ addmodifier(char *modn, char *outf, char *binv, int bi error(USER, errmsg); } if (nmods >= MAXMODLIST) - error(USER, "too many modifiers"); + error(INTERNAL, "too many modifiers"); modname[nmods++] = modn; /* XXX assumes static string */ lep->key = modn; /* XXX assumes static string */ mp = (MODCONT *)malloc(sizeof(MODCONT)); @@ -588,15 +588,20 @@ addmodifier(char *modn, char *outf, char *binv, int bi error(SYSTEM, "out of memory in addmodifier"); mp->outspec = outf; /* XXX assumes static string */ mp->modname = modn; /* XXX assumes static string */ - if (binv != NULL) - mp->binv = eparse(binv); - else - mp->binv = eparse("0"); - mp->nbins = 1; + if (binv == NULL) + binv = "0"; /* use single bin if unspecified */ + mp->binv = eparse(binv); + if (mp->binv->type == NUM) { /* check value if constant */ + bincnt = (int)(evalue(mp->binv) + 1.5); + if (bincnt != 1) { + sprintf(errmsg, "illegal non-zero constant for bin (%s)", + binv); + error(USER, errmsg); + } + } + mp->nbins = 1; /* initialize results holder */ setcolor(mp->cbin[0], 0., 0., 0.); - if (mp->binv->type == NUM) /* assume one bin if constant */ - bincnt = 1; - else if (bincnt > 1) + if (bincnt > 1) mp = growmodifier(mp, bincnt); lep->data = (char *)mp; /* allocate output streams */ @@ -659,6 +664,10 @@ ofname(char *oname, const char *ospec, const char *mna mnp = cp; break; case 'd': + case 'i': + case 'o': + case 'x': + case 'X': if (bnp != NULL) return -1; bnp = cp; @@ -1148,7 +1157,7 @@ trace_contribs(FILE *fin) "dummy ray(s) ignored during accumulation\n"); continue; } - if (!iblen || /* need reset? */ + if (!iblen || /* need flush/reset? */ queue_length() > 10*nrtprocs() || lastray+1 < lastray) { while (wait_rproc() != NULL) @@ -1161,9 +1170,9 @@ trace_contribs(FILE *fin) if (iblen) { /* trace ray if valid */ writebuf(rtp->pd.w, inpbuf, iblen); } else { /* else bypass dummy ray */ - queue_raytree(rtp); /* empty tree */ - if ((yres <= 0) | (waitflush > 1)) - waitflush = 1; /* flush after this */ + queue_raytree(rtp); /* queue empty ray/record */ + if ((yres <= 0) | (xres <= 0)) + waitflush = 1; /* flush right after */ } process_queue(); /* catch up with results */ if (raysleft && !--raysleft)