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.30 by greg, Wed Oct 5 19:44:17 2005 UTC vs.
Revision 1.56 by greg, Fri Jun 11 20:26:09 2010 UTC

# Line 25 | Line 25 | int    treebufsiz = BUFSIZ;            /* current tree buffer size
25   typedef double  DCOLOR[3];              /* double-precision color */
26  
27   /*
28 < * The modcont structure is used to accumulate ray contributions
28 > * The MODCONT structure is used to accumulate ray contributions
29   * for a particular modifier, which may be subdivided into bins
30 < * if binv is non-NULL.  If outspec contains a %s in it, this will
30 > * if binv evaluates > 0.  If outspec contains a %s in it, this will
31   * be replaced with the modifier name.  If outspec contains a %d in it,
32   * this will be used to create one output file per bin, otherwise all bins
33   * will be written to the same file, in order.  If the global outfmt
# Line 46 | Line 46 | static void mcfree(void *p) { epfree((*(MODCONT *)p).b
46  
47   LUTAB   modconttab = LU_SINIT(NULL,mcfree);     /* modifier lookup table */
48  
49 < /* close output stream */
50 < static void closefile(void *p) { fclose((FILE *)p); }
49 > /*
50 > * The STREAMOUT structure holds an open FILE pointer and a count of
51 > * the number of RGB triplets per record, or 0 if unknown.
52 > */
53 > typedef struct {
54 >        FILE            *ofp;           /* output file pointer */
55 >        int             outpipe;        /* output is to a pipe */
56 >        int             reclen;         /* triplets/record */
57 >        int             xr, yr;         /* output resolution for picture */
58 > } STREAMOUT;
59  
60 < LUTAB   ofiletab = LU_SINIT(free,closefile);    /* output file table */
60 > /* close output stream and free record */
61 > static void
62 > closestream(void *p)
63 > {
64 >        STREAMOUT       *sop = (STREAMOUT *)p;
65 >        int             status;
66 >        if (sop->outpipe)
67 >                status = pclose(sop->ofp);
68 >        else
69 >                status = fclose(sop->ofp);
70 >        if (status)
71 >                error(SYSTEM, "error closing output stream");
72 >        free(p);
73 > }
74  
75 + LUTAB   ofiletab = LU_SINIT(free,closestream);  /* output file table */
76 +
77   #define OF_MODIFIER     01
78   #define OF_BIN          02
79  
80 < FILE *getofile(const char *ospec, const char *mname, int bn);
80 > STREAMOUT *getostream(const char *ospec, const char *mname, int bn, int noopen);
81   int ofname(char *oname, const char *ospec, const char *mname, int bn);
82   void printheader(FILE *fout, const char *info);
83 < void printresolu(FILE *fout);
83 > void printresolu(FILE *fout, int xr, int yr);
84  
85   /*
86   * The rcont structure is used to manage i/o with a particular
# Line 76 | Line 99 | struct rtproc {
99  
100                                          /* rtrace command and defaults */
101   char            *rtargv[256+2*MAXMODLIST] = { "rtrace",
102 <                                "-dj", ".5", "-dr", "3",
103 <                                "-ab", "1", "-ad", "128", };
102 >                                "-dj", ".9", "-dr", "3",
103 >                                "-ab", "1", "-ad", "350", };
104 >
105   int  rtargc = 9;
106                                          /* overriding rtrace options */
107 < char            *myrtopts[] = { "-o~~TmWdp", "-h-", "-x", "1", "-y", "0",
107 > char            *myrtopts[] = { "-h-", "-x", "1", "-y", "0",
108                                  "-dt", "0", "-as", "0", "-aa", "0", NULL };
109  
110 + #define RTCOEFF         "-o~~TmWdp"     /* compute coefficients only */
111 + #define RTCONTRIB       "-o~~TmVdp"     /* compute ray contributions */
112 +
113   struct rtproc   rt0;                    /* head of rtrace process list */
114  
115   struct rtproc   *rt_unproc = NULL;      /* unprocessed ray trees */
116  
117 < char    persistfn[] = "pfXXXXXX";       /* persist file name */
117 > #define PERSIST_NONE    0               /* no persist file */
118 > #define PERSIST_SINGLE  1               /* user set -P persist */
119 > #define PERSIST_PARALL  2               /* user set -PP persist */
120 > #define PERSIST_OURS    3               /* -PP persist belongs to us */
121 > int     persist_state = PERSIST_NONE;   /* persist file state */
122 > char    persistfn[] = "pfXXXXXX";       /* our persist file name, if set */
123  
124   int             gargc;                  /* global argc */
125   char            **gargv;                /* global argv */
# Line 99 | Line 131 | int            inpfmt = 'a';           /* input format */
131   int             outfmt = 'a';           /* output format */
132  
133   int             header = 1;             /* output header? */
134 + int             force_open = 0;         /* truncate existing output? */
135 + int             recover = 0;            /* recover previous output? */
136 + int             accumulate = 1;         /* input rays per output record */
137   int             xres = 0;               /* horiz. output resolution */
138   int             yres = 0;               /* vert. output resolution */
139  
140 + int             account;                /* current accumulation count */
141   unsigned long   raysleft;               /* number of rays left to trace */
142   long            waitflush;              /* how long until next flush */
143  
# Line 115 | Line 151 | int            nmods = 0;              /* number of modifiers */
151  
152   #define queue_length()          (lastray - lastdone)
153  
154 < MODCONT *addmodifier(char *modn, char *outf, char *binv);
155 < void addmodfile(char *fname, char *outf, char *binv);
154 > MODCONT *growmodifier(MODCONT *mp, int nb);
155 > MODCONT *addmodifier(char *modn, char *outf, char *binv, int bincnt);
156 > void addmodfile(char *fname, char *outf, char *binv, int bincnt);
157  
158   void init(int np);
159   int done_rprocs(struct rtproc *rtp);
160 + void reload_output(void);
161   void recover_output(FILE *fin);
162   void trace_contribs(FILE *fin);
163   struct rtproc *wait_rproc(void);
# Line 129 | Line 167 | void process_queue(void);
167  
168   void put_contrib(const DCOLOR cnt, FILE *fout);
169   void add_contrib(const char *modn);
170 < void done_contrib(void);
170 > void done_contrib(int navg);
171  
172   /* return number of open rtrace processes */
173   static int
# Line 182 | Line 220 | fmterr:
220   int
221   main(int argc, char *argv[])
222   {
223 +        int     contrib = 0;
224          int     nprocs = 1;
186        int     recover = 0;
225          char    *curout = NULL;
226          char    *binval = NULL;
227 +        int     bincnt = 0;
228          char    fmt[8];
229          int     i, j;
230                                  /* need at least one argument */
231          if (argc < 2) {
232                  fprintf(stderr,
233 < "Usage: %s [-n nprocs][-r][-e expr][-f source][-o ospec][-b binv] {-m mod | -M file} [rtrace options] octree\n",
233 > "Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-b binv] {-m mod | -M file} [rtrace options] octree\n",
234                          argv[0]);
235                  exit(1);
236          }
# Line 207 | Line 246 | main(int argc, char *argv[])
246                  while ((j = expandarg(&argc, &argv, i)) > 0)
247                          ;
248                  if (j < 0) {
249 <                        fprintf(stderr, "%s: cannot expand '%s'",
249 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
250                                          argv[0], argv[i]);
251                          exit(1);
252                  }
253                  if (argv[i][0] == '-')
254                          switch (argv[i][1]) {
216                        case 'r':               /* recover output */
217                                if (argv[i][2]) break;
218                                recover++;
219                                continue;
255                          case 'n':               /* number of processes */
256                                  if (argv[i][2] || i >= argc-2) break;
257                                  nprocs = atoi(argv[++i]);
258                                  if (nprocs <= 0)
259                                          error(USER, "illegal number of processes");
260                                  continue;
261 +                        case 'V':               /* output contributions */
262 +                                switch (argv[i][2]) {
263 +                                case '\0':
264 +                                        contrib = !contrib;
265 +                                        continue;
266 +                                case '+': case '1':
267 +                                case 'T': case 't':
268 +                                case 'Y': case 'y':
269 +                                        contrib = 1;
270 +                                        continue;
271 +                                case '-': case '0':
272 +                                case 'F': case 'f':
273 +                                case 'N': case 'n':
274 +                                        contrib = 0;
275 +                                        continue;
276 +                                }
277 +                                break;
278 +                        case 'c':               /* input rays per output */
279 +                                if (argv[i][2] || i >= argc-2) break;
280 +                                accumulate = atoi(argv[++i]);
281 +                                continue;
282 +                        case 'r':               /* recover output */
283 +                                if (argv[i][2]) break;
284 +                                recover = 1;
285 +                                continue;
286                          case 'h':               /* output header? */
287                                  switch (argv[i][2]) {
288                                  case '\0':
# Line 240 | Line 300 | main(int argc, char *argv[])
300                                          continue;
301                                  }
302                                  break;
303 <                        case 'f':               /* file or i/o format */
303 >                        case 'f':               /* file or force or format */
304                                  if (!argv[i][2]) {
305                                          char    *fpath;
306                                          if (i >= argc-2) break;
# Line 255 | Line 315 | main(int argc, char *argv[])
315                                          fcompile(fpath);
316                                          continue;
317                                  }
318 +                                if (argv[i][2] == 'o') {
319 +                                        force_open = 1;
320 +                                        continue;
321 +                                }
322                                  setformat(argv[i]+2);
323                                  continue;
324                          case 'e':               /* expression */
# Line 273 | Line 337 | main(int argc, char *argv[])
337                                  if (argv[i][2] || i >= argc-2) break;
338                                  yres = atoi(argv[++i]);
339                                  continue;
340 <                        case 'b':               /* bin expression */
341 <                                if (argv[i][2] || i >= argc-2) break;
340 >                        case 'b':               /* bin expression/count */
341 >                                if (i >= argc-2) break;
342 >                                if (argv[i][2] == 'n') {
343 >                                        bincnt = (int)(eval(argv[++i]) + .5);
344 >                                        continue;
345 >                                }
346 >                                if (argv[i][2]) break;
347                                  binval = argv[++i];
348                                  continue;
349                          case 'm':               /* modifier name */
350                                  if (argv[i][2] || i >= argc-2) break;
351                                  rtargv[rtargc++] = "-ti";
352                                  rtargv[rtargc++] = argv[++i];
353 <                                addmodifier(argv[i], curout, binval);
353 >                                addmodifier(argv[i], curout, binval, bincnt);
354                                  continue;
355                          case 'M':               /* modifier file */
356                                  if (argv[i][2] || i >= argc-2) break;
357                                  rtargv[rtargc++] = "-tI";
358                                  rtargv[rtargc++] = argv[++i];
359 <                                addmodfile(argv[i], curout, binval);
359 >                                addmodfile(argv[i], curout, binval, bincnt);
360                                  continue;
361 +                        case 'P':               /* persist file */
362 +                                if (i >= argc-2) break;
363 +                                persist_state = (argv[i][2] == 'P') ?
364 +                                                PERSIST_PARALL : PERSIST_SINGLE;
365 +                                rtargv[rtargc++] = argv[i];
366 +                                rtargv[rtargc++] = argv[++i];
367 +                                continue;
368                          }
369                  rtargv[rtargc++] = argv[i];     /* assume rtrace option */
370          }
371 +        if (accumulate <= 0)    /* no output flushing for single record */
372 +                xres = yres = 0;
373                                  /* set global argument list */
374          gargc = argc; gargv = argv;
375                                  /* add "mandatory" rtrace settings */
376          for (j = 0; myrtopts[j] != NULL; j++)
377                  rtargv[rtargc++] = myrtopts[j];
378 +        rtargv[rtargc++] = contrib ? RTCONTRIB : RTCOEFF;
379                                  /* just asking for defaults? */
380          if (!strcmp(argv[i], "-defaults")) {
381 <                char    sxres[16], syres[16];
381 >                char    nps[8], sxres[16], syres[16];
382                  char    *rtpath;
383 <                printf("-n  %-2d\t\t\t\t# number of processes\n", nprocs);
383 >                printf("-c %-5d\t\t\t# accumulated rays per record\n",
384 >                                accumulate);
385 >                printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-',
386 >                                contrib ? "contributions" : "coefficients");
387                  fflush(stdout);                 /* report OUR options */
388 +                rtargv[rtargc++] = "-n";
389 +                sprintf(nps, "%d", nprocs);
390 +                rtargv[rtargc++] = nps;
391                  rtargv[rtargc++] = header ? "-h+" : "-h-";
392                  sprintf(fmt, "-f%c%c", inpfmt, outfmt);
393                  rtargv[rtargc++] = fmt;
# Line 312 | Line 397 | main(int argc, char *argv[])
397                  rtargv[rtargc++] = "-y";
398                  sprintf(syres, "%d", yres);
399                  rtargv[rtargc++] = syres;
315                rtargv[rtargc++] = "-oTW";
400                  rtargv[rtargc++] = "-defaults";
401                  rtargv[rtargc] = NULL;
402                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
# Line 326 | Line 410 | main(int argc, char *argv[])
410                  exit(1);
411          }
412          if (nprocs > 1) {       /* add persist file if parallel */
413 <                rtargv[rtargc++] = "-PP";
414 <                rtargv[rtargc++] = mktemp(persistfn);
413 >                if (persist_state == PERSIST_SINGLE)
414 >                        error(USER, "use -PP option for multiple processes");
415 >                if (persist_state == PERSIST_NONE) {
416 >                        rtargv[rtargc++] = "-PP";
417 >                        rtargv[rtargc++] = mktemp(persistfn);
418 >                        persist_state = PERSIST_OURS;
419 >                }
420          }
421                                  /* add format string */
422          sprintf(fmt, "-f%cf", inpfmt);
# Line 337 | Line 426 | main(int argc, char *argv[])
426                  error(USER, "missing octree argument");
427          rtargv[rtargc++] = octree = argv[i];
428          rtargv[rtargc] = NULL;
429 <                                /* start rtrace */
429 >                                /* start rtrace & recover if requested */
430          init(nprocs);
431 <        if (recover)            /* perform recovery if requested */
432 <                recover_output(stdin);
433 <        trace_contribs(stdin);  /* compute contributions */
431 >                                /* compute contributions */
432 >        trace_contribs(stdin);
433 >                                /* clean up */
434          quit(0);
435   }
436  
# Line 387 | Line 476 | quit(int status)
476   {
477          int     rtstat;
478  
479 <        if (rt0.next != NULL)           /* terminate persistent rtrace */
479 >        if (persist_state == PERSIST_OURS)  /* terminate waiting rtrace */
480                  killpersist();
481                                          /* clean up rtrace process(es) */
482          rtstat = done_rprocs(&rt0);
# Line 454 | Line 543 | init(int np)
543                          raysleft = yres;
544          } else
545                  raysleft = 0;
546 +        if ((account = accumulate) > 0)
547 +                raysleft *= accumulate;
548          waitflush = xres;
549 +        if (!recover)
550 +                return;
551 +                                        /* recover previous values */
552 +        if (accumulate <= 0)
553 +                reload_output();
554 +        else
555 +                recover_output(stdin);
556   }
557  
558 + /* grow modifier to accommodate more bins */
559 + MODCONT *
560 + growmodifier(MODCONT *mp, int nb)
561 + {
562 +        if (nb <= mp->nbins)
563 +                return mp;
564 +        mp = (MODCONT *)realloc(mp, sizeof(MODCONT) + sizeof(DCOLOR)*(nb-1));
565 +        if (mp == NULL)
566 +                error(SYSTEM, "out of memory in growmodifier");
567 +        memset(mp->cbin+mp->nbins, 0, sizeof(DCOLOR)*(nb-mp->nbins));
568 +        mp->nbins = nb;
569 +        return mp;
570 + }
571 +
572   /* add modifier to our list to track */
573   MODCONT *
574 < addmodifier(char *modn, char *outf, char *binv)
574 > addmodifier(char *modn, char *outf, char *binv, int bincnt)
575   {
576          LUENT   *lep = lu_find(&modconttab, modn);
577          MODCONT *mp;
578 +        int     i;
579          
580          if (lep->data != NULL) {
581                  sprintf(errmsg, "duplicate modifier '%s'", modn);
582                  error(USER, errmsg);
583          }
584          if (nmods >= MAXMODLIST)
585 <                error(USER, "too many modifiers");
585 >                error(INTERNAL, "too many modifiers");
586          modname[nmods++] = modn;        /* XXX assumes static string */
587          lep->key = modn;                /* XXX assumes static string */
588          mp = (MODCONT *)malloc(sizeof(MODCONT));
589          if (mp == NULL)
590                  error(SYSTEM, "out of memory in addmodifier");
478        lep->data = (char *)mp;
591          mp->outspec = outf;             /* XXX assumes static string */
592          mp->modname = modn;             /* XXX assumes static string */
593 <        if (binv != NULL)
594 <                mp->binv = eparse(binv);
595 <        else
596 <                mp->binv = eparse("0");
597 <        mp->nbins = 1;
593 >        if (binv == NULL)
594 >                binv = "0";             /* use single bin if unspecified */
595 >        mp->binv = eparse(binv);
596 >        if (mp->binv->type == NUM) {    /* check value if constant */
597 >                bincnt = (int)(evalue(mp->binv) + 1.5);
598 >                if (bincnt != 1) {
599 >                        sprintf(errmsg, "illegal non-zero constant for bin (%s)",
600 >                                        binv);
601 >                        error(USER, errmsg);
602 >                }
603 >        }
604 >        mp->nbins = 1;                  /* initialize results holder */
605          setcolor(mp->cbin[0], 0., 0., 0.);
606 +        if (bincnt > 1)
607 +                mp = growmodifier(mp, bincnt);
608 +        lep->data = (char *)mp;
609 +                                        /* allocate output streams */
610 +        for (i = bincnt; i-- > 0; )
611 +                getostream(mp->outspec, mp->modname, i, 1);
612          return mp;
613   }
614  
615   /* add modifiers from a file list */
616   void
617 < addmodfile(char *fname, char *outf, char *binv)
617 > addmodfile(char *fname, char *outf, char *binv, int bincnt)
618   {
619          char    *mname[MAXMODLIST];
620          int     i;
# Line 499 | Line 624 | addmodfile(char *fname, char *outf, char *binv)
624                  error(SYSTEM, errmsg);
625          }
626          for (i = 0; mname[i]; i++)      /* add each one */
627 <                addmodifier(mname[i], outf, binv);
627 >                addmodifier(mname[i], outf, binv, bincnt);
628   }
629  
630   /* put string to stderr */
# Line 541 | Line 666 | ofname(char *oname, const char *ospec, const char *mna
666                                  mnp = cp;
667                                  break;
668                          case 'd':
669 +                        case 'i':
670 +                        case 'o':
671 +                        case 'x':
672 +                        case 'X':
673                                  if (bnp != NULL)
674                                          return -1;
675                                  bnp = cp;
# Line 603 | Line 732 | printheader(FILE *fout, const char *info)
732  
733   /* write resolution string to given output stream */
734   void
735 < printresolu(FILE *fout)
735 > printresolu(FILE *fout, int xr, int yr)
736   {
737 <        if (xres > 0) {
738 <                if (yres > 0)                   /* resolution string */
739 <                        fprtresolu(xres, yres, fout);
737 >        if ((xr > 0) & (yr > 0))        /* resolution string */
738 >                fprtresolu(xr, yr, fout);
739 >        if (xres > 0)                   /* global flush flag */
740                  fflush(fout);
612        }
741   }
742  
743 < /* Get output file pointer (open and write header if new) */
744 < FILE *
745 < getofile(const char *ospec, const char *mname, int bn)
743 > /* Get output stream pointer (open and write header if new and noopen==0) */
744 > STREAMOUT *
745 > getostream(const char *ospec, const char *mname, int bn, int noopen)
746   {
747 <        int             ofl;
748 <        char            oname[1024];
749 <        LUENT           *lep;
747 >        static const DCOLOR     nocontrib = BLKCOLOR;
748 >        static STREAMOUT        stdos;
749 >        int                     ofl;
750 >        char                    oname[1024];
751 >        LUENT                   *lep;
752 >        STREAMOUT               *sop;
753          
754          if (ospec == NULL) {                    /* use stdout? */
755 <                if (!using_stdout) {
755 >                if (!noopen && !using_stdout) {
756                          if (outfmt != 'a')
757                                  SET_FILE_BINARY(stdout);
758                          if (header)
759                                  printheader(stdout, NULL);
760 <                        printresolu(stdout);
760 >                        printresolu(stdout, xres, yres);
761 >                        stdos.xr = xres; stdos.yr = yres;
762 >                        using_stdout = 1;
763                  }
764 <                using_stdout = 1;
765 <                return stdout;
764 >                stdos.ofp = stdout;
765 >                stdos.reclen += noopen;
766 >                return &stdos;
767          }
768          ofl = ofname(oname, ospec, mname, bn);  /* get output name */
769          if (ofl < 0) {
# Line 639 | Line 773 | getofile(const char *ospec, const char *mname, int bn)
773          lep = lu_find(&ofiletab, oname);        /* look it up */
774          if (lep->key == NULL)                   /* new entry */
775                  lep->key = strcpy((char *)malloc(strlen(oname)+1), oname);
776 <        if (lep->data == NULL) {                /* open output file */
777 <                FILE            *fp;
778 <                int             i;
779 <                if (oname[0] == '!')            /* output to command */
780 <                        fp = popen(oname+1, "w");
781 <                else
782 <                        fp = fopen(oname, "w");
783 <                if (fp == NULL) {
784 <                        sprintf(errmsg, "cannot open '%s' for writing", oname);
785 <                        error(SYSTEM, errmsg);
776 >        sop = (STREAMOUT *)lep->data;
777 >        if (sop == NULL) {                      /* allocate stream */
778 >                sop = (STREAMOUT *)malloc(sizeof(STREAMOUT));
779 >                if (sop == NULL)
780 >                        error(SYSTEM, "out of memory in getostream");
781 >                sop->outpipe = oname[0] == '!';
782 >                sop->reclen = 0;
783 >                sop->ofp = NULL;                /* open iff noopen==0 */
784 >                sop->xr = xres; sop->yr = yres;
785 >                lep->data = (char *)sop;
786 >                if (!sop->outpipe & !force_open & !recover &&
787 >                                access(oname, F_OK) == 0) {
788 >                        errno = EEXIST;         /* file exists */
789 >                        goto openerr;
790                  }
791 +        }
792 +        if (!noopen && sop->ofp == NULL) {      /* open output stream */
793 +                long            i;
794 +                if (oname[0] == '!')            /* output to command */
795 +                        sop->ofp = popen(oname+1, "w");
796 +                else                            /* else open file */
797 +                        sop->ofp = fopen(oname, "w");
798 +                if (sop->ofp == NULL)
799 +                        goto openerr;
800                  if (outfmt != 'a')
801 <                        SET_FILE_BINARY(fp);
801 >                        SET_FILE_BINARY(sop->ofp);
802                  if (header) {
803                          char    info[512];
804                          char    *cp = info;
805 <                        if (ofl & OF_MODIFIER) {
805 >                        if (ofl & OF_MODIFIER || sop->reclen == 1) {
806                                  sprintf(cp, "MODIFIER=%s\n", mname);
807                                  while (*cp) ++cp;
808                          }
# Line 664 | Line 811 | getofile(const char *ospec, const char *mname, int bn)
811                                  while (*cp) ++cp;
812                          }
813                          *cp = '\0';
814 <                        printheader(fp, info);
814 >                        printheader(sop->ofp, info);
815                  }
816 <                printresolu(fp);
816 >                if (accumulate > 0) {           /* global resolution */
817 >                        sop->xr = xres; sop->yr = yres;
818 >                }
819 >                printresolu(sop->ofp, sop->xr, sop->yr);
820                                                  /* play catch-up */
821 <                for (i = 0; i < lastdone; i++) {
822 <                        static const DCOLOR     nocontrib = BLKCOLOR;
823 <                        put_contrib(nocontrib, fp);
821 >                for (i = accumulate > 0 ? lastdone/accumulate : 0; i--; ) {
822 >                        int     j = sop->reclen;
823 >                        if (j <= 0) j = 1;
824 >                        while (j--)
825 >                                put_contrib(nocontrib, sop->ofp);
826                          if (outfmt == 'a')
827 <                                putc('\n', fp);
827 >                                putc('\n', sop->ofp);
828                  }
829                  if (xres > 0)
830 <                        fflush(fp);
679 <                lep->data = (char *)fp;
830 >                        fflush(sop->ofp);
831          }
832 <        return (FILE *)lep->data;               /* return open file pointer */
832 >        sop->reclen += noopen;                  /* add to length if noopen */
833 >        return sop;                             /* return output stream */
834 > openerr:
835 >        sprintf(errmsg, "cannot open '%s' for writing", oname);
836 >        error(SYSTEM, errmsg);
837 >        return NULL;    /* pro forma return */
838   }
839  
840   /* read input ray into buffer */
841   int
842   getinp(char *buf, FILE *fp)
843   {
844 +        double  dv[3], *dvp;
845 +        float   *fvp;
846          char    *cp;
847          int     i;
848  
# Line 693 | Line 851 | getinp(char *buf, FILE *fp)
851                  cp = buf;               /* make sure we get 6 floats */
852                  for (i = 0; i < 6; i++) {
853                          if (fgetword(cp, buf+127-cp, fp) == NULL)
854 <                                return 0;
854 >                                return -1;
855 >                        if (i >= 3)
856 >                                dv[i-3] = atof(cp);
857                          if ((cp = fskip(cp)) == NULL || *cp)
858 <                                return 0;
858 >                                return -1;
859                          *cp++ = ' ';
860                  }
861                  getc(fp);               /* get/put eol */
862                  *cp-- = '\0'; *cp = '\n';
863 +                if (DOT(dv,dv) <= FTINY*FTINY)
864 +                        return 0;       /* dummy ray */
865                  return strlen(buf);
866          case 'f':
867                  if (fread(buf, sizeof(float), 6, fp) < 6)
868 <                        return 0;
868 >                        return -1;
869 >                fvp = (float *)buf + 3;
870 >                if (DOT(fvp,fvp) <= FTINY*FTINY)
871 >                        return 0;       /* dummy ray */
872                  return sizeof(float)*6;
873          case 'd':
874                  if (fread(buf, sizeof(double), 6, fp) < 6)
875 <                        return 0;
875 >                        return -1;
876 >                dvp = (double *)buf + 3;
877 >                if (DOT(dvp,dvp) <= FTINY*FTINY)
878 >                        return 0;       /* dummy ray */
879                  return sizeof(double)*6;
880          }
881          error(INTERNAL, "botched input format");
882 <        return 0;       /* pro forma return */
882 >        return -1;      /* pro forma return */
883   }
884  
885   static float    rparams[9];             /* traced ray parameters */
# Line 741 | Line 909 | add_contrib(const char *modn)
909          bn = (int)(evalue(mp->binv) + .5);
910          if (bn <= 0)
911                  bn = 0;
912 <        else if (bn >= mp->nbins) {     /* new bin */
913 <                mp = (MODCONT *)realloc(mp, sizeof(MODCONT) +
746 <                                                bn*sizeof(DCOLOR));
747 <                if (mp == NULL)
748 <                        error(SYSTEM, "out of memory in add_contrib");
749 <                memset(mp->cbin+mp->nbins, 0, sizeof(DCOLOR)*(bn+1-mp->nbins));
750 <                mp->nbins = bn+1;
751 <                le->data = (char *)mp;
752 <        }
912 >        else if (bn >= mp->nbins)       /* new bin */
913 >                le->data = (char *)(mp = growmodifier(mp, bn+1));
914          addcolor(mp->cbin[bn], rparams);
915   }
916  
# Line 757 | Line 918 | add_contrib(const char *modn)
918   static int
919   puteol(const LUENT *e, void *p)
920   {
921 <        FILE    *fp = (FILE *)e->data;
921 >        STREAMOUT       *sop = (STREAMOUT *)e->data;
922  
923          if (outfmt == 'a')
924 <                putc('\n', fp);
924 >                putc('\n', sop->ofp);
925          if (!waitflush)
926 <                fflush(fp);
927 <        if (ferror(fp)) {
926 >                fflush(sop->ofp);
927 >        if (ferror(sop->ofp)) {
928                  sprintf(errmsg, "write error on file '%s'", e->key);
929                  error(SYSTEM, errmsg);
930          }
# Line 782 | Line 943 | put_contrib(const DCOLOR cnt, FILE *fout)
943                  fprintf(fout, "%.6e\t%.6e\t%.6e\t", cnt[0], cnt[1], cnt[2]);
944                  break;
945          case 'f':
946 <                fv[0] = cnt[0];
786 <                fv[1] = cnt[1];
787 <                fv[2] = cnt[2];
946 >                copycolor(fv, cnt);
947                  fwrite(fv, sizeof(float), 3, fout);
948                  break;
949          case 'd':
# Line 799 | Line 958 | put_contrib(const DCOLOR cnt, FILE *fout)
958          }
959   }
960  
961 < /* output ray tallies and clear for next primary */
961 > /* output ray tallies and clear for next accumulation */
962   void
963 < done_contrib(void)
963 > done_contrib(int navg)
964   {
965 <        int     i, j;
966 <        MODCONT *mp;
967 <        FILE    *fp;
965 >        double          sf = 1.;
966 >        int             i, j;
967 >        MODCONT         *mp;
968 >        STREAMOUT       *sop;
969 >                                                /* set average scaling */
970 >        if (navg > 1)
971 >                sf = 1. / (double)navg;
972                                                  /* output modifiers in order */
973          for (i = 0; i < nmods; i++) {
974                  mp = (MODCONT *)lu_find(&modconttab,modname[i])->data;
975 <                fp = getofile(mp->outspec, mp->modname, 0);
976 <                put_contrib(mp->cbin[0], fp);
975 >                if (navg > 1)                   /* average scaling */
976 >                        for (j = mp->nbins; j--; )
977 >                                scalecolor(mp->cbin[j], sf);
978 >                sop = getostream(mp->outspec, mp->modname, 0,0);
979 >                put_contrib(mp->cbin[0], sop->ofp);
980                  if (mp->nbins > 3 &&            /* minor optimization */
981 <                                fp == getofile(mp->outspec, mp->modname, 1))
981 >                                sop == getostream(mp->outspec, mp->modname, 1,0))
982                          for (j = 1; j < mp->nbins; j++)
983 <                                put_contrib(mp->cbin[j], fp);
983 >                                put_contrib(mp->cbin[j], sop->ofp);
984                  else
985                          for (j = 1; j < mp->nbins; j++)
986                                  put_contrib(mp->cbin[j],
987 <                                        getofile(mp->outspec, mp->modname, j));
988 <                                                /* clear for next ray tree */
987 >                                    getostream(mp->outspec,mp->modname,j,0)->ofp);
988 >                                                /* clear for next time */
989                  memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins);
990          }
991          --waitflush;                            /* terminate records */
# Line 878 | Line 1044 | process_queue(void)
1044                          if (!n || !(isalpha(*cp) | (*cp == '_')))
1045                                  error(USER, "bad modifier name from rtrace");
1046                                          /* get modifier name */
1047 <                        while (n > 0 && *cp != '\t') {
1047 >                        while (n > 1 && *cp != '\t') {
1048 >                                if (mnp - modname >= sizeof(modname)-2)
1049 >                                        error(INTERNAL, "modifier name too long");
1050                                  *mnp++ = *cp++; n--;
1051                          }
1052                          *mnp = '\0';
# Line 890 | Line 1058 | process_queue(void)
1058                          cp += sizeof(float)*9; n -= sizeof(float)*9;
1059                          add_contrib(modname);
1060                  }
1061 <                done_contrib();         /* sum up contributions & output */
1061 >                                        /* time to produce record? */
1062 >                if (account > 0 && !--account)
1063 >                        done_contrib(account = accumulate);
1064                  lastdone = rtp->raynum;
1065 <                free(rtp->buf);         /* free up buffer space */
1065 >                if (rtp->buf != NULL)   /* free up buffer space */
1066 >                        free(rtp->buf);
1067                  rt_unproc = rtp->next;
1068                  free(rtp);              /* done with this ray tree */
1069          }
# Line 976 | Line 1147 | get_rproc(void)
1147   void
1148   trace_contribs(FILE *fin)
1149   {
1150 +        static int      ignore_warning_given = 0;
1151          char            inpbuf[128];
1152          int             iblen;
1153          struct rtproc   *rtp;
1154                                                  /* loop over input */
1155 <        while ((iblen = getinp(inpbuf, fin)) > 0) {
1156 <                if (lastray+1 < lastray ||      /* need reset? */
1157 <                                queue_length() > 5*nrtprocs()) {
1155 >        while ((iblen = getinp(inpbuf, fin)) >= 0) {
1156 >                if (!iblen && accumulate != 1) {
1157 >                        if (!ignore_warning_given++)
1158 >                                error(WARNING,
1159 >                                "dummy ray(s) ignored during accumulation\n");
1160 >                        continue;
1161 >                }
1162 >                if (!iblen ||                   /* need flush/reset? */
1163 >                                queue_length() > 10*nrtprocs() ||
1164 >                                lastray+1 < lastray) {
1165                          while (wait_rproc() != NULL)
1166                                  process_queue();
1167 <                        lastdone = lastray = 0;
1167 >                        if (lastray+1 < lastray)
1168 >                                lastdone = lastray = 0;
1169                  }
1170                  rtp = get_rproc();              /* get avail. rtrace process */
1171 <                rtp->raynum = ++lastray;        /* assign ray to it */
1172 <                writebuf(rtp->pd.w, inpbuf, iblen);
1173 <                if (raysleft && !--raysleft)
1174 <                        break;
1171 >                rtp->raynum = ++lastray;        /* assign ray */
1172 >                if (iblen) {                    /* trace ray if valid */
1173 >                        writebuf(rtp->pd.w, inpbuf, iblen);
1174 >                } else {                        /* else bypass dummy ray */
1175 >                        queue_raytree(rtp);     /* queue empty ray/record */
1176 >                        if ((yres <= 0) | (xres <= 0))
1177 >                                waitflush = 1;  /* flush right after */
1178 >                }
1179                  process_queue();                /* catch up with results */
1180 +                if (raysleft && !--raysleft)
1181 +                        break;                  /* preemptive EOI */
1182          }
1183          while (wait_rproc() != NULL)            /* process outstanding rays */
1184                  process_queue();
1185 +        if (accumulate <= 0)
1186 +                done_contrib(0);                /* output tallies */
1187 +        else if (account < accumulate) {
1188 +                error(WARNING, "partial accumulation in final record");
1189 +                done_contrib(accumulate - account);
1190 +        }
1191          if (raysleft)
1192                  error(USER, "unexpected EOF on input");
1193          lu_done(&ofiletab);                     /* close output files */
1194   }
1195  
1196 + /* get ray contribution from previous file */
1197 + static int
1198 + get_contrib(DCOLOR cnt, FILE *finp)
1199 + {
1200 +        COLOR   fv;
1201 +        COLR    cv;
1202 +
1203 +        switch (outfmt) {
1204 +        case 'a':
1205 +                return(fscanf(finp,"%lf %lf %lf",&cnt[0],&cnt[1],&cnt[2]) == 3);
1206 +        case 'f':
1207 +                if (fread(fv, sizeof(fv[0]), 3, finp) != 3)
1208 +                        return(0);
1209 +                copycolor(cnt, fv);
1210 +                return(1);
1211 +        case 'd':
1212 +                return(fread(cnt, sizeof(cnt[0]), 3, finp) == 3);
1213 +        case 'c':
1214 +                if (fread(cv, sizeof(cv), 1, finp) != 1)
1215 +                        return(0);
1216 +                colr_color(fv, cv);
1217 +                copycolor(cnt, fv);
1218 +                return(1);
1219 +        default:
1220 +                error(INTERNAL, "botched output format");
1221 +        }
1222 +        return(0);      /* pro forma return */
1223 + }
1224 +
1225 + /* close output file opened for input */
1226 + static int
1227 + myclose(const LUENT *e, void *p)
1228 + {
1229 +        STREAMOUT       *sop = (STREAMOUT *)e->data;
1230 +        
1231 +        if (sop->ofp == NULL)
1232 +                return(0);
1233 +        fclose(sop->ofp);
1234 +        sop->ofp = NULL;
1235 +        return(0);
1236 + }
1237 +
1238 + /* load previously accumulated values */
1239 + void
1240 + reload_output(void)
1241 + {
1242 +        int             i, j;
1243 +        MODCONT         *mp;
1244 +        int             ofl;
1245 +        char            oname[1024];
1246 +        char            *fmode = "rb";
1247 +        char            *outvfmt;
1248 +        LUENT           *ment, *oent;
1249 +        int             xr, yr;
1250 +        STREAMOUT       sout;
1251 +        DCOLOR          rgbv;
1252 +
1253 +        switch (outfmt) {
1254 +        case 'a':
1255 +                outvfmt = "ascii";
1256 +                fmode = "r";
1257 +                break;
1258 +        case 'f':
1259 +                outvfmt = "float";
1260 +                break;
1261 +        case 'd':
1262 +                outvfmt = "double";
1263 +                break;
1264 +        case 'c':
1265 +                outvfmt = COLRFMT;
1266 +                break;
1267 +        default:
1268 +                error(INTERNAL, "botched output format");
1269 +                return;
1270 +        }
1271 +                                                /* reload modifier values */
1272 +        for (i = 0; i < nmods; i++) {
1273 +                ment = lu_find(&modconttab,modname[i]);
1274 +                mp = (MODCONT *)ment->data;
1275 +                if (mp->outspec == NULL)
1276 +                        error(USER, "cannot reload from stdout");
1277 +                if (mp->outspec[0] == '!')
1278 +                        error(USER, "cannot reload from command");
1279 +                for (j = 0; ; j++) {            /* load each modifier bin */
1280 +                        ofl = ofname(oname, mp->outspec, mp->modname, j);
1281 +                        if (ofl < 0)
1282 +                                error(USER, "bad output file specification");
1283 +                        oent = lu_find(&ofiletab, oname);
1284 +                        if (oent->data != NULL) {
1285 +                                sout = *(STREAMOUT *)oent->data;
1286 +                        } else {
1287 +                                sout.reclen = 0;
1288 +                                sout.outpipe = 0;
1289 +                                sout.xr = xres; sout.yr = yres;
1290 +                                sout.ofp = NULL;
1291 +                        }
1292 +                        if (sout.ofp == NULL) { /* open output as input */
1293 +                                sout.ofp = fopen(oname, fmode);
1294 +                                if (sout.ofp == NULL) {
1295 +                                        if (j)
1296 +                                                break;  /* assume end of modifier */
1297 +                                        sprintf(errmsg, "missing reload file '%s'",
1298 +                                                        oname);
1299 +                                        error(WARNING, errmsg);
1300 +                                        break;
1301 +                                }
1302 +                                if (header && checkheader(sout.ofp, outvfmt, NULL) != 1) {
1303 +                                        sprintf(errmsg, "format mismatch for '%s'",
1304 +                                                        oname);
1305 +                                        error(USER, errmsg);
1306 +                                }
1307 +                                if ((sout.xr > 0) & (sout.yr > 0) &&
1308 +                                                (!fscnresolu(&xr, &yr, sout.ofp) ||
1309 +                                                        (xr != sout.xr) |
1310 +                                                        (yr != sout.yr))) {
1311 +                                        sprintf(errmsg, "resolution mismatch for '%s'",
1312 +                                                        oname);
1313 +                                        error(USER, errmsg);
1314 +                                }
1315 +                        }
1316 +                                                        /* read in RGB value */
1317 +                        if (!get_contrib(rgbv, sout.ofp)) {
1318 +                                if (!j) {
1319 +                                        fclose(sout.ofp);
1320 +                                        break;          /* ignore empty file */
1321 +                                }
1322 +                                if (j < mp->nbins) {
1323 +                                        sprintf(errmsg, "missing data in '%s'",
1324 +                                                        oname);
1325 +                                        error(USER, errmsg);
1326 +                                }
1327 +                                break;
1328 +                        }
1329 +                        if (j >= mp->nbins)             /* grow modifier size */
1330 +                                ment->data = (char *)(mp = growmodifier(mp, j+1));
1331 +                        copycolor(mp->cbin[j], rgbv);
1332 +                        if (oent->key == NULL)          /* new file entry */
1333 +                                oent->key = strcpy((char *)
1334 +                                                malloc(strlen(oname)+1), oname);
1335 +                        if (oent->data == NULL)
1336 +                                oent->data = (char *)malloc(sizeof(STREAMOUT));
1337 +                        *(STREAMOUT *)oent->data = sout;
1338 +                }
1339 +        }
1340 +        lu_doall(&ofiletab, myclose, NULL);     /* close all files */
1341 + }
1342 +
1343   /* seek on the given output file */
1344   static int
1345   myseeko(const LUENT *e, void *p)
1346   {
1347 <        if (fseeko((FILE *)e->data, *(off_t *)p, SEEK_CUR) < 0) {
1347 >        STREAMOUT       *sop = (STREAMOUT *)e->data;
1348 >        off_t           nbytes = *(off_t *)p;
1349 >        
1350 >        if (sop->reclen > 1)
1351 >                nbytes = nbytes * sop->reclen;
1352 >        if (fseeko(sop->ofp, nbytes, SEEK_CUR) < 0) {
1353                  sprintf(errmsg, "seek error on file '%s'", e->key);
1354                  error(SYSTEM, errmsg);
1355          }
1356 +        return 0;
1357   }
1358  
1359   /* recover output if possible */
1360   void
1361   recover_output(FILE *fin)
1362   {
1363 <        off_t   lastout = -1;
1364 <        int     outvsiz;
1365 <        char    *outvfmt;
1366 <        int     i, j;
1367 <        MODCONT *mp;
1368 <        int     ofl;
1369 <        char    oname[1024];
1370 <        LUENT   *ment, *oent;
1371 <        FILE    *fp;
1372 <        off_t   nvals;
1363 >        off_t           lastout = -1;
1364 >        int             outvsiz, recsiz;
1365 >        char            *outvfmt;
1366 >        int             i, j;
1367 >        MODCONT         *mp;
1368 >        int             ofl;
1369 >        char            oname[1024];
1370 >        LUENT           *ment, *oent;
1371 >        STREAMOUT       sout;
1372 >        off_t           nvals;
1373 >        int             xr, yr;
1374  
1375          switch (outfmt) {
1376          case 'a':
# Line 1052 | Line 1398 | recover_output(FILE *fin)
1398                  mp = (MODCONT *)ment->data;
1399                  if (mp->outspec == NULL)
1400                          error(USER, "cannot recover from stdout");
1401 +                if (mp->outspec[0] == '!')
1402 +                        error(USER, "cannot recover from command");
1403                  for (j = 0; ; j++) {            /* check each bin's file */
1404                          ofl = ofname(oname, mp->outspec, mp->modname, j);
1405                          if (ofl < 0)
1406                                  error(USER, "bad output file specification");
1407                          oent = lu_find(&ofiletab, oname);
1408 <                        if (oent->data != NULL) { /* saw this one already */
1408 >                        if (oent->data != NULL) {
1409 >                                sout = *(STREAMOUT *)oent->data;
1410 >                        } else {
1411 >                                sout.reclen = 0;
1412 >                                sout.outpipe = 0;
1413 >                                sout.ofp = NULL;
1414 >                        }
1415 >                        if (sout.ofp != NULL) { /* already open? */
1416                                  if (ofl & OF_BIN)
1417                                          continue;
1418                                  break;
1419                          }
1065                        if (oname[0] == '!')
1066                                error(USER, "cannot recover from command");
1420                                                  /* open output */
1421 <                        fp = fopen(oname, "rb+");
1422 <                        if (fp == NULL) {
1421 >                        sout.ofp = fopen(oname, "rb+");
1422 >                        if (sout.ofp == NULL) {
1423                                  if (j)
1424                                          break;  /* assume end of modifier */
1425                                  sprintf(errmsg, "missing recover file '%s'",
1426                                                  oname);
1427 <                                error(USER, errmsg);
1427 >                                error(WARNING, errmsg);
1428 >                                break;
1429                          }
1430 <                        nvals = lseek(fileno(fp), 0, SEEK_END);
1430 >                        nvals = lseek(fileno(sout.ofp), 0, SEEK_END);
1431                          if (nvals <= 0) {
1432                                  lastout = 0;    /* empty output, quit here */
1433 <                                fclose(fp);
1433 >                                fclose(sout.ofp);
1434                                  break;
1435                          }
1436 <                        lseek(fileno(fp), 0, SEEK_SET);
1437 <                        if (header) {
1084 <                                int     xr, yr;
1085 <                                if (checkheader(fp, outvfmt, NULL) != 1) {
1436 >                        if (!sout.reclen) {
1437 >                                if (!(ofl & OF_BIN)) {
1438                                          sprintf(errmsg,
1439 <                                                "format mismatch for '%s'",
1439 >                                                "need -bn to recover file '%s'",
1440                                                          oname);
1441                                          error(USER, errmsg);
1442                                  }
1443 <                                if (xres > 0 && yres > 0 &&
1444 <                                                (!fscnresolu(&xr, &yr, fp) ||
1445 <                                                        xr != xres ||
1446 <                                                        yr != yres)) {
1447 <                                        sprintf(errmsg,
1448 <                                                "resolution mismatch for '%s'",
1449 <                                                        oname);
1450 <                                        error(USER, errmsg);
1451 <                                }
1443 >                                recsiz = outvsiz;
1444 >                        } else
1445 >                                recsiz = outvsiz * sout.reclen;
1446 >
1447 >                        lseek(fileno(sout.ofp), 0, SEEK_SET);
1448 >                        if (header && checkheader(sout.ofp, outvfmt, NULL) != 1) {
1449 >                                sprintf(errmsg, "format mismatch for '%s'",
1450 >                                                oname);
1451 >                                error(USER, errmsg);
1452                          }
1453 <                        nvals = (nvals - (off_t)ftell(fp)) / outvsiz;
1454 <                        if (lastout < 0 || nvals < lastout)
1453 >                        sout.xr = xres; sout.yr = yres;
1454 >                        if ((sout.xr > 0) & (sout.yr > 0) &&
1455 >                                        (!fscnresolu(&xr, &yr, sout.ofp) ||
1456 >                                                (xr != sout.xr) |
1457 >                                                (yr != sout.yr))) {
1458 >                                sprintf(errmsg, "resolution mismatch for '%s'",
1459 >                                                oname);
1460 >                                error(USER, errmsg);
1461 >                        }
1462 >                        nvals = (nvals - (off_t)ftell(sout.ofp)) / recsiz;
1463 >                        if ((lastout < 0) | (nvals < lastout))
1464                                  lastout = nvals;
1465 <                        if (oent->key == NULL) /* new entry */
1465 >                        if (oent->key == NULL)  /* new entry */
1466                                  oent->key = strcpy((char *)
1467                                                  malloc(strlen(oname)+1), oname);
1468 <                        oent->data = (char *)fp;
1468 >                        if (oent->data == NULL)
1469 >                                oent->data = (char *)malloc(sizeof(STREAMOUT));
1470 >                        *(STREAMOUT *)oent->data = sout;
1471                          if (!(ofl & OF_BIN))
1472                                  break;          /* no bin separation */
1473                  }
# Line 1113 | Line 1476 | recover_output(FILE *fin)
1476                          lu_done(&ofiletab);     /* reclose all outputs */
1477                          return;
1478                  }
1479 <                if (j > mp->nbins) {            /* preallocate modifier bins */
1480 <                        mp = (MODCONT *)realloc(mp, sizeof(MODCONT) +
1118 <                                                        (j-1)*sizeof(DCOLOR));
1119 <                        if (mp == NULL)
1120 <                                error(SYSTEM, "out of memory in recover_output");
1121 <                        memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins);
1122 <                        mp->nbins = j;
1123 <                        ment->data = (char *)mp;
1124 <                }
1479 >                if (j > mp->nbins)              /* reallocate modifier bins */
1480 >                        ment->data = (char *)(mp = growmodifier(mp, j));
1481          }
1482          if (lastout < 0) {
1483                  error(WARNING, "no output files to recover");
1484                  return;
1485          }
1486 <        if (raysleft && lastout >= raysleft) {
1486 >        if (raysleft && lastout >= raysleft/accumulate) {
1487                  error(WARNING, "output appears to be complete");
1488                  /* XXX should read & discard input? */
1489                  quit(0);
# Line 1137 | Line 1493 | recover_output(FILE *fin)
1493          lu_doall(&ofiletab, myseeko, &nvals);
1494                                                  /* skip repeated input */
1495          for (nvals = 0; nvals < lastout; nvals++)
1496 <                if (getinp(oname, fin) <= 0)
1496 >                if (getinp(oname, fin) < 0)
1497                          error(USER, "unexpected EOF on input");
1498 <        lastray = lastdone = (unsigned long)lastout;
1498 >        lastray = lastdone = (unsigned long)lastout * accumulate;
1499          if (raysleft)
1500                  raysleft -= lastray;
1501   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines