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

Comparing ray/src/util/dctimestep.c (file contents):
Revision 2.30 by greg, Sat Feb 8 01:28:06 2014 UTC vs.
Revision 2.33 by greg, Sun Jun 1 03:20:29 2014 UTC

# Line 26 | Line 26 | sum_images(const char *fspec, const CMATRIX *cv, FILE
26          int     i, y;
27  
28          if (cv->ncols != 1)
29 <                error(INTERNAL, "expected vector in sum_images()");
29 >                error(INTERNAL, "expected matrix in sum_images()");
30          for (i = 0; i < cv->nrows; i++) {
31                  const COLORV    *scv = cv_lval(cv,i);
32                  char            fname[1024];
33                  FILE            *fp;
34                  int             dt, xr, yr;
35                  COLORV          *psp;
36 +                char            *err;
37                                                          /* check for zero */
38                  if ((scv[RED] == 0) & (scv[GRN] == 0) & (scv[BLU] == 0) &&
39                                  (myDT != DTfromHeader) | (i < cv->nrows-1))
40                          continue;
41                                                          /* open next picture */
42                  sprintf(fname, fspec, i);
43 <                if ((fp = fopen(fname, "r")) == NULL) {
43 >                if ((fp = fopen(fname, "rb")) == NULL) {
44                          sprintf(errmsg, "cannot open picture '%s'", fname);
45                          error(SYSTEM, errmsg);
46                  }
47 <                SET_FILE_BINARY(fp);
48 <                dt = getDTfromHeader(fp);
47 >                dt = DTfromHeader;
48 >                if ((err = cm_getheader(&dt, NULL, NULL, fp)) != NULL)
49 >                        error(USER, err);
50                  if ((dt != DTrgbe) & (dt != DTxyze) ||
51                                  !fscnresolu(&xr, &yr, fp)) {
52                          sprintf(errmsg, "file '%s' not a picture", fname);
# Line 132 | Line 134 | main(int argc, char *argv[])
134                  switch (argv[a][1]) {
135                  case 'n':
136                          nsteps = atoi(argv[++a]);
137 <                        if (nsteps <= 0)
137 >                        if (nsteps < 0)
138                                  goto userr;
139                          break;
140                  case 'i':
# Line 146 | Line 148 | main(int argc, char *argv[])
148                          case 'a':
149                                  skyfmt = DTascii;
150                                  break;
151 +                        case 'h':
152 +                                skyfmt = DTfromHeader;
153 +                                break;
154                          default:
155                                  goto userr;
156                          }
# Line 258 | Line 263 | main(int argc, char *argv[])
263                                                          progname, fnbuf);
264                                          return(1);
265                                  }
266 + #ifdef getc_unlocked
267 +                                flockfile(ofp);
268 + #endif
269                                  cm_write(rvec, outfmt, ofp);
270                                  if (fclose(ofp) == EOF) {
271                                          fprintf(stderr,
# Line 269 | Line 277 | main(int argc, char *argv[])
277                                  cm_free(rvec);
278                          }
279                  } else {
280 + #ifdef getc_unlocked
281 +                        flockfile(ofp);
282 + #endif
283                          if (outfmt != DTascii)
284                                  SET_FILE_BINARY(ofp);
285                          if (rmtx->ncols > 1) {  /* header if actual matrix */
286                                  newheader("RADIANCE", ofp);
287                                  printargs(argc, argv, ofp);
288                                  fputnow(ofp);
289 +                                fprintf(ofp, "NROWS=%d\n", rmtx->nrows);
290 +                                fprintf(ofp, "NCOLS=%d\n", rmtx->ncols);
291 +                                fputs("NCOMP=3\n", ofp);
292                                  fputformat((char *)cm_fmt_id[outfmt], ofp);
293                                  fputc('\n', ofp);
294                          }
# Line 289 | Line 303 | main(int argc, char *argv[])
303          cm_free(cmtx);
304          return(0);
305   userr:
306 <        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] DCspec [skyf]\n",
306 >        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n",
307                                  progname);
308 <        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n",
308 >        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n",
309                                  progname);
310          return(1);
311   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines