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.7 by greg, Thu Nov 8 22:05:04 2012 UTC vs.
Revision 2.12 by greg, Wed Mar 20 01:00:22 2013 UTC

# Line 26 | Line 26 | int                    single_plane_incident = -1;
26   int                     input_orient = 0;
27   int                     output_orient = 0;
28  
29 +                                /* BSDF histogram */
30 + int                     bsdf_hist[HISTLEN];
31 +
32 +                                /* BSDF value for boundary regions */
33 + double                  bsdf_min = 0;
34 +
35                                  /* processed incident DSF measurements */
36   RBFNODE                 *dsf_list = NULL;
37  
# Line 82 | Line 88 | new_input_direction(double new_theta, double new_phi)
88   int
89   use_symmetry(FVECT vec)
90   {
91 <        double  phi = get_phi360(vec);
91 >        const double    phi = get_phi360(vec);
92  
93          switch (inp_coverage) {
94          case INP_QUAD1|INP_QUAD2|INP_QUAD3|INP_QUAD4:
# Line 188 | Line 194 | rotate_rbf(RBFNODE *rbf, const FVECT invec)
194          FVECT                   outvec;
195          int                     pos[2];
196          int                     n;
197 < #ifdef DEBUG
198 <        double  tdiff = 180./M_PI*fabs(acos(invec[2])-acos(rbf->invec[2]));
193 <        if (tdiff >= 1.5)
194 <                fprintf(stderr,
195 <                        "%s: Warning - rotated theta differs by %.1f degrees\n",
196 <                                progname, tdiff);
197 < #endif
198 <        for (n = rbf->nrbf; n-- > 0; ) {
197 >
198 >        for (n = ((-.01 > phi) | (phi > .01))*rbf->nrbf; n-- > 0; ) {
199                  ovec_from_pos(outvec, rbf->rbfa[n].gx, rbf->rbfa[n].gy);
200                  spinvector(outvec, outvec, vnorm, phi);
201                  pos_from_vec(pos, outvec);
# Line 221 | Line 221 | ovec_from_pos(FVECT vec, int xpos, int ypos)
221          double  uv[2];
222          double  r2;
223          
224 <        SDsquare2disk(uv, (1./grid_res)*(xpos+.5), (1./grid_res)*(ypos+.5));
224 >        SDsquare2disk(uv, (xpos+.5)/grid_res, (ypos+.5)/grid_res);
225                                  /* uniform hemispherical projection */
226          r2 = uv[0]*uv[0] + uv[1]*uv[1];
227          vec[0] = vec[1] = sqrt(2. - r2);
# Line 247 | Line 247 | pos_from_vec(int pos[2], const FVECT vec)
247   double
248   eval_rbfrep(const RBFNODE *rp, const FVECT outvec)
249   {
250 <        double          res = .0;
250 >        double          res = 0;
251          const RBFVAL    *rbfp;
252          FVECT           odir;
253          double          sig2;
254          int             n;
255 <
256 <        if (rp == NULL)
257 <                return(.0);
255 >                                /* use minimum if no information avail. */
256 >        if (rp == NULL) {
257 >                if (outvec[2] > 0 ^ output_orient > 0)
258 >                        return(.0);
259 >                return(bsdf_min*output_orient*outvec[2]);
260 >        }
261          rbfp = rp->rbfa;
262          for (n = rp->nrbf; n--; rbfp++) {
263                  ovec_from_pos(odir, rbfp->gx, rbfp->gy);
# Line 396 | Line 399 | save_bsdf_rep(FILE *ofp)
399          fprintf(ofp, "SYMMETRY=%d\n", !single_plane_incident * inp_coverage);
400          fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient);
401          fprintf(ofp, "GRIDRES=%d\n", grid_res);
402 +        fprintf(ofp, "BSDFMIN=%g\n", bsdf_min);
403          fputformat(BSDFREP_FMT, ofp);
404          fputc('\n', ofp);
405                                          /* write each DSF */
# Line 461 | Line 465 | headline(char *s, void *p)
465                  sscanf(s+8, "%d", &grid_res);
466                  return(0);
467          }
468 +        if (!strncmp(s, "BSDFMIN=", 8)) {
469 +                sscanf(s+8, "%lf", &bsdf_min);
470 +                return(0);
471 +        }
472          if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT))
473                  return(-1);
474          return(0);
# Line 491 | Line 499 | load_bsdf_rep(FILE *ifp)
499                  rbfh.invec[0] = getflt(ifp);
500                  rbfh.invec[1] = getflt(ifp);
501                  rbfh.invec[2] = getflt(ifp);
502 +                if (normalize(rbfh.invec) == 0) {
503 +                        fprintf(stderr, "%s: zero incident vector\n", progname);
504 +                        return(0);
505 +                }
506                  rbfh.vtotal = getflt(ifp);
507                  rbfh.nrbf = getint(4, ifp);
508                  newrbf = (RBFNODE *)malloc(sizeof(RBFNODE) +
509                                          sizeof(RBFVAL)*(rbfh.nrbf-1));
510                  if (newrbf == NULL)
511                          goto memerr;
512 <                memcpy(newrbf, &rbfh, sizeof(RBFNODE));
512 >                memcpy(newrbf, &rbfh, sizeof(RBFNODE)-sizeof(RBFVAL));
513                  for (i = 0; i < rbfh.nrbf; i++) {
514                          newrbf->rbfa[i].peak = getflt(ifp);
515                          newrbf->rbfa[i].crad = getint(2, ifp) & 0xffff;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines