--- ray/src/util/dctimestep.c 2014/09/17 22:40:49 2.34 +++ ray/src/util/dctimestep.c 2016/03/06 01:13:18 2.37 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: dctimestep.c,v 2.34 2014/09/17 22:40:49 greg Exp $"; +static const char RCSid[] = "$Id: dctimestep.c,v 2.37 2016/03/06 01:13:18 schorsch Exp $"; #endif /* * Compute time-step result using Daylight Coefficient method. @@ -8,6 +8,7 @@ static const char RCSid[] = "$Id: dctimestep.c,v 2.34 */ #include +#include "platform.h" #include "standard.h" #include "cmatrix.h" #include "platform.h" @@ -26,7 +27,7 @@ sum_images(const char *fspec, const CMATRIX *cv, FILE int i, y; if (cv->ncols != 1) - error(INTERNAL, "expected matrix in sum_images()"); + error(INTERNAL, "expected vector in sum_images()"); for (i = 0; i < cv->nrows; i++) { const COLORV *scv = cv_lval(cv,i); char fname[1024]; @@ -182,13 +183,20 @@ main(int argc, char *argv[]) goto userr; if (argc-a > 2) { /* VTDs expression */ - CMATRIX *smtx, *Dmat, *Tmat, *imtx; + CMATRIX *smtx, *Dmat, *Tmat, *imtx; + const char *ccp; /* get sky vector/matrix */ smtx = cm_load(argv[a+3], 0, nsteps, skyfmt); + nsteps = smtx->ncols; /* load BSDF */ - Tmat = cm_loadBTDF(argv[a+1]); + if (argv[a+1][0] != '!' && + (ccp = strrchr(argv[a+1], '.')) != NULL && + !strcasecmp(ccp+1, "XML")) + Tmat = cm_loadBTDF(argv[a+1]); + else + Tmat = cm_load(argv[a+1], 0, 0, DTfromHeader); /* load Daylight matrix */ - Dmat = cm_load(argv[a+2], Tmat==NULL ? 0 : Tmat->ncols, + Dmat = cm_load(argv[a+2], Tmat->ncols, smtx->nrows, DTfromHeader); /* multiply vector through */ imtx = cm_multiply(Dmat, smtx); @@ -198,6 +206,7 @@ main(int argc, char *argv[]) cm_free(imtx); } else { /* sky vector/matrix only */ cmtx = cm_load(argv[a+1], 0, nsteps, skyfmt); + nsteps = cmtx->ncols; } /* prepare output stream */ if ((ofspec != NULL) & (nsteps == 1) && hasNumberFormat(ofspec)) { @@ -317,7 +326,7 @@ main(int argc, char *argv[]) userr: fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n", progname); - fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n", + fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf Dmat.dat [skyf]\n", progname); return(1); }