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.34 by greg, Tue Feb 2 22:34:00 2016 UTC vs.
Revision 2.40 by greg, Fri Feb 17 22:31:49 2017 UTC

# Line 27 | Line 27 | static int             samp_order = 6;
27   const double            ssamp_thresh = 0.35;
28                                  /* number of super-samples */
29   #ifndef NSSAMP
30 < #define NSSAMP          100
30 > #define NSSAMP          64
31   #endif
32                                  /* limit on number of RBF lobes */
33   static int              lobe_lim = 15000;
# Line 38 | Line 38 | static int             do_prog = 79;
38   static char             *wrapBSDF[MAXCARG] = {"wrapBSDF", "-U"};
39   static int              wbsdfac = 2;
40  
41 < /* Add argument to wrapBSDF, allocating space if isstatic */
41 > /* Add argument to wrapBSDF, allocating space if !isstatic */
42   static void
43   add_wbsdf(const char *arg, int isstatic)
44   {
# Line 185 | Line 185 | eval_isotropic(char *funame)
185                          fputs("{\n", uvfp[1]);
186                  }
187          }
188 <                                                /* need to assign Dx, Dy, Dz? */
189 <        if (funame != NULL)
188 >        if (funame != NULL)                     /* need to assign Dx, Dy, Dz? */
189                  assignD = (fundefined(funame) < 6);
190                                                  /* run through directions */
191          for (ix = 0; ix < sqres/2; ix++) {
# Line 207 | Line 206 | eval_isotropic(char *funame)
206                              eval_rbfcol(&sdv, rbf, iovec+3);
207                              bsdf = sdv.cieY;
208                              if (rbf_colorimetry == RBCtristimulus) {
210                                c_ccvt(&sdv.spec, C_CSXY);
209                                  uv[0] = uv[1] = 1. /
210                                      (-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.);
211                                  uv[0] *= 4.*sdv.spec.cx;
# Line 251 | Line 249 | eval_isotropic(char *funame)
249   #endif
250                          }
251                          if (pctcull >= 0)
252 <                                fwrite(&bsdf, sizeof(bsdf), 1, ofp);
252 >                                putbinary(&bsdf, sizeof(bsdf), 1, ofp);
253                          else
254                                  fprintf(ofp, "\t%.3e\n", bsdf);
255  
256                          if (rbf_colorimetry == RBCtristimulus) {
257                                  if (pctcull >= 0) {
258 <                                        fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]);
259 <                                        fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]);
258 >                                        putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]);
259 >                                        putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]);
260                                  } else {
261                                          fprintf(uvfp[0], "\t%.3e\n", uv[0]);
262                                          fprintf(uvfp[1], "\t%.3e\n", uv[1]);
# Line 271 | Line 269 | eval_isotropic(char *funame)
269                          free(rbf);
270                  prog_show((ix+1.)*(2./sqres));
271          }
272 +        prog_done();
273          if (pctcull >= 0) {                     /* finish output */
274                  if (pclose(ofp)) {
275                          fprintf(stderr, "%s: error running rttree_reduce on Y\n",
# Line 306 | Line 305 | eval_isotropic(char *funame)
305                          }
306                  }
307          }
309        prog_done();
308   }
309  
310   /* Interpolate and output anisotropic BSDF data */
# Line 322 | Line 320 | eval_anisotropic(char *funame)
320          float           bsdf, uv[2];
321  
322          if (pctcull >= 0) {
323 +                const char      *avgopt = (input_orient>0 ^ output_orient>0)
324 +                                                ? "" : " -a";
325                  sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s",
326 <                                (input_orient>0 ^ output_orient>0) ? "" : " -a",
327 <                                pctcull, samp_order, create_component_file(0));
326 >                                avgopt, pctcull, samp_order,
327 >                                create_component_file(0));
328                  ofp = popen(cmd, "w");
329                  if (ofp == NULL) {
330                          fprintf(stderr, "%s: cannot create pipe to rttree_reduce\n",
# Line 338 | Line 338 | eval_anisotropic(char *funame)
338                  if (rbf_colorimetry == RBCtristimulus) {
339                          double  uvcull = 100. - (100.-pctcull)*.25;
340                          sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s",
341 <                                        (input_orient>0 ^ output_orient>0) ? "" : " -a",
342 <                                        uvcull, samp_order, create_component_file(1));
341 >                                        avgopt, uvcull, samp_order,
342 >                                        create_component_file(1));
343                          uvfp[0] = popen(cmd, "w");
344                          sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s",
345 <                                        (input_orient>0 ^ output_orient>0) ? "" : " -a",
346 <                                        uvcull, samp_order, create_component_file(2));
345 >                                        avgopt, uvcull, samp_order,
346 >                                        create_component_file(2));
347                          uvfp[1] = popen(cmd, "w");
348                          if ((uvfp[0] == NULL) | (uvfp[1] == NULL)) {
349                                  fprintf(stderr, "%s: cannot open pipes to uv output\n",
# Line 375 | Line 375 | eval_anisotropic(char *funame)
375                          fputs("{\n", uvfp[1]);
376                  }
377          }
378 <                                                /* need to assign Dx, Dy, Dz? */
379 <        if (funame != NULL)
378 >        if (funame != NULL)                     /* need to assign Dx, Dy, Dz? */
379                  assignD = (fundefined(funame) < 6);
380                                                  /* run through directions */
381          for (ix = 0; ix < sqres; ix++)
# Line 398 | Line 397 | eval_anisotropic(char *funame)
397                              eval_rbfcol(&sdv, rbf, iovec+3);
398                              bsdf = sdv.cieY;
399                              if (rbf_colorimetry == RBCtristimulus) {
401                                c_ccvt(&sdv.spec, C_CSXY);
400                                  uv[0] = uv[1] = 1. /
401                                      (-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.);
402                                  uv[0] *= 4.*sdv.spec.cx;
# Line 443 | Line 441 | eval_anisotropic(char *funame)
441   #endif
442                          }
443                          if (pctcull >= 0)
444 <                                fwrite(&bsdf, sizeof(bsdf), 1, ofp);
444 >                                putbinary(&bsdf, sizeof(bsdf), 1, ofp);
445                          else
446                                  fprintf(ofp, "\t%.3e\n", bsdf);
447  
448                          if (rbf_colorimetry == RBCtristimulus) {
449                                  if (pctcull >= 0) {
450 <                                        fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]);
451 <                                        fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]);
450 >                                        putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]);
451 >                                        putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]);
452                                  } else {
453                                          fprintf(uvfp[0], "\t%.3e\n", uv[0]);
454                                          fprintf(uvfp[1], "\t%.3e\n", uv[1]);
# Line 463 | Line 461 | eval_anisotropic(char *funame)
461                          free(rbf);
462                  prog_show((ix*sqres+iy+1.)/(sqres*sqres));
463              }
464 +        prog_done();
465          if (pctcull >= 0) {                     /* finish output */
466                  if (pclose(ofp)) {
467                          fprintf(stderr, "%s: error running rttree_reduce on Y\n",
# Line 492 | Line 491 | eval_anisotropic(char *funame)
491                          }
492                  }
493          }
495        prog_done();
494   }
495  
496 < #ifdef _WIN32
496 > #if defined(_WIN32) || defined(_WIN64)
497   /* Execute wrapBSDF command (may never return) */
498   static int
499   wrap_up(void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines