--- ray/src/rt/rc2.c 2012/06/21 17:14:32 2.6 +++ ray/src/rt/rc2.c 2014/05/29 04:56:43 2.9 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rc2.c,v 2.6 2012/06/21 17:14:32 greg Exp $"; +static const char RCSid[] = "$Id: rc2.c,v 2.9 2014/05/29 04:56:43 greg Exp $"; #endif /* * Accumulate ray contributions for a set of materials @@ -8,6 +8,7 @@ static const char RCSid[] = "$Id: rc2.c,v 2.6 2012/06/ #include "rcontrib.h" #include "resolu.h" +#include /* Close output stream and free record */ static void @@ -111,6 +112,7 @@ printheader(FILE *fout, const char *info) printargs(gargc-1, gargv, fout); /* add our command */ fprintf(fout, "SOFTWARE= %s\n", VersionID); fputnow(fout); + fputs("NCOMP=3\n", fout); /* always RGB */ if (info != NULL) /* add extra info if given */ fputs(info, fout); fputformat(formstr(outfmt), fout); @@ -131,8 +133,8 @@ printresolu(FILE *fout, int xr, int yr) STREAMOUT * getostream(const char *ospec, const char *mname, int bn, int noopen) { - /* static const DCOLOR nocontrib = BLKCOLOR; */ static STREAMOUT stdos; + char info[1024]; int ofl; char oname[1024]; LUENT *lep; @@ -142,8 +144,10 @@ getostream(const char *ospec, const char *mname, int b if (!noopen & !using_stdout) { if (outfmt != 'a') SET_FILE_BINARY(stdout); - if (header) - printheader(stdout, NULL); + if (header) { + sprintf(info, "NCOLS=%d\n", stdos.reclen); + printheader(stdout, info); + } printresolu(stdout, xres, yres); if (waitflush > 0) fflush(stdout); @@ -182,7 +186,6 @@ getostream(const char *ospec, const char *mname, int b } } if (!noopen && sop->ofp == NULL) { /* open output stream */ - long i; if (oname[0] == '!') /* output to command */ sop->ofp = popen(oname+1, "w"); else /* else open file */ @@ -195,7 +198,6 @@ getostream(const char *ospec, const char *mname, int b flockfile(sop->ofp); /* avoid lock/unlock overhead */ #endif if (header) { - char info[512]; char *cp = info; if (ofl & OF_MODIFIER || sop->reclen == 1) { sprintf(cp, "MODIFIER=%s\n", mname); @@ -205,24 +207,13 @@ getostream(const char *ospec, const char *mname, int b sprintf(cp, "BIN=%d\n", bn); while (*cp) ++cp; } - *cp = '\0'; + sprintf(cp, "NCOLS=%d\n", sop->reclen); printheader(sop->ofp, info); } if (accumulate > 0) { /* global resolution */ sop->xr = xres; sop->yr = yres; } printresolu(sop->ofp, sop->xr, sop->yr); -#if 0 - /* play catch-up */ - for (i = accumulate > 0 ? lastdone/accumulate : 0; i--; ) { - int j = sop->reclen; - if (j <= 0) j = 1; - while (j--) - put_contrib(nocontrib, sop->ofp); - if (outfmt == 'a') - putc('\n', sop->ofp); - } -#endif if (waitflush > 0) fflush(sop->ofp); } @@ -363,7 +354,7 @@ void end_record() { --waitflush; - lu_doall(&ofiletab, puteol, NULL); + lu_doall(&ofiletab, &puteol, NULL); if (using_stdout & (outfmt == 'a')) putc('\n', stdout); if (!waitflush) { @@ -513,7 +504,7 @@ reload_output() *(STREAMOUT *)oent->data = sout; } } - lu_doall(&ofiletab, myclose, NULL); /* close all files */ + lu_doall(&ofiletab, &myclose, NULL); /* close all files */ } @@ -669,7 +660,7 @@ recover_output() } /* seek on all files */ nvals = lastout * outvsiz; - lu_doall(&ofiletab, myseeko, &nvals); + lu_doall(&ofiletab, &myseeko, &nvals); /* skip repeated input */ lastout *= accumulate; for (nvals = 0; nvals < lastout; nvals++) {