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