| 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 |
< |
// returns the name of the given tag |
| 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 |
| 77 |
|
static char * |
| 83 |
|
} |
| 84 |
|
#endif |
| 85 |
|
|
| 86 |
< |
// returns the given tag's character content or empty string if none |
| 86 |
> |
/* Returns the given tag's character content or empty string if none */ |
| 87 |
|
#ifdef ezxml_txt |
| 88 |
|
#undef ezxml_txt |
| 89 |
|
static char * |
| 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"); |
| 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"); |
| 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; |
| 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; |
| 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")), |
| 546 |
> |
"Visible")) |
| 547 |
|
continue; |
| 548 |
< |
wdb = ezxml_child(wld, "WavelengthDataBlock"); |
| 549 |
< |
if (wdb == NULL) continue; |
| 550 |
< |
if (strcmp(ezxml_txt(ezxml_child(wdb,"WavelengthDataDirection")), |
| 548 |
> |
for (wdb = ezxml_child(wld, "WavelengthDataBlock"); |
| 549 |
> |
wdb != NULL; wdb = wdb->next) |
| 550 |
> |
if (!strcasecmp(ezxml_txt(ezxml_child(wdb, |
| 551 |
> |
"WavelengthDataDirection")), |
| 552 |
|
"Transmission Front")) |
| 553 |
< |
continue; |
| 554 |
< |
load_bsdf_data(dp, wdb); /* load front BTDF */ |
| 555 |
< |
break; /* ignore the rest */ |
| 553 |
> |
break; |
| 554 |
> |
if (wdb != NULL) { /* load front BTDF */ |
| 555 |
> |
load_bsdf_data(dp, wdb); |
| 556 |
> |
break; /* ignore the rest */ |
| 557 |
> |
} |
| 558 |
|
} |
| 559 |
|
ezxml_free(fl); /* done with XML file */ |
| 560 |
|
if (!check_bsdf_data(dp)) { |