| 27 |
|
static int npsamps = 256; |
| 28 |
|
/* limit on number of RBF lobes */ |
| 29 |
|
static int lobe_lim = 15000; |
| 30 |
+ |
/* progress bar length */ |
| 31 |
+ |
static int do_prog = 79; |
| 32 |
|
|
| 33 |
+ |
|
| 34 |
+ |
/* Start new progress bar */ |
| 35 |
+ |
#define prog_start(s) if (do_prog) fprintf(stderr, "%s: %s...\n", progname, s); else |
| 36 |
+ |
|
| 37 |
+ |
/* Draw progress bar of the appropriate length */ |
| 38 |
+ |
static void |
| 39 |
+ |
prog_show(double frac) |
| 40 |
+ |
{ |
| 41 |
+ |
char pbar[256]; |
| 42 |
+ |
int nchars; |
| 43 |
+ |
|
| 44 |
+ |
if (do_prog <= 1) return; |
| 45 |
+ |
if (do_prog > sizeof(pbar)-2) |
| 46 |
+ |
do_prog = sizeof(pbar)-2; |
| 47 |
+ |
if (frac < 0) frac = 0; |
| 48 |
+ |
else if (frac > 1) frac = 1; |
| 49 |
+ |
nchars = do_prog*frac + .5; |
| 50 |
+ |
pbar[0] = '\r'; |
| 51 |
+ |
memset(pbar+1, '*', nchars); |
| 52 |
+ |
memset(pbar+1+nchars, '-', do_prog-nchars); |
| 53 |
+ |
pbar[do_prog+1] = '\0'; |
| 54 |
+ |
fputs(pbar, stderr); |
| 55 |
+ |
} |
| 56 |
+ |
|
| 57 |
+ |
/* Finish progress bar */ |
| 58 |
+ |
static void |
| 59 |
+ |
prog_done(void) |
| 60 |
+ |
{ |
| 61 |
+ |
int n = do_prog; |
| 62 |
+ |
|
| 63 |
+ |
if (n <= 1) return; |
| 64 |
+ |
fputc('\r', stderr); |
| 65 |
+ |
while (n--) |
| 66 |
+ |
fputc(' ', stderr); |
| 67 |
+ |
fputc('\r', stderr); |
| 68 |
+ |
} |
| 69 |
+ |
|
| 70 |
|
/* Return angle basis corresponding to the given name */ |
| 71 |
< |
ANGLE_BASIS * |
| 71 |
> |
static ANGLE_BASIS * |
| 72 |
|
get_basis(const char *bn) |
| 73 |
|
{ |
| 74 |
|
int n = nabases; |
| 336 |
|
printf("\t%.3e\n", sum/npsamps); |
| 337 |
|
} |
| 338 |
|
putchar('\n'); |
| 339 |
+ |
prog_show((j+1.)/abp->nangles); |
| 340 |
|
} |
| 341 |
|
data_epilogue(); /* finish output */ |
| 342 |
+ |
prog_done(); |
| 343 |
|
} |
| 344 |
|
|
| 345 |
|
/* Interpolate and output a radial basis function BSDF representation */ |
| 374 |
|
else |
| 375 |
|
bo_getvec(vout, j+(n+frandom())/npsamps, abp); |
| 376 |
|
|
| 377 |
< |
sum += eval_rbfrep(rbf, vout) / vout[2]; |
| 377 |
> |
sum += eval_rbfrep(rbf, vout); |
| 378 |
|
} |
| 379 |
< |
bsdfarr[j*abp->nangles + i] = sum*output_orient/npsamps; |
| 379 |
> |
fo_getvec(vout, j+.5, abp); /* use centered secant */ |
| 380 |
> |
bsdfarr[j*abp->nangles + i] = sum / (npsamps*vout[2]); |
| 381 |
|
} |
| 382 |
|
if (rbf != NULL) |
| 383 |
|
free(rbf); |
| 384 |
+ |
prog_show((i+1.)/abp->nangles); |
| 385 |
|
} |
| 386 |
|
n = 0; /* write out our matrix */ |
| 387 |
|
for (j = 0; j < abp->nangles; j++) { |
| 390 |
|
putchar('\n'); |
| 391 |
|
} |
| 392 |
|
data_epilogue(); /* finish output */ |
| 393 |
+ |
prog_done(); |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
/* Read in BSDF and interpolate as Klems matrix representation */ |
| 436 |
|
case 'l': |
| 437 |
|
lobe_lim = atoi(argv[++i]); |
| 438 |
|
break; |
| 439 |
+ |
case 'p': |
| 440 |
+ |
do_prog = atoi(argv[i]+2); |
| 441 |
+ |
break; |
| 442 |
|
default: |
| 443 |
|
goto userr; |
| 444 |
|
} |
| 447 |
|
fprintf(stderr, |
| 448 |
|
"%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n", |
| 449 |
|
progname); |
| 450 |
< |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n", |
| 404 |
< |
progname); |
| 450 |
> |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n"); |
| 451 |
|
goto userr; |
| 452 |
|
} |
| 453 |
|
++eclock; |
| 456 |
|
if (dofwd) { |
| 457 |
|
input_orient = -1; |
| 458 |
|
output_orient = -1; |
| 459 |
< |
eval_function(argv[i]); /* outside reflectance */ |
| 459 |
> |
prog_start("Evaluating outside reflectance"); |
| 460 |
> |
eval_function(argv[i]); |
| 461 |
|
output_orient = 1; |
| 462 |
< |
eval_function(argv[i]); /* outside -> inside */ |
| 462 |
> |
prog_start("Evaluating outside->inside transmission"); |
| 463 |
> |
eval_function(argv[i]); |
| 464 |
|
} |
| 465 |
|
if (dobwd) { |
| 466 |
|
input_orient = 1; |
| 467 |
|
output_orient = 1; |
| 468 |
< |
eval_function(argv[i]); /* inside reflectance */ |
| 468 |
> |
prog_start("Evaluating inside reflectance"); |
| 469 |
> |
eval_function(argv[i]); |
| 470 |
|
output_orient = -1; |
| 471 |
< |
eval_function(argv[i]); /* inside -> outside */ |
| 471 |
> |
prog_start("Evaluating inside->outside transmission"); |
| 472 |
> |
eval_function(argv[i]); |
| 473 |
|
} |
| 474 |
|
xml_epilogue(); /* finish XML output & exit */ |
| 475 |
|
return(0); |
| 485 |
|
if (i < argc) { /* open input files if given */ |
| 486 |
|
int nbsdf = 0; |
| 487 |
|
for ( ; i < argc; i++) { /* interpolate each component */ |
| 488 |
+ |
char pbuf[256]; |
| 489 |
|
FILE *fpin = fopen(argv[i], "rb"); |
| 490 |
|
if (fpin == NULL) { |
| 491 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
| 499 |
|
xml_header(argc, argv); |
| 500 |
|
xml_prologue(NULL); |
| 501 |
|
} |
| 502 |
+ |
sprintf(pbuf, "Interpolating component '%s'", argv[i]); |
| 503 |
+ |
prog_start(pbuf); |
| 504 |
|
eval_rbf(); |
| 505 |
|
} |
| 506 |
|
xml_epilogue(); /* finish XML output & exit */ |
| 511 |
|
return(1); |
| 512 |
|
xml_header(argc, argv); /* start XML output */ |
| 513 |
|
xml_prologue(NULL); |
| 514 |
+ |
prog_start("Interpolating from standard input"); |
| 515 |
|
eval_rbf(); /* resample dist. */ |
| 516 |
|
xml_epilogue(); /* finish XML output & exit */ |
| 517 |
|
return(0); |