--- ray/src/cv/pabopto2bsdf.c 2014/03/20 16:54:23 2.20 +++ ray/src/cv/pabopto2bsdf.c 2014/03/24 02:31:02 2.24 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.20 2014/03/20 16:54:23 greg Exp $"; +static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.24 2014/03/24 02:31:02 greg Exp $"; #endif /* * Load measured BSDF data in PAB-Opto format. @@ -77,7 +77,9 @@ init_pabopto_inp(const int i, const char *fname) inpfile[i].isDSF = 1; continue; } - if (!strcasecmp(typ, "BSDF")) { + if (!strcasecmp(typ, "BSDF") || + !strcasecmp(typ, "BRDF") || + !strcasecmp(typ, "BTDF")) { inpfile[i].isDSF = 0; continue; } @@ -129,7 +131,7 @@ add_pabopto_inp(const int i) if (i) /* process previous incidence */ make_rbfrep(); #ifdef DEBUG - fprintf(stderr, "New incident (theta,phi)=(%f,%f)\n", + fprintf(stderr, "New incident (theta,phi)=(%.1f,%.1f)\n", inpfile[i].theta, inpfile[i].phi); #endif new_bsdf_data(inpfile[i].theta, inpfile[i].phi); @@ -210,8 +212,9 @@ main(int argc, char *argv[]) FVECT dir; int i, j, n; + progname = argv[0]; if (argc != 2) { - fprintf(stderr, "Usage: %s input.dat > output.rad\n", argv[0]); + fprintf(stderr, "Usage: %s input.dat > output.rad\n", progname); return(1); } ninpfiles = 1; @@ -219,7 +222,10 @@ main(int argc, char *argv[]) if (!init_pabopto_inp(0, argv[1]) || !add_pabopto_inp(0)) return(1); /* reduce data set */ - make_rbfrep(); + if (make_rbfrep() == NULL) { + fprintf(stderr, "%s: nothing to plot!\n", progname); + exit(1); + } #ifdef DEBUG fprintf(stderr, "Minimum BSDF = %.4f\n", bsdf_min); #endif @@ -232,7 +238,7 @@ main(int argc, char *argv[]) if (dsf_grid[i][j].sum.n > 0) { ovec_from_pos(dir, i, j); bsdf = dsf_grid[i][j].sum.v / - (dsf_grid[i][j].sum.n*output_orient*dir[2]); + ((double)dsf_grid[i][j].sum.n*output_orient*dir[2]); if (bsdf <= bsdf_min*.6) continue; bsdf = log(bsdf + 1e-5) - min_log; @@ -262,7 +268,7 @@ main(int argc, char *argv[]) sprintf(buf, "gensurf tgreen bsdf - - - %d %d", GRIDRES-1, GRIDRES-1); pfp = popen(buf, "w"); if (pfp == NULL) { - fprintf(stderr, "%s: cannot open '| %s'\n", argv[0], buf); + fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf); return(1); } for (i = 0; i < GRIDRES; i++)