21 |
|
|
22 |
|
typedef struct { |
23 |
|
const char *fname; /* input file path */ |
24 |
< |
double theta, phi; /* input angles */ |
24 |
> |
double theta, phi; /* input angles (degrees) */ |
25 |
> |
double up_phi; /* azimuth for "up" direction */ |
26 |
|
int igp[2]; /* input grid position */ |
27 |
|
int isDSF; /* data is DSF (rather than BSDF)? */ |
28 |
|
long dstart; /* data start offset in file */ |
61 |
|
} |
62 |
|
inpfile[i].fname = fname; |
63 |
|
inpfile[i].isDSF = -1; |
64 |
+ |
inpfile[i].up_phi = 0; |
65 |
|
inpfile[i].theta = inpfile[i].phi = -10001.; |
66 |
|
/* read header information */ |
67 |
|
while ((c = getc(fp)) == '#' || c == EOF) { |
79 |
|
inpfile[i].isDSF = 1; |
80 |
|
continue; |
81 |
|
} |
82 |
< |
if (!strcasecmp(typ, "BSDF")) { |
82 |
> |
if (!strcasecmp(typ, "BSDF") || |
83 |
> |
!strcasecmp(typ, "BRDF") || |
84 |
> |
!strcasecmp(typ, "BTDF")) { |
85 |
|
inpfile[i].isDSF = 0; |
86 |
|
continue; |
87 |
|
} |
88 |
|
} |
89 |
+ |
if (sscanf(buf, "upphi %lf", &inpfile[i].up_phi) == 1) |
90 |
+ |
continue; |
91 |
|
if (sscanf(buf, "intheta %lf", &inpfile[i].theta) == 1) |
92 |
|
continue; |
93 |
|
if (sscanf(buf, "inphi %lf", &inpfile[i].phi) == 1) |
108 |
|
fputs(": unknown incident angle\n", stderr); |
109 |
|
return(0); |
110 |
|
} |
111 |
+ |
/* convert to Y-up orientation */ |
112 |
+ |
inpfile[i].phi += 90.-inpfile[i].up_phi; |
113 |
|
/* convert angle to grid position */ |
114 |
|
dv[2] = sin(M_PI/180.*inpfile[i].theta); |
115 |
|
dv[0] = cos(M_PI/180.*inpfile[i].phi)*dv[2]; |
137 |
|
if (i) /* process previous incidence */ |
138 |
|
make_rbfrep(); |
139 |
|
#ifdef DEBUG |
140 |
< |
fprintf(stderr, "New incident (theta,phi)=(%f,%f)\n", |
140 |
> |
fprintf(stderr, "New incident (theta,phi)=(%.1f,%.1f)\n", |
141 |
|
inpfile[i].theta, inpfile[i].phi); |
142 |
|
#endif |
143 |
|
new_bsdf_data(inpfile[i].theta, inpfile[i].phi); |
147 |
|
#endif |
148 |
|
/* read scattering data */ |
149 |
|
while (fscanf(fp, "%lf %lf %lf\n", &theta_out, &phi_out, &val) == 3) |
150 |
< |
add_bsdf_data(theta_out, phi_out, val, inpfile[i].isDSF); |
150 |
> |
add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi, |
151 |
> |
val, inpfile[i].isDSF); |
152 |
|
n = 0; |
153 |
|
while ((c = getc(fp)) != EOF) |
154 |
|
n += !isspace(c); |
193 |
|
for (i = 0; i < ninpfiles; i++) |
194 |
|
if (!init_pabopto_inp(i, argv[i+1])) |
195 |
|
return(1); |
196 |
< |
qsort(inpfile, ninpfiles, sizeof(PGINPUT), &cmp_indir); |
196 |
> |
qsort(inpfile, ninpfiles, sizeof(PGINPUT), cmp_indir); |
197 |
|
/* compile measurements */ |
198 |
|
for (i = 0; i < ninpfiles; i++) |
199 |
|
if (!add_pabopto_inp(i)) |
245 |
|
if (dsf_grid[i][j].sum.n > 0) { |
246 |
|
ovec_from_pos(dir, i, j); |
247 |
|
bsdf = dsf_grid[i][j].sum.v / |
248 |
< |
(dsf_grid[i][j].sum.n*output_orient*dir[2]); |
248 |
> |
((double)dsf_grid[i][j].sum.n*output_orient*dir[2]); |
249 |
|
if (bsdf <= bsdf_min*.6) |
250 |
|
continue; |
251 |
|
bsdf = log(bsdf + 1e-5) - min_log; |
261 |
|
for (n = 0; n < dsf_list->nrbf; n++) { |
262 |
|
RBFVAL *rbf = &dsf_list->rbfa[n]; |
263 |
|
ovec_from_pos(dir, rbf->gx, rbf->gy); |
264 |
< |
bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]); |
264 |
> |
bsdf = eval_rbfrep(dsf_list, dir); |
265 |
|
bsdf = log(bsdf + 1e-5) - min_log; |
266 |
|
printf("red sphere p%04d\n0\n0\n", ++n); |
267 |
|
printf("4 %.6g %.6g %.6g %.6g\n\n", |
281 |
|
for (i = 0; i < GRIDRES; i++) |
282 |
|
for (j = 0; j < GRIDRES; j++) { |
283 |
|
ovec_from_pos(dir, i, j); |
284 |
< |
bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]); |
284 |
> |
bsdf = eval_rbfrep(dsf_list, dir); |
285 |
|
bsdf = log(bsdf + 1e-5) - min_log; |
286 |
|
fprintf(pfp, "%.8e %.8e %.8e\n", |
287 |
|
dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf); |