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.1 by greg, Sat Jun 9 07:16:47 2012 UTC vs.
Revision 2.5 by greg, Tue Jun 19 00:12:08 2012 UTC

# Line 10 | Line 10 | static const char RCSid[] = "$Id$";
10   #include "resolu.h"
11   #include "platform.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 83 | Line 103 | printheader(FILE *fout, const char *info)
103                  if (octname[strlen(octname)-1] != '\n')
104                          fputc('\n', fout);
105          } else {
106 <                FILE    *fin = fopen(octname, "r");
106 >                FILE    *fin = fopen(octname, (outfmt=='a') ? "r" : "rb");
107                  if (fin == NULL)
108                          quit(1);
109 <                checkheader(fin, "ignore", fout);
109 >                checkheader(fin, OCTFMT, fout);
110                  fclose(fin);
111          }
112          printargs(gargc-1, gargv, fout);        /* add our command */
# 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 256 | Line 276 | static void
276   put_contrib(const DCOLOR cnt, FILE *fout)
277   {
278          double  sf = 1;
279 <        float   fv[3];
279 >        COLOR   fv;
280          COLR    cv;
281  
282          if (accumulate > 1)
# Line 272 | Line 292 | put_contrib(const DCOLOR cnt, FILE *fout)
292                  break;
293          case 'f':
294                  if (accumulate > 1) {
295 <                        fv[0] = sf*cnt[0]; fv[1] = sf*cnt[1]; fv[2] = sf*cnt[2];
295 >                        copycolor(fv, cnt);
296 >                        scalecolor(fv, sf);
297                  } else
298                          copycolor(fv, cnt);
299                  fwrite(fv, sizeof(float), 3, fout);
300                  break;
301          case 'd':
302                  if (accumulate > 1) {
303 <                        double  dv[3];
304 <                        dv[0] = sf*cnt[0]; dv[1] = sf*cnt[1]; dv[2] = sf*cnt[2];
303 >                        DCOLOR  dv;
304 >                        copycolor(dv, cnt);
305 >                        scalecolor(dv, sf);
306                          fwrite(dv, sizeof(double), 3, fout);
307                  } else
308                          fwrite(cnt, sizeof(double), 3, fout);
# Line 302 | Line 324 | put_contrib(const DCOLOR cnt, FILE *fout)
324   void
325   mod_output(MODCONT *mp)
326   {
327 <        STREAMOUT       *sop = getostream(mp->outspec, mp->modname, 0,0);
327 >        STREAMOUT       *sop = getostream(mp->outspec, mp->modname, 0, 0);
328          int             j;
329  
330          put_contrib(mp->cbin[0], sop->ofp);
331          if (mp->nbins > 3 &&    /* minor optimization */
332 <                        sop == getostream(mp->outspec, mp->modname, 1,0))
332 >                        sop == getostream(mp->outspec, mp->modname, 1, 0)) {
333                  for (j = 1; j < mp->nbins; j++)
334                          put_contrib(mp->cbin[j], sop->ofp);
335 <        else
335 >        } else {
336                  for (j = 1; j < mp->nbins; j++) {
337 <                        sop = getostream(mp->outspec, mp->modname,j,0);
337 >                        sop = getostream(mp->outspec, mp->modname, j, 0);
338                          put_contrib(mp->cbin[j], sop->ofp);
339                  }
340 +        }
341   }
342  
343  
# Line 649 | Line 672 | recover_output()
672          nvals = lastout * outvsiz;
673          lu_doall(&ofiletab, myseeko, &nvals);
674                                                  /* skip repeated input */
675 +        lastout *= accumulate;
676          for (nvals = 0; nvals < lastout; nvals++) {
677                  FVECT   vdummy;
678                  if (getvec(vdummy) < 0 || getvec(vdummy) < 0)
679                          error(USER, "unexpected EOF on input");
680          }
681 <        lastray = lastdone = lastout * accumulate;
681 >        lastray = lastdone = (RNUMBER)lastout;
682          if (raysleft)
683                  raysleft -= lastray;
684   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines