ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/bsdf2ttree.c
(Generate patch)

Comparing ray/src/cv/bsdf2ttree.c (file contents):
Revision 2.25 by greg, Tue Mar 11 19:37:45 2014 UTC vs.
Revision 2.26 by greg, Wed Mar 12 21:15:31 2014 UTC

# Line 28 | Line 28 | const double           ssamp_thresh = 0.35;
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[])
# Line 203 | Line 232 | eval_isotropic(char *funame)
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)) {
# Line 216 | Line 246 | eval_isotropic(char *funame)
246                  fputs("}\n", stdout);
247          }
248          data_epilogue();
249 +        prog_done();
250   }
251  
252   /* Interpolate and output anisotropic BSDF data */
# Line 313 | Line 344 | eval_anisotropic(char *funame)
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)) {
# Line 323 | Line 355 | eval_anisotropic(char *funame)
355          } else
356                  fputs("}\n", stdout);
357          data_epilogue();
358 +        prog_done();
359   }
360  
361   /* Read in BSDF and interpolate as tensor tree representation */
# Line 372 | Line 405 | main(int argc, char *argv[])
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                  }
# Line 390 | Line 426 | main(int argc, char *argv[])
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);
# Line 407 | Line 447 | main(int argc, char *argv[])
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",
# Line 418 | Line 459 | main(int argc, char *argv[])
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
# Line 430 | Line 473 | main(int argc, char *argv[])
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines