362 |
|
SDSpectralDF *df; |
363 |
|
SDMat *dp; |
364 |
|
char *sdata; |
365 |
+ |
int tback; |
366 |
|
int inbi, outbi; |
367 |
|
int i; |
368 |
|
/* allocate BSDF component */ |
369 |
|
sdata = ezxml_txt(ezxml_child(wdb, "WavelengthDataDirection")); |
370 |
< |
if (!strcasecmp(sdata, "Transmission Front")) { |
370 |
> |
if ((tback = !strcasecmp(sdata, "Transmission Back")) || |
371 |
> |
(sd->tf == NULL && |
372 |
> |
!strcasecmp(sdata, "Transmission Front"))) { |
373 |
|
if (sd->tf != NULL) |
374 |
|
SDfreeSpectralDF(sd->tf); |
375 |
|
if ((sd->tf = SDnewSpectralDF(1)) == NULL) |
376 |
|
return RC_MEMERR; |
377 |
|
df = sd->tf; |
378 |
|
} else if (!strcasecmp(sdata, "Reflection Front")) { |
379 |
< |
if (sd->rf != NULL) |
377 |
< |
SDfreeSpectralDF(sd->rf); |
378 |
< |
if ((sd->rf = SDnewSpectralDF(1)) == NULL) |
379 |
< |
return RC_MEMERR; |
380 |
< |
df = sd->rf; |
381 |
< |
} else if (!strcasecmp(sdata, "Reflection Back")) { |
382 |
< |
if (sd->rb != NULL) |
379 |
> |
if (sd->rb != NULL) /* note back-front reversal */ |
380 |
|
SDfreeSpectralDF(sd->rb); |
381 |
|
if ((sd->rb = SDnewSpectralDF(1)) == NULL) |
382 |
|
return RC_MEMERR; |
383 |
|
df = sd->rb; |
384 |
+ |
} else if (!strcasecmp(sdata, "Reflection Back")) { |
385 |
+ |
if (sd->rf != NULL) /* note front-back reversal */ |
386 |
+ |
SDfreeSpectralDF(sd->rf); |
387 |
+ |
if ((sd->rf = SDnewSpectralDF(1)) == NULL) |
388 |
+ |
return RC_MEMERR; |
389 |
+ |
df = sd->rf; |
390 |
|
} else |
391 |
|
return RC_FAIL; |
392 |
|
/* XXX should also check "ScatteringDataType" for consistency? */ |
424 |
|
dp->ib_priv = &abase_list[inbi]; |
425 |
|
dp->ob_priv = &abase_list[outbi]; |
426 |
|
if (df == sd->tf) { |
427 |
< |
dp->ib_vec = &ab_getvecR; |
428 |
< |
dp->ib_ndx = &ab_getndxR; |
429 |
< |
dp->ob_vec = &ab_getvec; |
430 |
< |
dp->ob_ndx = &ab_getndx; |
427 |
> |
if (tback) { |
428 |
> |
dp->ib_vec = &ab_getvecR; |
429 |
> |
dp->ib_ndx = &ab_getndxR; |
430 |
> |
dp->ob_vec = &ab_getvec; |
431 |
> |
dp->ob_ndx = &ab_getndx; |
432 |
> |
} else { |
433 |
> |
dp->ib_vec = &ab_getvec; |
434 |
> |
dp->ib_ndx = &ab_getndx; |
435 |
> |
dp->ob_vec = &ab_getvecR; |
436 |
> |
dp->ob_ndx = &ab_getndxR; |
437 |
> |
} |
438 |
|
} else if (df == sd->rf) { |
439 |
|
dp->ib_vec = &ab_getvec; |
440 |
|
dp->ib_ndx = &ab_getndx; |