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 |
|
} |
185 |
|
CMATRIX *smtx, *Dmat, *Tmat, *imtx; |
186 |
|
/* get sky vector/matrix */ |
187 |
|
smtx = cm_load(argv[a+3], 0, nsteps, skyfmt); |
188 |
+ |
nsteps = smtx->ncols; |
189 |
|
/* load BSDF */ |
190 |
|
Tmat = cm_loadBTDF(argv[a+1]); |
191 |
|
/* load Daylight matrix */ |
199 |
|
cm_free(imtx); |
200 |
|
} else { /* sky vector/matrix only */ |
201 |
|
cmtx = cm_load(argv[a+1], 0, nsteps, skyfmt); |
202 |
+ |
nsteps = cmtx->ncols; |
203 |
|
} |
204 |
|
/* prepare output stream */ |
205 |
|
if ((ofspec != NULL) & (nsteps == 1) && hasNumberFormat(ofspec)) { |
270 |
|
#ifdef getc_unlocked |
271 |
|
flockfile(ofp); |
272 |
|
#endif |
273 |
+ |
if (headout) { /* header output */ |
274 |
+ |
newheader("RADIANCE", ofp); |
275 |
+ |
printargs(argc, argv, ofp); |
276 |
+ |
fputnow(ofp); |
277 |
+ |
fprintf(ofp, "FRAME=%d\n", i+1); |
278 |
+ |
fprintf(ofp, "NROWS=%d\n", rvec->nrows); |
279 |
+ |
fputs("NCOLS=1\nNCOMP=3\n", ofp); |
280 |
+ |
fputformat((char *)cm_fmt_id[outfmt], ofp); |
281 |
+ |
fputc('\n', ofp); |
282 |
+ |
} |
283 |
|
cm_write(rvec, outfmt, ofp); |
284 |
|
if (fclose(ofp) == EOF) { |
285 |
|
fprintf(stderr, |
296 |
|
#endif |
297 |
|
if (outfmt != DTascii) |
298 |
|
SET_FILE_BINARY(ofp); |
299 |
< |
if (rmtx->ncols > 1) { /* header if actual matrix */ |
299 |
> |
if (headout) { /* header output */ |
300 |
|
newheader("RADIANCE", ofp); |
301 |
|
printargs(argc, argv, ofp); |
302 |
|
fputnow(ofp); |
303 |
+ |
fprintf(ofp, "NROWS=%d\n", rmtx->nrows); |
304 |
|
fprintf(ofp, "NCOLS=%d\n", rmtx->ncols); |
305 |
|
fputs("NCOMP=3\n", ofp); |
306 |
|
fputformat((char *)cm_fmt_id[outfmt], ofp); |
317 |
|
cm_free(cmtx); |
318 |
|
return(0); |
319 |
|
userr: |
320 |
< |
fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] DCspec [skyf]\n", |
320 |
> |
fprintf(stderr, "Usage: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] DCspec [skyf]\n", |
321 |
|
progname); |
322 |
< |
fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n", |
322 |
> |
fprintf(stderr, " or: %s [-n nsteps][-o ospec][-i{f|d|h}][-o{f|d}] Vspec Tbsdf.xml Dmat.dat [skyf]\n", |
323 |
|
progname); |
324 |
|
return(1); |
325 |
|
} |