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

Comparing ray/src/common/bsdf.c (file contents):
Revision 2.7 by greg, Tue Sep 7 23:10:50 2010 UTC vs.
Revision 2.12 by greg, Thu Jan 6 04:40:22 2011 UTC

# Line 61 | Line 61 | static ANGLE_BASIS     abase_list[MAXABASES] = {
61  
62   static int      nabases = 3;    /* current number of defined bases */
63  
64 < #define  FEQ(a,b)       ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7)
64 > #define  FEQ(a,b)       ((a)-(b) <= 1e-6 && (b)-(a) <= 1e-6)
65  
66 + static int
67 + fequal(double a, double b)
68 + {
69 +        if (b != .0)
70 +                a = a/b - 1.;
71 +        return((a <= 1e-6) & (a >= -1e-6));
72 + }
73 +
74   // returns the name of the given tag
75   #ifdef ezxml_name
76   #undef ezxml_name
# Line 211 | Line 219 | load_angle_basis(      /* load custom BSDF angle basis */
219          if (!abname || !*abname)
220                  return;
221          for (i = nabases; i--; )
222 <                if (!strcmp(abname, abase_list[i].name))
222 >                if (!strcasecmp(abname, abase_list[i].name))
223                          return;         /* assume it's the same */
224          if (nabases >= MAXABASES)
225                  error(INTERNAL, "too many angle bases");
# Line 227 | Line 235 | load_angle_basis(      /* load custom BSDF angle basis */
235                  if (!i)
236                          abase_list[nabases].lat[i].tmin =
237                                          -abase_list[nabases].lat[i+1].tmin;
238 <                else if (!FEQ(atof(ezxml_txt(ezxml_child(ezxml_child(wbb,
238 >                else if (!fequal(atof(ezxml_txt(ezxml_child(ezxml_child(wbb,
239                                          "ThetaBounds"), "LowerTheta"))),
240                                  abase_list[nabases].lat[i].tmin))
241                          error(WARNING, "theta values disagree in custom basis");
# Line 249 | Line 257 | to_meters(             /* return factor to convert given unit to
257          if (!strcasecmp(unit, "Foot")) return(.3048);
258          if (!strcasecmp(unit, "Inch")) return(.0254);
259          if (!strcasecmp(unit, "Centimeter")) return(.01);
260 +        if (!strcasecmp(unit, "Millimeter")) return(.001);
261          sprintf(errmsg, "unknown dimensional unit '%s'", unit);
262          error(USER, errmsg);
263   }
# Line 311 | Line 320 | load_bsdf_data(                /* load BSDF distribution for this wa
320                  return;
321          }
322          for (i = nabases; i--; )
323 <                if (!strcmp(cbasis, abase_list[i].name)) {
323 >                if (!strcasecmp(cbasis, abase_list[i].name)) {
324                          dp->ninc = abase_list[i].nangles;
325                          dp->ib_priv = (void *)&abase_list[i];
326                          dp->ib_vec = ab_getvecR;
# Line 325 | Line 334 | load_bsdf_data(                /* load BSDF distribution for this wa
334                  return;
335          }
336          for (i = nabases; i--; )
337 <                if (!strcmp(rbasis, abase_list[i].name)) {
337 >                if (!strcasecmp(rbasis, abase_list[i].name)) {
338                          dp->nout = abase_list[i].nangles;
339                          dp->ob_priv = (void *)&abase_list[i];
340                          dp->ob_vec = ab_getvec;
# Line 445 | Line 454 | check_bsdf_data(       /* check that BSDF data is sane */
454                                  BSDF_value(dp,i,o) = .0f;
455                          }
456                  }
457 <                if (hemi_total > 1.02) {
457 >                if (hemi_total > 1.01) {
458                          sprintf(errmsg,
459                          "incoming BSDF direction %d passes %.1f%% of light",
460                                          i, 100.*hemi_total);
# Line 462 | Line 471 | check_bsdf_data(       /* check that BSDF data is sane */
471                  for (i = dp->ninc; i--; )
472                          hemi_total += BSDF_value(dp,i,o) * omega_iarr[i];
473  
474 <                if (hemi_total > 1.02) {
474 >                if (hemi_total > 1.01) {
475                          sprintf(errmsg,
476                          "outgoing BSDF direction %d collects %.1f%% of light",
477                                          o, 100.*hemi_total);
# Line 471 | Line 480 | check_bsdf_data(       /* check that BSDF data is sane */
480                  full_total += hemi_total*omega_oarr[o];
481          }
482          full_total /= PI;
483 <        if (full_total > 1.02) {
484 <                sprintf(errmsg, "BSDF transfers %.1f%% of light",
483 >        if (full_total > 1.00001) {
484 >                sprintf(errmsg, "BSDF transfers %.4f%% of light",
485                                  100.*full_total);
486                  error(WARNING, errmsg);
487          }
# Line 517 | Line 526 | load_BSDF(             /* load BSDF data from file */
526                  return(NULL);
527          }
528          wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer");
529 +        if (strcasecmp(ezxml_txt(ezxml_child(ezxml_child(wtl,
530 +                        "DataDefinition"), "IncidentDataStructure")),
531 +                        "Columns")) {
532 +                sprintf(errmsg,
533 +                        "BSDF \"%s\": unsupported IncidentDataStructure",
534 +                                path);
535 +                error(WARNING, errmsg);
536 +                ezxml_free(fl);
537 +                return(NULL);
538 +        }              
539          load_angle_basis(ezxml_child(ezxml_child(wtl,
540                                  "DataDefinition"), "AngleBasis"));
541          dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data));
542          load_geometry(dp, ezxml_child(wtl, "Material"));
543          for (wld = ezxml_child(wtl, "WavelengthData");
544                                  wld != NULL; wld = wld->next) {
545 <                if (strcmp(ezxml_txt(ezxml_child(wld,"Wavelength")), "Visible"))
545 >                if (strcasecmp(ezxml_txt(ezxml_child(wld,"Wavelength")), "Visible"))
546                          continue;
547                  wdb = ezxml_child(wld, "WavelengthDataBlock");
548                  if (wdb == NULL) continue;
549 <                if (strcmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")),
549 >                if (strcasecmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")),
550                                          "Transmission Front"))
551                          continue;
552                  load_bsdf_data(dp, wdb);        /* load front BTDF */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines