3 |
|
#endif |
4 |
|
/* |
5 |
|
* Load measured BSDF data in PAB-Opto format. |
6 |
+ |
* Assumes that surface-normal (Z-axis) faces into room unless -t option given. |
7 |
|
* |
8 |
|
* G. Ward |
9 |
|
*/ |
33 |
|
PGINPUT *inpfile; /* input files sorted by incidence */ |
34 |
|
int ninpfiles; /* number of input files */ |
35 |
|
|
36 |
+ |
int rev_orient = 0; /* shall we reverse surface orientation? */ |
37 |
+ |
|
38 |
|
/* Compare incident angles */ |
39 |
|
static int |
40 |
|
cmp_indir(const void *p1, const void *p2) |
117 |
|
fputs(": unknown incident angle\n", stderr); |
118 |
|
return(0); |
119 |
|
} |
120 |
+ |
if (rev_orient) { /* reverse Z-axis to face outside */ |
121 |
+ |
inpfile[i].theta = 180. - inpfile[i].theta; |
122 |
+ |
inpfile[i].phi = 360. - inpfile[i].phi; |
123 |
+ |
} |
124 |
|
/* convert to Y-up orientation */ |
125 |
|
inpfile[i].phi += 90.-inpfile[i].up_phi; |
126 |
|
/* convert angle to grid position */ |
169 |
|
fclose(fp); |
170 |
|
return(1); |
171 |
|
} |
172 |
+ |
if (rev_orient) { /* reverse Z-axis to face outside */ |
173 |
+ |
theta_out = 180. - theta_out; |
174 |
+ |
phi_out = 360. - phi_out; |
175 |
+ |
} |
176 |
|
add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi, |
177 |
|
val, inpfile[i].isDSF); |
178 |
|
} |
202 |
|
progname = argv[0]; /* get options */ |
203 |
|
while (argc > 2 && argv[1][0] == '-') { |
204 |
|
switch (argv[1][1]) { |
205 |
+ |
case 't': |
206 |
+ |
rev_orient = !rev_orient; |
207 |
+ |
break; |
208 |
|
case 'n': |
209 |
|
nprocs = atoi(argv[2]); |
210 |
+ |
argv++; argc--; |
211 |
|
break; |
212 |
|
default: |
213 |
|
goto userr; |
214 |
|
} |
215 |
< |
argv += 2; argc -= 2; |
215 |
> |
argv++; argc--; |
216 |
|
} |
217 |
|
/* initialize & sort inputs */ |
218 |
|
ninpfiles = argc - 1; |
234 |
|
save_bsdf_rep(stdout); /* write it out */ |
235 |
|
return(0); |
236 |
|
userr: |
237 |
< |
fprintf(stderr, "Usage: %s [-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n", |
237 |
> |
fprintf(stderr, "Usage: %s [-t][-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n", |
238 |
|
progname); |
239 |
|
return(1); |
240 |
|
} |