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.34 by greg, Wed Sep 17 22:40:49 2014 UTC vs.
Revision 2.38 by greg, Tue Apr 10 23:22:42 2018 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 20 | Line 21 | static int
21   sum_images(const char *fspec, const CMATRIX *cv, FILE *fout)
22   {
23          int     myDT = DTfromHeader;
24 <        COLOR   *scanline = NULL;
24 >        COLR    *scanline = NULL;
25          CMATRIX *pmat = NULL;
26          int     myXR=0, myYR=0;
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 55 | Line 56 | sum_images(const char *fspec, const CMATRIX *cv, FILE
56                  if (myDT == DTfromHeader) {             /* on first one */
57                          myDT = dt;
58                          myXR = xr; myYR = yr;
59 <                        scanline = (COLOR *)malloc(sizeof(COLOR)*myXR);
59 >                        scanline = (COLR *)malloc(sizeof(COLR)*myXR);
60                          if (scanline == NULL)
61                                  error(SYSTEM, "out of memory in sum_images()");
62                          pmat = cm_alloc(myYR, myXR);
# Line 71 | Line 72 | sum_images(const char *fspec, const CMATRIX *cv, FILE
72                  }
73                  psp = pmat->cmem;
74                  for (y = 0; y < yr; y++) {              /* read it in */
75 +                        COLOR   col;
76                          int     x;
77 <                        if (freadscan(scanline, xr, fp) < 0) {
77 >                        if (freadcolrs(scanline, xr, fp) < 0) {
78                                  sprintf(errmsg, "error reading picture '%s'",
79                                                  fname);
80                                  error(SYSTEM, errmsg);
81                          }
82                                                          /* sum in scanline */
83                          for (x = 0; x < xr; x++, psp += 3) {
84 <                                multcolor(scanline[x], scv);
85 <                                addcolor(psp, scanline[x]);
84 >                                if (!scanline[x][EXP])
85 >                                        continue;       /* skip zeroes */
86 >                                colr_color(col, scanline[x]);
87 >                                multcolor(col, scv);
88 >                                addcolor(psp, col);
89                          }
90                  }
91                  fclose(fp);                             /* done this picture */
# Line 182 | Line 187 | main(int argc, char *argv[])
187                  goto userr;
188  
189          if (argc-a > 2) {                       /* VTDs expression */
190 <                CMATRIX *smtx, *Dmat, *Tmat, *imtx;
190 >                CMATRIX         *smtx, *Dmat, *Tmat, *imtx;
191 >                const char      *ccp;
192                                                  /* get sky vector/matrix */
193                  smtx = cm_load(argv[a+3], 0, nsteps, skyfmt);
194 +                nsteps = smtx->ncols;
195                                                  /* load BSDF */
196 <                Tmat = cm_loadBTDF(argv[a+1]);
196 >                if (argv[a+1][0] != '!' &&
197 >                                (ccp = strrchr(argv[a+1], '.')) != NULL &&
198 >                                !strcasecmp(ccp+1, "XML"))
199 >                        Tmat = cm_loadBTDF(argv[a+1]);
200 >                else
201 >                        Tmat = cm_load(argv[a+1], 0, 0, DTfromHeader);
202                                                  /* load Daylight matrix */
203 <                Dmat = cm_load(argv[a+2], Tmat==NULL ? 0 : Tmat->ncols,
203 >                Dmat = cm_load(argv[a+2], Tmat->ncols,
204                                          smtx->nrows, DTfromHeader);
205                                                  /* multiply vector through */
206                  imtx = cm_multiply(Dmat, smtx);
# Line 198 | Line 210 | main(int argc, char *argv[])
210                  cm_free(imtx);
211          } else {                                /* sky vector/matrix only */
212                  cmtx = cm_load(argv[a+1], 0, nsteps, skyfmt);
213 +                nsteps = cmtx->ncols;
214          }
215                                                  /* prepare output stream */
216          if ((ofspec != NULL) & (nsteps == 1) && hasNumberFormat(ofspec)) {
# Line 317 | Line 330 | main(int argc, char *argv[])
330   userr:
331          fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n",
332                                  progname);
333 <        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n",
333 >        fprintf(stderr, "   or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf Dmat.dat [skyf]\n",
334                                  progname);
335          return(1);
336   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines