--- ray/src/common/bsdf.c 2010/09/26 15:43:26 2.8 +++ ray/src/common/bsdf.c 2011/01/06 04:40:22 2.12 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdf.c,v 2.8 2010/09/26 15:43:26 greg Exp $"; +static const char RCSid[] = "$Id: bsdf.c,v 2.12 2011/01/06 04:40:22 greg Exp $"; #endif /* * Routines for handling BSDF data @@ -61,8 +61,16 @@ static ANGLE_BASIS abase_list[MAXABASES] = { static int nabases = 3; /* current number of defined bases */ -#define FEQ(a,b) ((a)-(b) <= 1e-7 && (b)-(a) <= 1e-7) +#define FEQ(a,b) ((a)-(b) <= 1e-6 && (b)-(a) <= 1e-6) +static int +fequal(double a, double b) +{ + if (b != .0) + a = a/b - 1.; + return((a <= 1e-6) & (a >= -1e-6)); +} + // returns the name of the given tag #ifdef ezxml_name #undef ezxml_name @@ -211,7 +219,7 @@ load_angle_basis( /* load custom BSDF angle basis */ if (!abname || !*abname) return; for (i = nabases; i--; ) - if (!strcmp(abname, abase_list[i].name)) + if (!strcasecmp(abname, abase_list[i].name)) return; /* assume it's the same */ if (nabases >= MAXABASES) error(INTERNAL, "too many angle bases"); @@ -227,7 +235,7 @@ load_angle_basis( /* load custom BSDF angle basis */ if (!i) abase_list[nabases].lat[i].tmin = -abase_list[nabases].lat[i+1].tmin; - else if (!FEQ(atof(ezxml_txt(ezxml_child(ezxml_child(wbb, + else if (!fequal(atof(ezxml_txt(ezxml_child(ezxml_child(wbb, "ThetaBounds"), "LowerTheta"))), abase_list[nabases].lat[i].tmin)) error(WARNING, "theta values disagree in custom basis"); @@ -312,7 +320,7 @@ load_bsdf_data( /* load BSDF distribution for this wa return; } for (i = nabases; i--; ) - if (!strcmp(cbasis, abase_list[i].name)) { + if (!strcasecmp(cbasis, abase_list[i].name)) { dp->ninc = abase_list[i].nangles; dp->ib_priv = (void *)&abase_list[i]; dp->ib_vec = ab_getvecR; @@ -326,7 +334,7 @@ load_bsdf_data( /* load BSDF distribution for this wa return; } for (i = nabases; i--; ) - if (!strcmp(rbasis, abase_list[i].name)) { + if (!strcasecmp(rbasis, abase_list[i].name)) { dp->nout = abase_list[i].nangles; dp->ob_priv = (void *)&abase_list[i]; dp->ob_vec = ab_getvec; @@ -518,17 +526,27 @@ load_BSDF( /* load BSDF data from file */ return(NULL); } wtl = ezxml_child(ezxml_child(fl, "Optical"), "Layer"); + if (strcasecmp(ezxml_txt(ezxml_child(ezxml_child(wtl, + "DataDefinition"), "IncidentDataStructure")), + "Columns")) { + sprintf(errmsg, + "BSDF \"%s\": unsupported IncidentDataStructure", + path); + error(WARNING, errmsg); + ezxml_free(fl); + return(NULL); + } load_angle_basis(ezxml_child(ezxml_child(wtl, "DataDefinition"), "AngleBasis")); dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data)); load_geometry(dp, ezxml_child(wtl, "Material")); for (wld = ezxml_child(wtl, "WavelengthData"); wld != NULL; wld = wld->next) { - if (strcmp(ezxml_txt(ezxml_child(wld,"Wavelength")), "Visible")) + if (strcasecmp(ezxml_txt(ezxml_child(wld,"Wavelength")), "Visible")) continue; wdb = ezxml_child(wld, "WavelengthDataBlock"); if (wdb == NULL) continue; - if (strcmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")), + if (strcasecmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")), "Transmission Front")) continue; load_bsdf_data(dp, wdb); /* load front BTDF */