ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rtcontrib.c
(Generate patch)

Comparing ray/src/util/rtcontrib.c (file contents):
Revision 1.26 by schorsch, Mon Sep 19 11:30:11 2005 UTC vs.
Revision 1.30 by greg, Wed Oct 5 19:44:17 2005 UTC

# Line 57 | Line 57 | LUTAB  ofiletab = LU_SINIT(free,closefile);    /* output f
57   FILE *getofile(const char *ospec, const char *mname, int bn);
58   int ofname(char *oname, const char *ospec, const char *mname, int bn);
59   void printheader(FILE *fout, const char *info);
60 + void printresolu(FILE *fout);
61  
62   /*
63   * The rcont structure is used to manage i/o with a particular
# Line 112 | Line 113 | int            using_stdout = 0;       /* are we using stdout? */
113   const char      *modname[MAXMODLIST];   /* ordered modifier name list */
114   int             nmods = 0;              /* number of modifiers */
115  
116 + #define queue_length()          (lastray - lastdone)
117 +
118   MODCONT *addmodifier(char *modn, char *outf, char *binv);
119   void addmodfile(char *fname, char *outf, char *binv);
120  
# Line 128 | Line 131 | void put_contrib(const DCOLOR cnt, FILE *fout);
131   void add_contrib(const char *modn);
132   void done_contrib(void);
133  
134 + /* return number of open rtrace processes */
135 + static int
136 + nrtprocs(void)
137 + {
138 +        int     nrtp = 0;
139 +        struct rtproc   *rtp;
140 +
141 +        for (rtp = &rt0; rtp != NULL; rtp = rtp->next)
142 +                nrtp += rtp->pd.running;
143 +        return(nrtp);
144 + }
145 +
146   /* set input/output format */
147   static void
148   setformat(const char *fmt)
# Line 584 | Line 599 | printheader(FILE *fout, const char *info)
599                  break;
600          }
601          fputc('\n', fout);
602 + }
603 +
604 + /* write resolution string to given output stream */
605 + void
606 + printresolu(FILE *fout)
607 + {
608          if (xres > 0) {
609                  if (yres > 0)                   /* resolution string */
610                          fprtresolu(xres, yres, fout);
# Line 605 | Line 626 | getofile(const char *ospec, const char *mname, int bn)
626                                  SET_FILE_BINARY(stdout);
627                          if (header)
628                                  printheader(stdout, NULL);
629 +                        printresolu(stdout);
630                  }
631                  using_stdout = 1;
632                  return stdout;
# Line 633 | Line 655 | getofile(const char *ospec, const char *mname, int bn)
655                  if (header) {
656                          char    info[512];
657                          char    *cp = info;
658 <                        sprintf(cp, "MODIFIER=%s\n", mname);
659 <                        while (*cp) ++cp;
658 >                        if (ofl & OF_MODIFIER) {
659 >                                sprintf(cp, "MODIFIER=%s\n", mname);
660 >                                while (*cp) ++cp;
661 >                        }
662                          if (ofl & OF_BIN) {
663                                  sprintf(cp, "BIN=%d\n", bn);
664                                  while (*cp) ++cp;
# Line 642 | Line 666 | getofile(const char *ospec, const char *mname, int bn)
666                          *cp = '\0';
667                          printheader(fp, info);
668                  }
669 +                printresolu(fp);
670                                                  /* play catch-up */
671                  for (i = 0; i < lastdone; i++) {
672                          static const DCOLOR     nocontrib = BLKCOLOR;
# Line 716 | Line 741 | add_contrib(const char *modn)
741          bn = (int)(evalue(mp->binv) + .5);
742          if (bn <= 0)
743                  bn = 0;
744 <        else if (bn > mp->nbins) {      /* new bin */
744 >        else if (bn >= mp->nbins) {     /* new bin */
745                  mp = (MODCONT *)realloc(mp, sizeof(MODCONT) +
746                                                  bn*sizeof(DCOLOR));
747                  if (mp == NULL)
# Line 915 | Line 940 | wait_rproc(void)
940                                  if (rt->bsiz + BUFSIZ <= treebufsiz)
941                                          rt->bsiz = treebufsiz;
942                                  else
943 <                                        rt->bsiz = treebufsiz += BUFSIZ;
943 >                                        treebufsiz = rt->bsiz += BUFSIZ;
944                                  rt->buf = (char *)realloc(rt->buf, rt->bsiz);
945                          }
946                          if (rt->buf == NULL)
# Line 956 | Line 981 | trace_contribs(FILE *fin)
981          struct rtproc   *rtp;
982                                                  /* loop over input */
983          while ((iblen = getinp(inpbuf, fin)) > 0) {
984 <                if (lastray+1 < lastray) {      /* counter rollover? */
984 >                if (lastray+1 < lastray ||      /* need reset? */
985 >                                queue_length() > 5*nrtprocs()) {
986                          while (wait_rproc() != NULL)
987                                  process_queue();
988                          lastdone = lastray = 0;
# Line 1109 | Line 1135 | recover_output(FILE *fin)
1135                                                  /* seek on all files */
1136          nvals = lastout * outvsiz;
1137          lu_doall(&ofiletab, myseeko, &nvals);
1138 <                                                /* discard input */
1138 >                                                /* skip repeated input */
1139          for (nvals = 0; nvals < lastout; nvals++)
1140                  if (getinp(oname, fin) <= 0)
1141                          error(USER, "unexpected EOF on input");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines