| 28 |
|
const int nssamp = 100; |
| 29 |
|
/* limit on number of RBF lobes */ |
| 30 |
|
static int lobe_lim = 15000; |
| 31 |
+ |
/* progress bar length */ |
| 32 |
+ |
static int do_prog = 79; |
| 33 |
|
|
| 34 |
+ |
|
| 35 |
+ |
/* Start new progress bar */ |
| 36 |
+ |
#define prog_start(s) if (do_prog) fprintf(stderr, "%s: %s...\n", progname, s); else |
| 37 |
+ |
|
| 38 |
+ |
/* Draw progress bar of the appropriate length */ |
| 39 |
+ |
static void |
| 40 |
+ |
prog_show(double frac) |
| 41 |
+ |
{ |
| 42 |
+ |
char pbar[256]; |
| 43 |
+ |
int nchars; |
| 44 |
+ |
|
| 45 |
+ |
if (do_prog <= 0) return; |
| 46 |
+ |
if (do_prog > sizeof(pbar)-2) |
| 47 |
+ |
do_prog = sizeof(pbar)-2; |
| 48 |
+ |
if (frac < 0) frac = 0; |
| 49 |
+ |
else if (frac > 1) frac = 1; |
| 50 |
+ |
nchars = do_prog*frac + .5; |
| 51 |
+ |
pbar[0] = '\r'; |
| 52 |
+ |
memset(pbar+1, '*', nchars); |
| 53 |
+ |
memset(pbar+1+nchars, '-', do_prog-nchars); |
| 54 |
+ |
pbar[do_prog+1] = '\0'; |
| 55 |
+ |
fputs(pbar, stderr); |
| 56 |
+ |
} |
| 57 |
+ |
|
| 58 |
+ |
/* Finish progress bar */ |
| 59 |
+ |
static void |
| 60 |
+ |
prog_done(void) |
| 61 |
+ |
{ |
| 62 |
+ |
int n = do_prog; |
| 63 |
+ |
|
| 64 |
+ |
if (n <= 1) return; |
| 65 |
+ |
fputc('\r', stderr); |
| 66 |
+ |
while (n--) |
| 67 |
+ |
fputc(' ', stderr); |
| 68 |
+ |
fputc('\r', stderr); |
| 69 |
+ |
} |
| 70 |
+ |
|
| 71 |
|
/* Output XML prologue to stdout */ |
| 72 |
|
static void |
| 73 |
|
xml_prologue(int ac, char *av[]) |
| 242 |
|
} |
| 243 |
|
if (rbf != NULL) |
| 244 |
|
free(rbf); |
| 245 |
+ |
prog_show((ix+1.)*(2./sqres)); |
| 246 |
|
} |
| 247 |
|
if (pctcull >= 0) { /* finish output */ |
| 248 |
|
if (pclose(ofp)) { |
| 256 |
|
fputs("}\n", stdout); |
| 257 |
|
} |
| 258 |
|
data_epilogue(); |
| 259 |
+ |
prog_done(); |
| 260 |
|
} |
| 261 |
|
|
| 262 |
|
/* Interpolate and output anisotropic BSDF data */ |
| 354 |
|
} |
| 355 |
|
if (rbf != NULL) |
| 356 |
|
free(rbf); |
| 357 |
+ |
prog_show((ix*sqres+iy+1.)/(sqres*sqres)); |
| 358 |
|
} |
| 359 |
|
if (pctcull >= 0) { /* finish output */ |
| 360 |
|
if (pclose(ofp)) { |
| 365 |
|
} else |
| 366 |
|
fputs("}\n", stdout); |
| 367 |
|
data_epilogue(); |
| 368 |
+ |
prog_done(); |
| 369 |
|
} |
| 370 |
|
|
| 371 |
|
/* Read in BSDF and interpolate as tensor tree representation */ |
| 415 |
|
case 'l': |
| 416 |
|
lobe_lim = atoi(argv[++i]); |
| 417 |
|
break; |
| 418 |
+ |
case 'p': |
| 419 |
+ |
do_prog = atoi(argv[i]+2); |
| 420 |
+ |
break; |
| 421 |
|
default: |
| 422 |
|
goto userr; |
| 423 |
|
} |
| 436 |
|
if (dofwd) { |
| 437 |
|
input_orient = -1; |
| 438 |
|
output_orient = -1; |
| 439 |
< |
(*evf)(argv[i]); /* outside reflectance */ |
| 439 |
> |
prog_start("Evaluating outside reflectance"); |
| 440 |
> |
(*evf)(argv[i]); |
| 441 |
|
output_orient = 1; |
| 442 |
< |
(*evf)(argv[i]); /* outside -> inside */ |
| 442 |
> |
prog_start("Evaluating outside->inside transmission"); |
| 443 |
> |
(*evf)(argv[i]); |
| 444 |
|
} |
| 445 |
|
if (dobwd) { |
| 446 |
|
input_orient = 1; |
| 447 |
|
output_orient = 1; |
| 448 |
< |
(*evf)(argv[i]); /* inside reflectance */ |
| 448 |
> |
prog_start("Evaluating inside reflectance"); |
| 449 |
> |
(*evf)(argv[i]); |
| 450 |
|
output_orient = -1; |
| 451 |
< |
(*evf)(argv[i]); /* inside -> outside */ |
| 451 |
> |
prog_start("Evaluating inside->outside transmission"); |
| 452 |
> |
(*evf)(argv[i]); |
| 453 |
|
} |
| 454 |
|
xml_epilogue(); /* finish XML output & exit */ |
| 455 |
|
return(0); |
| 457 |
|
if (i < argc) { /* open input files if given */ |
| 458 |
|
int nbsdf = 0; |
| 459 |
|
for ( ; i < argc; i++) { /* interpolate each component */ |
| 460 |
+ |
char pbuf[256]; |
| 461 |
|
FILE *fpin = fopen(argv[i], "rb"); |
| 462 |
|
if (fpin == NULL) { |
| 463 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
| 469 |
|
fclose(fpin); |
| 470 |
|
if (!nbsdf++) /* start XML on first dist. */ |
| 471 |
|
xml_prologue(argc, argv); |
| 472 |
+ |
sprintf(pbuf, "Interpolating component '%s'", argv[i]); |
| 473 |
+ |
prog_start(pbuf); |
| 474 |
|
if (single_plane_incident) |
| 475 |
|
eval_isotropic(NULL); |
| 476 |
|
else |
| 483 |
|
if (!load_bsdf_rep(stdin)) |
| 484 |
|
return(1); |
| 485 |
|
xml_prologue(argc, argv); /* start XML output */ |
| 486 |
+ |
prog_start("Interpolating from standard input"); |
| 487 |
|
if (single_plane_incident) /* resample dist. */ |
| 488 |
|
eval_isotropic(NULL); |
| 489 |
|
else |