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

Comparing ray/src/cv/bsdfrep.c (file contents):
Revision 2.4 by greg, Tue Oct 23 05:10:42 2012 UTC vs.
Revision 2.5 by greg, Wed Nov 7 03:04:23 2012 UTC

# Line 14 | Line 14 | static const char RCSid[] = "$Id$";
14   #include "rtio.h"
15   #include "resolu.h"
16   #include "bsdfrep.h"
17 +                                /* active grid resolution */
18 + int                     grid_res = GRIDRES;
19 +
20                                  /* coverage/symmetry using INP_QUAD? flags */
21   int                     inp_coverage = 0;
22                                  /* all incident angles in-plane so far? */
# Line 168 | Line 171 | rev_rbf_symmetry(RBFNODE *rbf, int sym)
171          rev_symmetry(rbf->invec, sym);
172          if (sym & MIRROR_X)
173                  for (n = rbf->nrbf; n-- > 0; )
174 <                        rbf->rbfa[n].gx = GRIDRES-1 - rbf->rbfa[n].gx;
174 >                        rbf->rbfa[n].gx = grid_res-1 - rbf->rbfa[n].gx;
175          if (sym & MIRROR_Y)
176                  for (n = rbf->nrbf; n-- > 0; )
177 <                        rbf->rbfa[n].gy = GRIDRES-1 - rbf->rbfa[n].gy;
177 >                        rbf->rbfa[n].gy = grid_res-1 - rbf->rbfa[n].gy;
178   }
179  
180   /* Compute volume associated with Gaussian lobe */
# Line 190 | Line 193 | ovec_from_pos(FVECT vec, int xpos, int ypos)
193          double  uv[2];
194          double  r2;
195          
196 <        SDsquare2disk(uv, (1./GRIDRES)*(xpos+.5), (1./GRIDRES)*(ypos+.5));
196 >        SDsquare2disk(uv, (1./grid_res)*(xpos+.5), (1./grid_res)*(ypos+.5));
197                                  /* uniform hemispherical projection */
198          r2 = uv[0]*uv[0] + uv[1]*uv[1];
199          vec[0] = vec[1] = sqrt(2. - r2);
# Line 208 | Line 211 | pos_from_vec(int pos[2], const FVECT vec)
211  
212          SDdisk2square(sq, vec[0]*norm, vec[1]*norm);
213  
214 <        pos[0] = (int)(sq[0]*GRIDRES);
215 <        pos[1] = (int)(sq[1]*GRIDRES);
214 >        pos[0] = (int)(sq[0]*grid_res);
215 >        pos[1] = (int)(sq[1]*grid_res);
216   }
217  
218   /* Evaluate RBF for DSF at the given normalized outgoing direction */
# Line 351 | Line 354 | clear_bsdf_rep(void)
354          inp_coverage = 0;
355          single_plane_incident = -1;
356          input_orient = output_orient = 0;
357 +        grid_res = GRIDRES;
358   }
359  
360   /* Write our BSDF mesh interpolant out to the given binary stream */
# Line 363 | Line 367 | save_bsdf_rep(FILE *ofp)
367                                          /* finish header */
368          fprintf(ofp, "SYMMETRY=%d\n", !single_plane_incident * inp_coverage);
369          fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient);
370 +        fprintf(ofp, "GRIDRES=%d\n", grid_res);
371          fputformat(BSDFREP_FMT, ofp);
372          fputc('\n', ofp);
373                                          /* write each DSF */
# Line 424 | Line 429 | headline(char *s, void *p)
429                  sscanf(s+9, "%d %d", &input_orient, &output_orient);
430                  return(0);
431          }
432 +        if (!strncmp(s, "GRIDRES=", 8)) {
433 +                sscanf(s+8, "%d", &grid_res);
434 +                return(0);
435 +        }
436          if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT))
437                  return(-1);
438          return(0);
# Line 438 | Line 447 | load_bsdf_rep(FILE *ifp)
447          int             i;
448  
449          clear_bsdf_rep();
450 +        if (ifp == NULL)
451 +                return(0);
452          if (getheader(ifp, headline, NULL) < 0 || single_plane_incident < 0 |
453                          !input_orient | !output_orient) {
454                  fprintf(stderr, "%s: missing/bad format for BSDF interpolant\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines