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 |
+ |
#define prog_done() if (do_prog) fputc('\n',stderr); else |
60 |
+ |
|
61 |
|
/* Output XML prologue to stdout */ |
62 |
|
static void |
63 |
|
xml_prologue(int ac, char *av[]) |
164 |
|
exit(1); |
165 |
|
} |
166 |
|
SET_FILE_BINARY(ofp); |
167 |
+ |
#ifdef getc_unlocked /* avoid lock/unlock overhead */ |
168 |
+ |
flockfile(ofp); |
169 |
+ |
#endif |
170 |
|
} else |
171 |
|
fputs("{\n", stdout); |
172 |
|
/* need to assign Dx, Dy, Dz? */ |
232 |
|
} |
233 |
|
if (rbf != NULL) |
234 |
|
free(rbf); |
235 |
+ |
prog_show((ix+1.)*(2./sqres)); |
236 |
|
} |
237 |
|
if (pctcull >= 0) { /* finish output */ |
238 |
|
if (pclose(ofp)) { |
246 |
|
fputs("}\n", stdout); |
247 |
|
} |
248 |
|
data_epilogue(); |
249 |
+ |
prog_done(); |
250 |
|
} |
251 |
|
|
252 |
|
/* Interpolate and output anisotropic BSDF data */ |
273 |
|
progname); |
274 |
|
exit(1); |
275 |
|
} |
276 |
+ |
SET_FILE_BINARY(ofp); |
277 |
+ |
#ifdef getc_unlocked /* avoid lock/unlock overhead */ |
278 |
+ |
flockfile(ofp); |
279 |
+ |
#endif |
280 |
|
} else |
281 |
|
fputs("{\n", stdout); |
282 |
|
/* need to assign Dx, Dy, Dz? */ |
344 |
|
} |
345 |
|
if (rbf != NULL) |
346 |
|
free(rbf); |
347 |
+ |
prog_show((ix*sqres+iy+1.)/(sqres*sqres)); |
348 |
|
} |
349 |
|
if (pctcull >= 0) { /* finish output */ |
350 |
|
if (pclose(ofp)) { |
355 |
|
} else |
356 |
|
fputs("}\n", stdout); |
357 |
|
data_epilogue(); |
358 |
+ |
prog_done(); |
359 |
|
} |
360 |
|
|
361 |
|
/* Read in BSDF and interpolate as tensor tree representation */ |
405 |
|
case 'l': |
406 |
|
lobe_lim = atoi(argv[++i]); |
407 |
|
break; |
408 |
+ |
case 'p': |
409 |
+ |
do_prog = atoi(argv[i]+2); |
410 |
+ |
break; |
411 |
|
default: |
412 |
|
goto userr; |
413 |
|
} |
418 |
|
fprintf(stderr, |
419 |
|
"%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n", |
420 |
|
progname); |
421 |
< |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n", |
379 |
< |
progname); |
421 |
> |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n"); |
422 |
|
goto userr; |
423 |
|
} |
424 |
|
++eclock; |
426 |
|
if (dofwd) { |
427 |
|
input_orient = -1; |
428 |
|
output_orient = -1; |
429 |
< |
(*evf)(argv[i]); /* outside reflectance */ |
429 |
> |
prog_start("Evaluating outside reflectance"); |
430 |
> |
(*evf)(argv[i]); |
431 |
|
output_orient = 1; |
432 |
< |
(*evf)(argv[i]); /* outside -> inside */ |
432 |
> |
prog_start("Evaluating outside->inside transmission"); |
433 |
> |
(*evf)(argv[i]); |
434 |
|
} |
435 |
|
if (dobwd) { |
436 |
|
input_orient = 1; |
437 |
|
output_orient = 1; |
438 |
< |
(*evf)(argv[i]); /* inside reflectance */ |
438 |
> |
prog_start("Evaluating inside reflectance"); |
439 |
> |
(*evf)(argv[i]); |
440 |
|
output_orient = -1; |
441 |
< |
(*evf)(argv[i]); /* inside -> outside */ |
441 |
> |
prog_start("Evaluating inside->outside transmission"); |
442 |
> |
(*evf)(argv[i]); |
443 |
|
} |
444 |
|
xml_epilogue(); /* finish XML output & exit */ |
445 |
|
return(0); |
447 |
|
if (i < argc) { /* open input files if given */ |
448 |
|
int nbsdf = 0; |
449 |
|
for ( ; i < argc; i++) { /* interpolate each component */ |
450 |
+ |
char pbuf[256]; |
451 |
|
FILE *fpin = fopen(argv[i], "rb"); |
452 |
|
if (fpin == NULL) { |
453 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
459 |
|
fclose(fpin); |
460 |
|
if (!nbsdf++) /* start XML on first dist. */ |
461 |
|
xml_prologue(argc, argv); |
462 |
+ |
sprintf(pbuf, "Interpolating component '%s'", argv[i]); |
463 |
+ |
prog_start(pbuf); |
464 |
|
if (single_plane_incident) |
465 |
|
eval_isotropic(NULL); |
466 |
|
else |
473 |
|
if (!load_bsdf_rep(stdin)) |
474 |
|
return(1); |
475 |
|
xml_prologue(argc, argv); /* start XML output */ |
476 |
+ |
prog_start("Interpolating from standard input"); |
477 |
|
if (single_plane_incident) /* resample dist. */ |
478 |
|
eval_isotropic(NULL); |
479 |
|
else |