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

Comparing ray/src/rt/rc2.c (file contents):
Revision 2.2 by greg, Sun Jun 10 05:25:42 2012 UTC vs.
Revision 2.8 by greg, Wed Aug 7 05:10:09 2013 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8  
9   #include "rcontrib.h"
10   #include "resolu.h"
11 < #include "platform.h"
11 > #include <ctype.h>
12  
13 + /* Close output stream and free record */
14 + static void
15 + closestream(void *p)
16 + {
17 +        STREAMOUT       *sop = (STREAMOUT *)p;
18 +        
19 +        if (sop->ofp != NULL) {
20 +                int     status = 0;
21 +                if (sop->outpipe)
22 +                        status = pclose(sop->ofp);
23 +                else if (sop->ofp != stdout)
24 +                        status = fclose(sop->ofp);
25 +                if (status)
26 +                        error(SYSTEM, "error closing output stream");
27 +        }
28 +        free(p);
29 + }
30 +
31 + LUTAB   ofiletab = LU_SINIT(free,closestream);  /* output file table */
32 +
33   #define OF_MODIFIER     01
34   #define OF_BIN          02
35  
# Line 120 | Line 140 | getostream(const char *ospec, const char *mname, int b
140          STREAMOUT               *sop;
141          
142          if (ospec == NULL) {                    /* use stdout? */
143 <                if (!noopen && !using_stdout) {
143 >                if (!noopen & !using_stdout) {
144                          if (outfmt != 'a')
145                                  SET_FILE_BINARY(stdout);
146                          if (header)
# Line 163 | Line 183 | getostream(const char *ospec, const char *mname, int b
183                  }
184          }
185          if (!noopen && sop->ofp == NULL) {      /* open output stream */
166                long            i;
186                  if (oname[0] == '!')            /* output to command */
187                          sop->ofp = popen(oname+1, "w");
188                  else                            /* else open file */
# Line 193 | Line 212 | getostream(const char *ospec, const char *mname, int b
212                          sop->xr = xres; sop->yr = yres;
213                  }
214                  printresolu(sop->ofp, sop->xr, sop->yr);
196 #if 0
197                                                /* play catch-up */
198                for (i = accumulate > 0 ? lastdone/accumulate : 0; i--; ) {
199                        int     j = sop->reclen;
200                        if (j <= 0) j = 1;
201                        while (j--)
202                                put_contrib(nocontrib, sop->ofp);
203                        if (outfmt == 'a')
204                                putc('\n', sop->ofp);
205                }
206 #endif
215                  if (waitflush > 0)
216                          fflush(sop->ofp);
217          }
# Line 309 | Line 317 | mod_output(MODCONT *mp)
317  
318          put_contrib(mp->cbin[0], sop->ofp);
319          if (mp->nbins > 3 &&    /* minor optimization */
320 <                        sop == getostream(mp->outspec, mp->modname, 1, 0))
320 >                        sop == getostream(mp->outspec, mp->modname, 1, 0)) {
321                  for (j = 1; j < mp->nbins; j++)
322                          put_contrib(mp->cbin[j], sop->ofp);
323 <        else
323 >        } else {
324                  for (j = 1; j < mp->nbins; j++) {
325                          sop = getostream(mp->outspec, mp->modname, j, 0);
326                          put_contrib(mp->cbin[j], sop->ofp);
327                  }
328 +        }
329   }
330  
331  
# Line 343 | Line 352 | void
352   end_record()
353   {
354          --waitflush;
355 <        lu_doall(&ofiletab, puteol, NULL);
355 >        lu_doall(&ofiletab, &puteol, NULL);
356          if (using_stdout & (outfmt == 'a'))
357                  putc('\n', stdout);
358          if (!waitflush) {
# Line 493 | Line 502 | reload_output()
502                          *(STREAMOUT *)oent->data = sout;
503                  }
504          }
505 <        lu_doall(&ofiletab, myclose, NULL);     /* close all files */
505 >        lu_doall(&ofiletab, &myclose, NULL);    /* close all files */
506   }
507  
508  
# Line 649 | Line 658 | recover_output()
658          }
659                                                  /* seek on all files */
660          nvals = lastout * outvsiz;
661 <        lu_doall(&ofiletab, myseeko, &nvals);
661 >        lu_doall(&ofiletab, &myseeko, &nvals);
662                                                  /* skip repeated input */
663 +        lastout *= accumulate;
664          for (nvals = 0; nvals < lastout; nvals++) {
665                  FVECT   vdummy;
666                  if (getvec(vdummy) < 0 || getvec(vdummy) < 0)
667                          error(USER, "unexpected EOF on input");
668          }
669 <        lastray = lastdone = lastout * accumulate;
669 >        lastray = lastdone = (RNUMBER)lastout;
670          if (raysleft)
671                  raysleft -= lastray;
672   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines