| 28 |
|
char validf[] = "-e 'valid(s,t)=X`SYS(s,t)^2+Y`SYS(s,t)^2+Z`SYS(s,t)^2-1e-7'"; |
| 29 |
|
#endif |
| 30 |
|
|
| 31 |
– |
char *progname; |
| 32 |
– |
|
| 31 |
|
/* Produce a Radiance model plotting the indicated incident direction(s) */ |
| 32 |
|
int |
| 33 |
|
main(int argc, char *argv[]) |
| 43 |
|
FVECT idir, odir; |
| 44 |
|
int i, j, n; |
| 45 |
|
/* check arguments */ |
| 46 |
< |
progname = argv[0]; |
| 46 |
> |
fixargv0(argv[0]); |
| 47 |
|
if (argc > 1 && !strcmp(argv[1], "-p")) { |
| 48 |
|
++showPeaks; |
| 49 |
|
++argv; --argc; |
| 73 |
|
bsdf_min = myBSDF.rLambFront.cieY/M_PI; |
| 74 |
|
if (myBSDF.rb != NULL && myBSDF.rLambBack.cieY < bsdf_min*M_PI) |
| 75 |
|
bsdf_min = myBSDF.rLambBack.cieY/M_PI; |
| 76 |
< |
if ((myBSDF.tf != NULL) | (myBSDF.tb != NULL) && |
| 77 |
< |
myBSDF.tLamb.cieY < bsdf_min*M_PI) |
| 78 |
< |
bsdf_min = myBSDF.tLamb.cieY/M_PI; |
| 76 |
> |
if (myBSDF.tf != NULL && myBSDF.tLambFront.cieY < bsdf_min*M_PI) |
| 77 |
> |
bsdf_min = myBSDF.tLambFront.cieY/M_PI; |
| 78 |
> |
if (myBSDF.tb != NULL && myBSDF.tLambBack.cieY < bsdf_min*M_PI) |
| 79 |
> |
bsdf_min = myBSDF.tLambBack.cieY/M_PI; |
| 80 |
|
if (doTrans && (myBSDF.tf == NULL) & (myBSDF.tb == NULL)) { |
| 81 |
|
fprintf(stderr, "%s: no transmitted component in '%s'\n", |
| 82 |
|
progname, argv[1]); |
| 94 |
|
fclose(fp); |
| 95 |
|
} |
| 96 |
|
#ifdef DEBUG |
| 97 |
< |
fprintf(stderr, "Minimum BSDF set to %.4f\n", bsdf_min); |
| 97 |
> |
fprintf(stderr, "Minimum BSDF set to %.4g\n", bsdf_min); |
| 98 |
|
#endif |
| 99 |
< |
min_log = log(bsdf_min*.5 + 1e-5); |
| 99 |
> |
min_log = log(bsdf_min*.5 + 1e-6); |
| 100 |
|
/* output BSDF rep. */ |
| 101 |
|
for (n = 0; (n < 6) & (2*n+3 < argc); n++) { |
| 102 |
|
double theta = (M_PI/180.)*atof(argv[2*n+2]); |
| 115 |
|
idir[1] = idir[2] * sin(phi); |
| 116 |
|
idir[2] = input_orient * sqrt(1. - idir[2]*idir[2]); |
| 117 |
|
#ifdef DEBUG |
| 118 |
< |
fprintf(stderr, "Computing BSDF for incident direction (%.1f,%.1f)\n", |
| 118 |
> |
fprintf(stderr, "Computing BSDF for incident direction (%.2f,%.2f)\n", |
| 119 |
|
get_theta180(idir), get_phi360(idir)); |
| 120 |
|
#endif |
| 121 |
|
if (!inpXML) |
| 122 |
|
rbf = advect_rbf(idir, 15000); |
| 123 |
|
#ifdef DEBUG |
| 124 |
|
if (inpXML) |
| 125 |
< |
fprintf(stderr, "Hemispherical %s: %.3f\n", |
| 125 |
> |
fprintf(stderr, "Hemispherical %s: %.4f\n", |
| 126 |
|
(output_orient > 0 ^ input_orient > 0 ? |
| 127 |
|
"transmission" : "reflection"), |
| 128 |
|
SDdirectHemi(idir, SDsampSp|SDsampDf | |
| 131 |
|
else if (rbf == NULL) |
| 132 |
|
fputs("Empty RBF\n", stderr); |
| 133 |
|
else |
| 134 |
< |
fprintf(stderr, "Hemispherical %s: %.3f\n", |
| 134 |
> |
fprintf(stderr, "Hemispherical %s: %.4f\n", |
| 135 |
|
(output_orient > 0 ^ input_orient > 0 ? |
| 136 |
|
"transmission" : "reflection"), |
| 137 |
|
rbf->vtotal); |
| 154 |
|
} |
| 155 |
|
fflush(stdout); |
| 156 |
|
sprintf(buf, "gensurf tmat bsdf%d - - - %d %d %s", n+1, |
| 157 |
< |
GRIDRES-1, GRIDRES-1, validf); |
| 157 |
> |
grid_res-1, grid_res-1, validf); |
| 158 |
|
fp = popen(buf, "w"); |
| 159 |
|
if (fp == NULL) { |
| 160 |
|
fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf); |
| 161 |
|
return(1); |
| 162 |
|
} |
| 163 |
< |
for (i = 0; i < GRIDRES; i++) |
| 164 |
< |
for (j = 0; j < GRIDRES; j++) { |
| 163 |
> |
for (i = 0; i < grid_res; i++) |
| 164 |
> |
for (j = 0; j < grid_res; j++) { |
| 165 |
|
ovec_from_pos(odir, i, j); |
| 166 |
|
if (inpXML) { |
| 167 |
|
SDValue sval; |
| 168 |
< |
if (SDreportError(SDevalBSDF(&sval, odir, |
| 169 |
< |
idir, &myBSDF), stderr)) |
| 168 |
> |
if (SDreportError(SDevalBSDF(&sval, idir, |
| 169 |
> |
odir, &myBSDF), stderr)) |
| 170 |
|
return(1); |
| 171 |
|
bsdf = sval.cieY; |
| 172 |
|
} else |
| 173 |
|
bsdf = eval_rbfrep(rbf, odir); |
| 174 |
< |
bsdf = log(bsdf + 1e-5) - min_log; |
| 174 |
> |
bsdf = log(bsdf + 1e-6) - min_log; |
| 175 |
|
fprintf(fp, "%.8e %.8e %.8e\n", |
| 176 |
|
odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf); |
| 177 |
|
} |