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.47 by greg, Fri Mar 11 02:27:02 2022 UTC vs.
Revision 2.49 by greg, Fri Mar 11 02:44:33 2022 UTC

# Line 107 | Line 107 | sum_images(const char *fspec, const CMATRIX *cv, FILE
107          return(i);
108   }
109  
110 + /* adjust matrix dimensions according to user size(s) */
111 + static int
112 + alt_dim(CMATRIX *cm, int nr, int nc)
113 + {
114 +        if ((nr <= 0) & (nc <= 0))
115 +                return(0);
116 +        if ((nr == cm->nrows) & (nc == cm->ncols))
117 +                return(0);
118 +        if (nr > 0) {
119 +                if (nc <= 0)
120 +                        nc = cm->nrows*cm->ncols/nr;
121 +                if (nr*nc != cm->nrows*cm->ncols) {
122 +                        fprintf(stderr, "Bad dimensions: %dx%d != %dx%d\n",
123 +                                        nr, nc, cm->nrows, cm->ncols);
124 +                        return(-1);
125 +                }
126 +        } else /* nc > 0 */ {
127 +                nr = cm->nrows*cm->ncols/nc;
128 +                if (nc*nr != cm->nrows*cm->ncols) {
129 +                        fprintf(stderr, "Bad dimensions: %d does not divide %dx%d evenly\n",
130 +                                        nc, cm->nrows, cm->ncols);
131 +                        return(-1);
132 +                }
133 +        }
134 +        cm->nrows = nr;
135 +        cm->ncols = nc;
136 +        return(1);
137 + }
138 +
139   /* check to see if a string contains a %d or %o specification */
140   static int
141   hasNumberFormat(const char *s)
# Line 296 | Line 325 | main(int argc, char *argv[])
325                          const char      *wtype = (outfmt==DTascii) ? "w" : "wb";
326                          for (i = 0; i < nsteps; i++) {
327                                  CMATRIX *rvec = cm_column(rmtx, i);
328 <                                if (yres > 0) {
329 <                                        if (xres <= 0)
301 <                                                xres = rvec->nrows/yres;
302 <                                        if (xres*yres != rvec->nrows) {
303 <                                                fprintf(stderr, "Bad resolution: %d != %dx%d\n",
304 <                                                                rvec->nrows, xres, yres);
305 <                                                return(1);
306 <                                        }
307 <                                        rvec->nrows = yres;
308 <                                        rvec->ncols = xres;
309 <                                } else if (xres > 0) {
310 <                                        yres = rvec->nrows/xres;
311 <                                        if (xres*yres != rvec->nrows) {
312 <                                                fprintf(stderr,
313 <                                                        "Bad resolution: %d does not divide %d evenly\n",
314 <                                                                        xres, rvec->nrows);
315 <                                                return(1);
316 <                                        }
317 <                                        rvec->nrows = yres;
318 <                                        rvec->ncols = xres;
319 <                                }
328 >                                if (alt_dim(rvec, yres, xres) < 0)
329 >                                        return(1);
330                                  sprintf(fnbuf, ofspec, i);
331                                  if ((ofp = fopen(fnbuf, wtype)) == NULL) {
332                                          fprintf(stderr,
# Line 358 | Line 368 | main(int argc, char *argv[])
368   #endif
369                          if (outfmt != DTascii)
370                                  SET_FILE_BINARY(ofp);
371 +                        if (alt_dim(rmtx, yres, xres) < 0)
372 +                                return(1);
373                          if (headout) {          /* header output */
374                                  newheader("RADIANCE", ofp);
375                                  printargs(argc, argv, ofp);
# Line 383 | Line 395 | main(int argc, char *argv[])
395          cm_free(cmtx);
396          return(0);
397   userr:
398 <        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d|c}] DCspec [skyf]\n",
398 >        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-x xr][-y yr][-i{f|d|h}][-o{f|d|c}] DCspec [skyf]\n",
399                                  progname);
400 <        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d|c}] Vspec Tbsdf Dmat.dat [skyf]\n",
400 >        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-x xr][-y yr][-i{f|d|h}][-o{f|d|c}] Vspec Tbsdf Dmat.dat [skyf]\n",
401                                  progname);
402          return(1);
403   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines