22 |
|
enum {CIE_X, CIE_Y, CIE_Z}; |
23 |
|
/* assumed maximum # Klems patches */ |
24 |
|
#define MAXPATCHES 145 |
25 |
– |
/* global argv[0] */ |
26 |
– |
char *progname; |
25 |
|
/* selected basis function name */ |
26 |
|
static const char klems_full[] = "LBNL/Klems Full"; |
27 |
|
static const char klems_half[] = "LBNL/Klems Half"; |
194 |
|
for (n = npsamps; n-- > 0; ) { |
195 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
196 |
|
fi_getvec(vin, i+urand(n), abp); |
197 |
< |
ec = SDevalBSDF(&sdv, vout, vin, &bsd); |
197 |
> |
ec = SDevalBSDF(&sdv, vin, vout, &bsd); |
198 |
|
if (ec != SDEnone) |
199 |
|
goto err; |
200 |
|
sum += sdv.cieY; |
243 |
|
for (n = npsamps; n-- > 0; ) { |
244 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
245 |
|
bi_getvec(vin, i+urand(n), abp); |
246 |
< |
ec = SDevalBSDF(&sdv, vout, vin, &bsd); |
246 |
> |
ec = SDevalBSDF(&sdv, vin, vout, &bsd); |
247 |
|
if (ec != SDEnone) |
248 |
|
goto err; |
249 |
|
sum += sdv.cieY; |
275 |
|
} |
276 |
|
} |
277 |
|
/* front transmission */ |
278 |
< |
if (bsd.tf != NULL || bsd.tLamb.cieY > .002) { |
278 |
> |
if (bsd.tf != NULL || bsd.tLambFront.cieY > .002) { |
279 |
|
input_orient = 1; output_orient = -1; |
280 |
|
cfp[CIE_Y] = open_component_file(CIE_Y); |
281 |
|
if (bsd.tf != NULL && bsd.tf->comp[0].cspec[2].flags) { |
291 |
|
for (n = npsamps; n-- > 0; ) { |
292 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
293 |
|
fi_getvec(vin, i+urand(n), abp); |
294 |
< |
ec = SDevalBSDF(&sdv, vout, vin, &bsd); |
294 |
> |
ec = SDevalBSDF(&sdv, vin, vout, &bsd); |
295 |
|
if (ec != SDEnone) |
296 |
|
goto err; |
297 |
|
sum += sdv.cieY; |
340 |
|
for (n = npsamps; n-- > 0; ) { |
341 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
342 |
|
bi_getvec(vin, i+urand(n), abp); |
343 |
< |
ec = SDevalBSDF(&sdv, vout, vin, &bsd); |
343 |
> |
ec = SDevalBSDF(&sdv, vin, vout, &bsd); |
344 |
|
if (ec != SDEnone) |
345 |
|
goto err; |
346 |
|
sum += sdv.cieY; |
523 |
|
static int |
524 |
|
wrap_up(void) |
525 |
|
{ |
526 |
< |
char cmd[8192]; |
526 |
> |
char cmd[32700]; |
527 |
|
|
528 |
|
if (bsdf_manuf[0]) { |
529 |
|
add_wbsdf("-f", 1); |
574 |
|
} |
575 |
|
#endif |
576 |
|
|
577 |
< |
#define HEAD_BUFLEN 8192 |
577 |
> |
#define HEAD_BUFLEN 10240 |
578 |
|
static char head_buf[HEAD_BUFLEN]; |
579 |
|
static int cur_headlen = 0; |
580 |
|
|
590 |
|
strcpy(head_buf+cur_headlen, s); |
591 |
|
cur_headlen += len; |
592 |
|
|
593 |
+ |
#if defined(_WIN32) || defined(_WIN64) |
594 |
+ |
if (head_buf[cur_headlen-1] == '\n') |
595 |
+ |
head_buf[cur_headlen-1] = '\t'; |
596 |
+ |
#endif |
597 |
|
return(1); |
598 |
|
} |
599 |
|
|
616 |
|
main(int argc, char *argv[]) |
617 |
|
{ |
618 |
|
int dofwd = 0, dobwd = 1; |
619 |
< |
char buf[2048]; |
619 |
> |
char buf[1024]; |
620 |
|
char *cp; |
621 |
|
int i, na; |
622 |
< |
|
623 |
< |
progname = argv[0]; |
622 |
> |
/* set global progname */ |
623 |
> |
fixargv0(argv[0]); |
624 |
|
esupport |= E_VARIABLE|E_FUNCTION|E_RCONST; |
625 |
|
esupport &= ~(E_INCHAN|E_OUTCHAN); |
626 |
|
scompile("PI:3.14159265358979323846", NULL, 0); |
637 |
|
single_plane_incident = 0; |
638 |
|
break; |
639 |
|
case 'f': |
640 |
< |
if (!argv[i][2]) { |
640 |
> |
if ((argv[i][0] == '-') & !argv[i][2]) { |
641 |
|
if (strchr(argv[++i], '=') != NULL) { |
642 |
|
add_wbsdf("-f", 1); |
643 |
|
add_wbsdf(argv[i], 1); |
698 |
|
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n"); |
699 |
|
goto userr; |
700 |
|
} |
701 |
+ |
doptimize(1); /* optimize definitions */ |
702 |
|
++eclock; |
703 |
|
if (dofwd) { |
704 |
|
input_orient = -1; |
729 |
|
if (i < argc) { /* open input files if given */ |
730 |
|
int nbsdf = 0; |
731 |
|
for ( ; i < argc; i++) { /* interpolate each component */ |
729 |
– |
char pbuf[256]; |
732 |
|
FILE *fpin = fopen(argv[i], "rb"); |
733 |
|
if (fpin == NULL) { |
734 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
735 |
|
progname, argv[i]); |
736 |
|
return(1); |
737 |
|
} |
738 |
< |
sprintf(pbuf, "%s:\n", argv[i]); |
739 |
< |
record2header(pbuf); |
738 |
> |
sprintf(buf, "%s:\n", argv[i]); |
739 |
> |
record2header(buf); |
740 |
|
sir_headshare = &record2header; |
741 |
|
if (!load_bsdf_rep(fpin)) |
742 |
|
return(1); |
743 |
|
fclose(fpin); |
744 |
|
done_header(); |
745 |
< |
sprintf(pbuf, "Interpolating component '%s'", argv[i]); |
746 |
< |
prog_start(pbuf); |
745 |
> |
sprintf(buf, "Interpolating component '%s'", argv[i]); |
746 |
> |
prog_start(buf); |
747 |
|
eval_rbf(); |
748 |
|
} |
749 |
|
return(wrap_up()); |
750 |
|
} |
751 |
|
SET_FILE_BINARY(stdin); /* load from stdin */ |
752 |
+ |
record2header("<stdin>:\n"); |
753 |
+ |
sir_headshare = &record2header; |
754 |
|
if (!load_bsdf_rep(stdin)) |
755 |
|
return(1); |
756 |
+ |
done_header(); |
757 |
|
prog_start("Interpolating from standard input"); |
758 |
|
eval_rbf(); /* resample dist. */ |
759 |
|
return(wrap_up()); |