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.29 by greg, Tue Feb 2 00:42:11 2016 UTC vs.
Revision 2.36 by greg, Fri Jul 19 17:37:56 2019 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   */
10  
11   #define _USE_MATH_DEFINES
12 #include <stdio.h>
12   #include <stdlib.h>
14 #include <string.h>
13   #include <ctype.h>
14   #include <math.h>
15 + #include "rtio.h"
16   #include "platform.h"
17   #include "bsdfrep.h"
19 #include "resolu.h"
18                                  /* global argv[0] */
19   char                    *progname;
20  
# Line 128 | Line 126 | init_pabopto_inp(const int i, const char *fname)
126          dv[0] = cos(M_PI/180.*inpfile[i].phi)*dv[2];
127          dv[1] = sin(M_PI/180.*inpfile[i].phi)*dv[2];
128          dv[2] = sqrt(1. - dv[2]*dv[2]);
129 <        pos_from_vec(inpfile[i].igp, dv);
129 >        if (inpfile[i].theta <= FTINY)
130 >                inpfile[i].igp[0] = inpfile[i].igp[1] = grid_res/2 - 1;
131 >        else
132 >                pos_from_vec(inpfile[i].igp, dv);
133          return(1);
134   }
135  
# Line 188 | Line 189 | add_pabopto_inp(const int i)
189   }
190  
191   #ifndef TEST_MAIN
192 +
193 + #define SYM_ILL         '?'             /* illegal symmetry value */
194 + #define SYM_ISO         'I'             /* isotropic */
195 + #define SYM_QUAD        'Q'             /* quadrilateral symmetry */
196 + #define SYM_BILAT       'B'             /* bilateral symmetry */
197 + #define SYM_ANISO       'A'             /* anisotropic */
198 +
199 + static const char       quadrant_rep[16][16] = {
200 +                                "in-plane","0-90","90-180","0-180",
201 +                                "180-270","0-90+180-270","90-270",
202 +                                "0-270","270-360","270-90",
203 +                                "90-180+270-360","270-180","180-360",
204 +                                "180-90","90-360","0-360"
205 +                        };
206 + static const char       quadrant_sym[16] = {
207 +                                SYM_ISO, SYM_QUAD, SYM_QUAD, SYM_BILAT,
208 +                                SYM_QUAD, SYM_ILL, SYM_BILAT, SYM_ILL,
209 +                                SYM_QUAD, SYM_BILAT, SYM_ILL, SYM_ILL,
210 +                                SYM_BILAT, SYM_ILL, SYM_ILL, SYM_ANISO
211 +                        };
212 +
213   /* Read in PAB-Opto BSDF files and output RBF interpolant */
214   int
215   main(int argc, char *argv[])
216   {
217          extern int      nprocs;
218 +        const char      *symmetry = "U";
219          int             i;
220                                                  /* start header */
221          SET_FILE_BINARY(stdout);
# Line 209 | Line 232 | main(int argc, char *argv[])
232                          nprocs = atoi(argv[2]);
233                          argv++; argc--;
234                          break;
235 +                case 's':
236 +                        symmetry = argv[2];
237 +                        argv++; argc--;
238 +                        break;
239                  default:
240                          goto userr;
241                  }
# Line 230 | Line 257 | main(int argc, char *argv[])
257                  if (!add_pabopto_inp(i))
258                          return(1);
259          make_rbfrep();                          /* process last data set */
260 +                                                /* check input symmetry */
261 +        switch (toupper(symmetry[0])) {
262 +        case 'U':                               /* unspecified symmetry */
263 +                if (quadrant_sym[inp_coverage] != SYM_ILL)
264 +                        break;                  /* anything legal goes */
265 +                fprintf(stderr, "%s: unsupported phi coverage (%s)\n",
266 +                                progname, quadrant_rep[inp_coverage]);
267 +                return(1);
268 +        case SYM_ISO:                           /* legal symmetry types */
269 +        case SYM_QUAD:
270 +        case SYM_BILAT:
271 +        case SYM_ANISO:
272 +                if (quadrant_sym[inp_coverage] == toupper(symmetry[0]))
273 +                        break;                  /* matches spec */
274 +                fprintf(stderr,
275 +                "%s: phi coverage (%s) does not match requested '%s' symmetry\n",
276 +                                progname, quadrant_rep[inp_coverage], symmetry);
277 +                return(1);
278 +        default:
279 +                fprintf(stderr,
280 +  "%s: -s option must be Isotropic, Quadrilateral, Bilateral, or Anisotropic\n",
281 +                                progname);
282 +                return(1);
283 +        }
284 + #ifdef DEBUG
285 +        fprintf(stderr, "Input phi coverage (%s) has '%c' symmetry\n",
286 +                                quadrant_rep[inp_coverage],
287 +                                quadrant_sym[inp_coverage]);
288 + #endif
289          build_mesh();                           /* create interpolation */
290          save_bsdf_rep(stdout);                  /* write it out */
291          return(0);
292   userr:
293 <        fprintf(stderr, "Usage: %s [-t][-n nproc] meas1.dat meas2.dat .. > bsdf.sir\n",
293 >        fprintf(stderr, "Usage: %s [-t][-n nproc][-s symmetry] meas1.dat meas2.dat .. > bsdf.sir\n",
294                                          progname);
295          return(1);
296   }
297 < #else
297 >
298 > #else           /* TEST_MAIN */
299 >
300   /* Test main produces a Radiance model from the given input file */
301   int
302   main(int argc, char *argv[])
# Line 322 | Line 380 | main(int argc, char *argv[])
380   #endif
381          return(0);
382   }
383 < #endif
383 >
384 > #endif          /* TEST_MAIN */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines