17 |
|
#include "calcomp.h" |
18 |
|
#include "bsdfrep.h" |
19 |
|
#include "bsdf_m.h" |
20 |
+ |
/* assumed maximum # Klems patches */ |
21 |
+ |
#define MAXPATCHES 145 |
22 |
|
/* global argv[0] */ |
23 |
|
char *progname; |
24 |
|
/* selected basis function name */ |
174 |
|
sum = 0; /* average over patches */ |
175 |
|
for (n = npsamps; n-- > 0; ) { |
176 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
177 |
< |
fi_getvec(vin, i+(n+frandom())/npsamps, abp); |
177 |
> |
fi_getvec(vin, i+urand(n), abp); |
178 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
179 |
|
if (ec != SDEnone) |
180 |
|
goto err; |
195 |
|
sum = 0; /* average over patches */ |
196 |
|
for (n = npsamps; n-- > 0; ) { |
197 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
198 |
< |
bi_getvec(vin, i+(n+frandom())/npsamps, abp); |
198 |
> |
bi_getvec(vin, i+urand(n), abp); |
199 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
200 |
|
if (ec != SDEnone) |
201 |
|
goto err; |
216 |
|
sum = 0; /* average over patches */ |
217 |
|
for (n = npsamps; n-- > 0; ) { |
218 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
219 |
< |
fi_getvec(vin, i+(n+frandom())/npsamps, abp); |
219 |
> |
fi_getvec(vin, i+urand(n), abp); |
220 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
221 |
|
if (ec != SDEnone) |
222 |
|
goto err; |
229 |
|
data_epilogue(); |
230 |
|
} |
231 |
|
/* back transmission */ |
232 |
< |
if (bsd.tb != NULL) { |
232 |
> |
if ((bsd.tb != NULL) | (bsd.tf != NULL)) { |
233 |
|
input_orient = -1; output_orient = 1; |
234 |
|
data_prologue(); |
235 |
|
for (j = 0; j < abp->nangles; j++) { |
236 |
|
for (i = 0; i < abp->nangles; i++) { |
237 |
< |
sum = 0; /* average over patches */ |
237 |
> |
sum = 0; /* average over patches */ |
238 |
|
for (n = npsamps; n-- > 0; ) { |
239 |
|
fo_getvec(vout, j+(n+frandom())/npsamps, abp); |
240 |
< |
bi_getvec(vin, i+(n+frandom())/npsamps, abp); |
240 |
> |
bi_getvec(vin, i+urand(n), abp); |
241 |
|
ec = SDevalBSDF(&sv, vout, vin, &bsd); |
242 |
|
if (ec != SDEnone) |
243 |
|
goto err; |
261 |
|
eval_function(char *funame) |
262 |
|
{ |
263 |
|
ANGLE_BASIS *abp = get_basis(kbasis); |
264 |
+ |
int assignD = (fundefined(funame) < 6); |
265 |
|
double iovec[6]; |
266 |
|
double sum; |
267 |
|
int i, j, n; |
268 |
|
|
269 |
+ |
initurand(npsamps); |
270 |
|
data_prologue(); /* begin output */ |
271 |
|
for (j = 0; j < abp->nangles; j++) { /* run through directions */ |
272 |
|
for (i = 0; i < abp->nangles; i++) { |
278 |
|
bo_getvec(iovec+3, j+(n+frandom())/npsamps, abp); |
279 |
|
|
280 |
|
if (input_orient > 0) |
281 |
< |
fi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
281 |
> |
fi_getvec(iovec, i+urand(n), abp); |
282 |
|
else |
283 |
< |
bi_getvec(iovec, i+(n+frandom())/npsamps, abp); |
283 |
> |
bi_getvec(iovec, i+urand(n), abp); |
284 |
|
|
285 |
+ |
if (assignD) { |
286 |
+ |
varset("Dx", '=', -iovec[3]); |
287 |
+ |
varset("Dy", '=', -iovec[4]); |
288 |
+ |
varset("Dz", '=', -iovec[5]); |
289 |
+ |
++eclock; |
290 |
+ |
} |
291 |
|
sum += funvalue(funame, 6, iovec); |
292 |
|
} |
293 |
|
printf("\t%.3e\n", sum/npsamps); |
301 |
|
static void |
302 |
|
eval_rbf(void) |
303 |
|
{ |
294 |
– |
#define MAXPATCHES 145 |
304 |
|
ANGLE_BASIS *abp = get_basis(kbasis); |
305 |
|
float bsdfarr[MAXPATCHES*MAXPATCHES]; |
306 |
|
FVECT vin, vout; |
333 |
|
} |
334 |
|
bsdfarr[j*abp->nangles + i] = sum*output_orient/npsamps; |
335 |
|
} |
336 |
+ |
if (rbf != NULL) |
337 |
+ |
free(rbf); |
338 |
|
} |
339 |
|
n = 0; /* write out our matrix */ |
340 |
|
for (j = 0; j < abp->nangles; j++) { |
343 |
|
putchar('\n'); |
344 |
|
} |
345 |
|
data_epilogue(); /* finish output */ |
335 |
– |
#undef MAXPATCHES |
346 |
|
} |
347 |
|
|
348 |
|
/* Read in BSDF and interpolate as Klems matrix representation */ |
393 |
|
fprintf(stderr, |
394 |
|
"%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n", |
395 |
|
progname); |
396 |
+ |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n", |
397 |
+ |
progname); |
398 |
|
goto userr; |
399 |
|
} |
400 |
+ |
++eclock; |
401 |
|
xml_header(argc, argv); /* start XML output */ |
402 |
|
xml_prologue(NULL); |
403 |
|
if (dofwd) { |