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.31 by greg, Fri May 30 00:00:54 2014 UTC vs.
Revision 2.37 by schorsch, Sun Mar 6 01:13:18 2016 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   */
9  
10   #include <ctype.h>
11 + #include "platform.h"
12   #include "standard.h"
13   #include "cmatrix.h"
14   #include "platform.h"
# Line 26 | Line 27 | sum_images(const char *fspec, const CMATRIX *cv, FILE
27          int     i, y;
28  
29          if (cv->ncols != 1)
30 <                error(INTERNAL, "expected matrix in sum_images()");
30 >                error(INTERNAL, "expected vector in sum_images()");
31          for (i = 0; i < cv->nrows; i++) {
32                  const COLORV    *scv = cv_lval(cv,i);
33                  char            fname[1024];
# Line 119 | Line 120 | hasNumberFormat(const char *s)
120   int
121   main(int argc, char *argv[])
122   {
123 <        int             skyfmt = DTascii;
123 >        int             skyfmt = DTfromHeader;
124          int             outfmt = DTascii;
125 <        int             nsteps = 1;
125 >        int             headout = 1;
126 >        int             nsteps = 0;
127          char            *ofspec = NULL;
128          FILE            *ofp = stdout;
129          CMATRIX         *cmtx;          /* component vector/matrix result */
# Line 136 | Line 138 | main(int argc, char *argv[])
138                          nsteps = atoi(argv[++a]);
139                          if (nsteps < 0)
140                                  goto userr;
141 +                        skyfmt = nsteps ? DTascii : DTfromHeader;
142                          break;
143 +                case 'h':
144 +                        headout = !headout;
145 +                        break;
146                  case 'i':
147                          switch (argv[a][2]) {
148                          case 'f':
# Line 148 | Line 154 | main(int argc, char *argv[])
154                          case 'a':
155                                  skyfmt = DTascii;
156                                  break;
151                        case 'h':
152                                skyfmt = DTfromHeader;
153                                break;
157                          default:
158                                  goto userr;
159                          }
# Line 180 | Line 183 | main(int argc, char *argv[])
183                  goto userr;
184  
185          if (argc-a > 2) {                       /* VTDs expression */
186 <                CMATRIX *smtx, *Dmat, *Tmat, *imtx;
186 >                CMATRIX         *smtx, *Dmat, *Tmat, *imtx;
187 >                const char      *ccp;
188                                                  /* get sky vector/matrix */
189                  smtx = cm_load(argv[a+3], 0, nsteps, skyfmt);
190 +                nsteps = smtx->ncols;
191                                                  /* load BSDF */
192 <                Tmat = cm_loadBTDF(argv[a+1]);
192 >                if (argv[a+1][0] != '!' &&
193 >                                (ccp = strrchr(argv[a+1], '.')) != NULL &&
194 >                                !strcasecmp(ccp+1, "XML"))
195 >                        Tmat = cm_loadBTDF(argv[a+1]);
196 >                else
197 >                        Tmat = cm_load(argv[a+1], 0, 0, DTfromHeader);
198                                                  /* load Daylight matrix */
199 <                Dmat = cm_load(argv[a+2], Tmat==NULL ? 0 : Tmat->ncols,
199 >                Dmat = cm_load(argv[a+2], Tmat->ncols,
200                                          smtx->nrows, DTfromHeader);
201                                                  /* multiply vector through */
202                  imtx = cm_multiply(Dmat, smtx);
# Line 196 | Line 206 | main(int argc, char *argv[])
206                  cm_free(imtx);
207          } else {                                /* sky vector/matrix only */
208                  cmtx = cm_load(argv[a+1], 0, nsteps, skyfmt);
209 +                nsteps = cmtx->ncols;
210          }
211                                                  /* prepare output stream */
212          if ((ofspec != NULL) & (nsteps == 1) && hasNumberFormat(ofspec)) {
# Line 266 | Line 277 | main(int argc, char *argv[])
277   #ifdef getc_unlocked
278                                  flockfile(ofp);
279   #endif
280 +                                if (headout) {  /* header output */
281 +                                        newheader("RADIANCE", ofp);
282 +                                        printargs(argc, argv, ofp);
283 +                                        fputnow(ofp);
284 +                                        fprintf(ofp, "FRAME=%d\n", i+1);
285 +                                        fprintf(ofp, "NROWS=%d\n", rvec->nrows);
286 +                                        fputs("NCOLS=1\nNCOMP=3\n", ofp);
287 +                                        fputformat((char *)cm_fmt_id[outfmt], ofp);
288 +                                        fputc('\n', ofp);
289 +                                }
290                                  cm_write(rvec, outfmt, ofp);
291                                  if (fclose(ofp) == EOF) {
292                                          fprintf(stderr,
# Line 282 | Line 303 | main(int argc, char *argv[])
303   #endif
304                          if (outfmt != DTascii)
305                                  SET_FILE_BINARY(ofp);
306 <                        if (rmtx->ncols > 1) {  /* header if actual matrix */
306 >                        if (headout) {          /* header output */
307                                  newheader("RADIANCE", ofp);
308                                  printargs(argc, argv, ofp);
309                                  fputnow(ofp);
310 +                                fprintf(ofp, "NROWS=%d\n", rmtx->nrows);
311                                  fprintf(ofp, "NCOLS=%d\n", rmtx->ncols);
312                                  fputs("NCOMP=3\n", ofp);
313                                  fputformat((char *)cm_fmt_id[outfmt], ofp);
# Line 302 | Line 324 | main(int argc, char *argv[])
324          cm_free(cmtx);
325          return(0);
326   userr:
327 <        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] DCspec [skyf]\n",
327 >        fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n",
328                                  progname);
329 <        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n",
329 >        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf Dmat.dat [skyf]\n",
330                                  progname);
331          return(1);
332   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines