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.29 by greg, Tue Feb 2 00:42:11 2016 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 162 | Line 169 | add_pabopto_inp(const int i)
169                                  fclose(fp);
170                                  return(1);
171                          }
172 +                if (rev_orient) {       /* reverse Z-axis to face outside */
173 +                        theta_out = 180. - theta_out;
174 +                        phi_out = 360. - phi_out;
175 +                }
176                  add_bsdf_data(theta_out, phi_out+90.-inpfile[i].up_phi,
177                                  val, inpfile[i].isDSF);
178          }
# Line 191 | Line 202 | main(int argc, char *argv[])
202          progname = argv[0];                     /* get options */
203          while (argc > 2 && argv[1][0] == '-') {
204                  switch (argv[1][1]) {
205 +                case 't':
206 +                        rev_orient = !rev_orient;
207 +                        break;
208                  case 'n':
209                          nprocs = atoi(argv[2]);
210 +                        argv++; argc--;
211                          break;
212                  default:
213                          goto userr;
214                  }
215 <                argv += 2; argc -= 2;
215 >                argv++; argc--;
216          }
217                                                  /* initialize & sort inputs */
218          ninpfiles = argc - 1;
# Line 219 | Line 234 | main(int argc, char *argv[])
234          save_bsdf_rep(stdout);                  /* write it out */
235          return(0);
236   userr:
237 <        fprintf(stderr, "Usage: %s [-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n",
237 >        fprintf(stderr, "Usage: %s [-t][-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n",
238                                          progname);
239          return(1);
240   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines