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.28 by greg, Fri Jan 29 16:21:56 2016 UTC vs.
Revision 2.32 by greg, Tue Apr 9 22:15:51 2019 UTC

# Line 3 | Line 3 | static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   * Load measured BSDF data in PAB-Opto format.
6 + * Assumes that surface-normal (Z-axis) faces into room unless -t option given.
7   *
8   *      G. Ward
9   */
# Line 32 | Line 33 | typedef struct {
33   PGINPUT         *inpfile;       /* input files sorted by incidence */
34   int             ninpfiles;      /* number of input files */
35  
36 + int             rev_orient = 0; /* shall we reverse surface orientation? */
37 +
38   /* Compare incident angles */
39   static int
40   cmp_indir(const void *p1, const void *p2)
# Line 114 | Line 117 | init_pabopto_inp(const int i, const char *fname)
117                  fputs(": unknown incident angle\n", stderr);
118                  return(0);
119          }
120 +        if (rev_orient) {       /* reverse Z-axis to face outside */
121 +                inpfile[i].theta = 180. - inpfile[i].theta;
122 +                inpfile[i].phi = 360. - inpfile[i].phi;
123 +        }
124                                  /* convert to Y-up orientation */
125          inpfile[i].phi += 90.-inpfile[i].up_phi;
126                                  /* convert angle to grid position */
# Line 121 | Line 128 | init_pabopto_inp(const int i, const char *fname)
128          dv[0] = cos(M_PI/180.*inpfile[i].phi)*dv[2];
129          dv[1] = sin(M_PI/180.*inpfile[i].phi)*dv[2];
130          dv[2] = sqrt(1. - dv[2]*dv[2]);
131 <        pos_from_vec(inpfile[i].igp, dv);
131 >        if (inpfile[i].theta <= FTINY)
132 >                inpfile[i].igp[0] = inpfile[i].igp[1] = grid_res/2 - 1;
133 >        else
134 >                pos_from_vec(inpfile[i].igp, dv);
135          return(1);
136   }
137  
# Line 162 | Line 172 | add_pabopto_inp(const int i)
172                                  fclose(fp);
173                                  return(1);
174                          }
175 +                if (rev_orient) {       /* reverse Z-axis to face outside */
176 +                        theta_out = 180. - theta_out;
177 +                        phi_out = 360. - phi_out;
178 +                }
179                  add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi,
180                                  val, inpfile[i].isDSF);
181          }
# Line 191 | Line 205 | main(int argc, char *argv[])
205          progname = argv[0];                     /* get options */
206          while (argc > 2 && argv[1][0] == '-') {
207                  switch (argv[1][1]) {
208 +                case 't':
209 +                        rev_orient = !rev_orient;
210 +                        break;
211                  case 'n':
212                          nprocs = atoi(argv[2]);
213 +                        argv++; argc--;
214                          break;
215                  default:
216                          goto userr;
217                  }
218 <                argv += 2; argc -= 2;
218 >                argv++; argc--;
219          }
220                                                  /* initialize & sort inputs */
221          ninpfiles = argc - 1;
# Line 219 | Line 237 | main(int argc, char *argv[])
237          save_bsdf_rep(stdout);                  /* write it out */
238          return(0);
239   userr:
240 <        fprintf(stderr, "Usage: %s [-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n",
240 >        fprintf(stderr, "Usage: %s [-t][-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n",
241                                          progname);
242          return(1);
243   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines