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

Comparing ray/src/cv/pabopto2bsdf.c (file contents):
Revision 2.7 by greg, Mon Oct 21 18:33:15 2013 UTC vs.
Revision 2.16 by greg, Mon Mar 17 01:52:51 2014 UTC

# Line 14 | Line 14 | static const char RCSid[] = "$Id$";
14   #include <math.h>
15   #include "platform.h"
16   #include "bsdfrep.h"
17 + #include "resolu.h"
18                                  /* global argv[0] */
19   char                    *progname;
20  
# Line 70 | Line 71 | init_pabopto_inp(const int i, const char *fname)
71                          fclose(fp);
72                          return(0);
73                  }
74 +                if (sscanf(buf, "sample_name \"%[^\"]\"", bsdf_name) == 1)
75 +                        continue;
76                  if (sscanf(buf, "format: theta phi %s", typ) == 1) {
77                          if (!strcasecmp(typ, "DSF")) {
78                                  inpfile[i].isDSF = 1;
# Line 145 | Line 148 | add_pabopto_inp(const int i)
148          return(1);
149   }
150  
151 < #if 1
151 > #ifndef TEST_MAIN
152   /* Read in PAB-Opto BSDF files and output RBF interpolant */
153   int
154   main(int argc, char *argv[])
# Line 214 | Line 217 | main(int argc, char *argv[])
217                  return(1);
218                                                  /* reduce data set */
219          make_rbfrep();
220 <                                                /* produce spheres at meas. */
220 > #ifdef DEBUG
221 >        fprintf(stderr, "Minimum BSDF = %.4f\n", bsdf_min);
222 > #endif
223 >        min_log = log(bsdf_min*.5 + 1e-5);
224 > #if 1                                           /* produce spheres at meas. */
225          puts("void plastic yellow\n0\n0\n5 .6 .4 .01 .04 .08\n");
219        min_log = log(bsdf_min*.5);
226          n = 0;
227          for (i = 0; i < GRIDRES; i++)
228              for (j = 0; j < GRIDRES; j++)
229 <                if (dsf_grid[i][j].nval > 0) {
229 >                if (dsf_grid[i][j].sum.n > 0) {
230                          ovec_from_pos(dir, i, j);
231 <                        bsdf = dsf_grid[i][j].vsum/(dsf_grid[i][j].nval*dir[2]);
231 >                        bsdf = dsf_grid[i][j].sum.v /
232 >                                (dsf_grid[i][j].sum.n*output_orient*dir[2]);
233                          if (bsdf <= bsdf_min*.6)
234                                  continue;
235 <                        bsdf = log(bsdf) - min_log;
235 >                        bsdf = log(bsdf + 1e-5) - min_log;
236                          ovec_from_pos(dir, i, j);
237                          printf("yellow sphere s%04d\n0\n0\n", ++n);
238                          printf("4 %.6g %.6g %.6g %.6g\n\n",
239                                          dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf,
240                                          .007*bsdf);
241                  }
242 <                                                /* output continuous surface */
242 > #endif
243 > #if 1                                           /* spheres at RBF peaks */
244 >        puts("void plastic red\n0\n0\n5 .8 .01 .01 .04 .08\n");
245 >        for (n = 0; n < dsf_list->nrbf; n++) {
246 >                RBFVAL  *rbf = &dsf_list->rbfa[n];
247 >                ovec_from_pos(dir, rbf->gx, rbf->gy);
248 >                bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]);
249 >                bsdf = log(bsdf + 1e-5) - min_log;
250 >                printf("red sphere p%04d\n0\n0\n", ++n);
251 >                printf("4 %.6g %.6g %.6g %.6g\n\n",
252 >                                dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf,
253 >                                .011*bsdf);
254 >        }
255 > #endif
256 > #if 1                                           /* output continuous surface */
257          puts("void trans tgreen\n0\n0\n7 .7 1 .7 .04 .04 .9 1\n");
258          fflush(stdout);
259          sprintf(buf, "gensurf tgreen bsdf - - - %d %d", GRIDRES-1, GRIDRES-1);
260          pfp = popen(buf, "w");
261          if (pfp == NULL) {
262 <                fputs(buf, stderr);
242 <                fputs(": cannot start command\n", stderr);
262 >                fprintf(stderr, "%s: cannot open '| %s'\n", argv[0], buf);
263                  return(1);
264          }
265          for (i = 0; i < GRIDRES; i++)
266              for (j = 0; j < GRIDRES; j++) {
267                  ovec_from_pos(dir, i, j);
268 <                bsdf = eval_rbfrep(dsf_list, dir) / dir[2];
269 <                bsdf = log(bsdf) - min_log;
268 >                bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]);
269 >                bsdf = log(bsdf + 1e-5) - min_log;
270                  fprintf(pfp, "%.8e %.8e %.8e\n",
271                                  dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf);
272              }
273 <        return(pclose(pfp)==0 ? 0 : 1);
273 >        if (pclose(pfp) != 0)
274 >                return(1);
275 > #endif
276 >        return(0);
277   }
278   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines