46 |
|
static ANGLE_BASIS abase_list[MAXABASES] = { |
47 |
|
{ |
48 |
|
"LBNL/Klems Full", 145, |
49 |
< |
{ {-5., 1}, |
49 |
> |
{ {0., 1}, |
50 |
|
{5., 8}, |
51 |
|
{15., 16}, |
52 |
|
{25., 20}, |
58 |
|
{90., 0} } |
59 |
|
}, { |
60 |
|
"LBNL/Klems Half", 73, |
61 |
< |
{ {-6.5, 1}, |
61 |
> |
{ {0., 1}, |
62 |
|
{6.5, 8}, |
63 |
|
{19.5, 12}, |
64 |
|
{32.5, 16}, |
68 |
|
{90., 0} } |
69 |
|
}, { |
70 |
|
"LBNL/Klems Quarter", 41, |
71 |
< |
{ {-9., 1}, |
71 |
> |
{ {0., 1}, |
72 |
|
{9., 8}, |
73 |
|
{27., 12}, |
74 |
|
{46., 12}, |
218 |
|
if (li == last_li) /* cached latitude? */ |
219 |
|
return last_ohm; |
220 |
|
last_li = li; |
221 |
– |
theta1 = M_PI/180. * ab->lat[li+1].tmin; |
222 |
– |
if (ab->lat[li].nphis == 1) /* special case */ |
223 |
– |
return last_ohm = M_PI*(1. - sq(cos(theta1))); |
221 |
|
theta = M_PI/180. * ab->lat[li].tmin; |
222 |
+ |
theta1 = M_PI/180. * ab->lat[li+1].tmin; |
223 |
|
return last_ohm = M_PI*(sq(cos(theta)) - sq(cos(theta1))) / |
224 |
|
(double)ab->lat[li].nphis; |
225 |
|
} |
333 |
|
ezxml_child(ezxml_child(wbb, |
334 |
|
"ThetaBounds"), "UpperTheta"))); |
335 |
|
if (!i) |
336 |
< |
abase_list[nabases].lat[i].tmin = |
339 |
< |
-abase_list[nabases].lat[i+1].tmin; |
336 |
> |
abase_list[nabases].lat[0].tmin = 0; |
337 |
|
else if (!fequal(atof(ezxml_txt(ezxml_child(ezxml_child(wbb, |
338 |
|
"ThetaBounds"), "LowerTheta"))), |
339 |
|
abase_list[nabases].lat[i].tmin)) { |
399 |
|
SDSpectralDF *df; |
400 |
|
SDMat *dp; |
401 |
|
char *sdata; |
405 |
– |
int tfront; |
402 |
|
int inbi, outbi; |
403 |
|
int i; |
404 |
|
/* allocate BSDF component */ |
407 |
|
return RC_FAIL; |
408 |
|
/* |
409 |
|
* Remember that front and back are reversed from WINDOW 6 orientations |
414 |
– |
* Favor their "Front" (incoming light) since that's more often valid |
410 |
|
*/ |
411 |
< |
tfront = !strcasecmp(sdata, "Transmission Back"); |
417 |
< |
if (!strcasecmp(sdata, "Transmission Front") || |
418 |
< |
tfront & (sd->tf == NULL)) { |
411 |
> |
if (!strcasecmp(sdata, "Transmission Front")) { |
412 |
|
if (sd->tf != NULL) |
413 |
|
SDfreeSpectralDF(sd->tf); |
414 |
|
if ((sd->tf = SDnewSpectralDF(1)) == NULL) |
415 |
|
return RC_MEMERR; |
416 |
|
df = sd->tf; |
417 |
+ |
} else if (!strcasecmp(sdata, "Transmission Back")) { |
418 |
+ |
if (sd->tb != NULL) |
419 |
+ |
SDfreeSpectralDF(sd->tb); |
420 |
+ |
if ((sd->tb = SDnewSpectralDF(1)) == NULL) |
421 |
+ |
return RC_MEMERR; |
422 |
+ |
df = sd->tb; |
423 |
|
} else if (!strcasecmp(sdata, "Reflection Front")) { |
424 |
|
if (sd->rb != NULL) /* note back-front reversal */ |
425 |
|
SDfreeSpectralDF(sd->rb); |
469 |
|
dp->ib_priv = &abase_list[inbi]; |
470 |
|
dp->ob_priv = &abase_list[outbi]; |
471 |
|
if (df == sd->tf) { |
472 |
< |
if (tfront) { |
473 |
< |
dp->ib_vec = &fi_getvec; |
474 |
< |
dp->ib_ndx = &fi_getndx; |
475 |
< |
dp->ob_vec = &bo_getvec; |
476 |
< |
dp->ob_ndx = &bo_getndx; |
477 |
< |
} else { |
478 |
< |
dp->ib_vec = &bi_getvec; |
479 |
< |
dp->ib_ndx = &bi_getndx; |
480 |
< |
dp->ob_vec = &fo_getvec; |
482 |
< |
dp->ob_ndx = &fo_getndx; |
483 |
< |
} |
472 |
> |
dp->ib_vec = &fi_getvec; |
473 |
> |
dp->ib_ndx = &fi_getndx; |
474 |
> |
dp->ob_vec = &bo_getvec; |
475 |
> |
dp->ob_ndx = &bo_getndx; |
476 |
> |
} else if (df == sd->tb) { |
477 |
> |
dp->ib_vec = &bi_getvec; |
478 |
> |
dp->ib_ndx = &bi_getndx; |
479 |
> |
dp->ob_vec = &fo_getvec; |
480 |
> |
dp->ob_ndx = &fo_getndx; |
481 |
|
} else if (df == sd->rf) { |
482 |
|
dp->ib_vec = &fi_getvec; |
483 |
|
dp->ib_ndx = &fi_getndx; |
595 |
|
sd->name); |
596 |
|
return SDEsupport; |
597 |
|
} |
598 |
< |
/* get angle basis */ |
599 |
< |
rval = load_angle_basis(ezxml_child(ezxml_child(wtl, |
600 |
< |
"DataDefinition"), "AngleBasis")); |
601 |
< |
if (rval < 0) |
602 |
< |
return convert_errcode(rval); |
598 |
> |
/* get angle bases */ |
599 |
> |
for (wld = ezxml_child(ezxml_child(wtl, "DataDefinition"), "AngleBasis"); |
600 |
> |
wld != NULL; wld = wld->next) { |
601 |
> |
rval = load_angle_basis(wld); |
602 |
> |
if (rval < 0) |
603 |
> |
return convert_errcode(rval); |
604 |
> |
} |
605 |
|
/* load BSDF components */ |
606 |
|
for (wld = ezxml_child(wtl, "WavelengthData"); |
607 |
|
wld != NULL; wld = wld->next) { |
616 |
|
/* separate diffuse components */ |
617 |
|
extract_diffuse(&sd->rLambFront, sd->rf); |
618 |
|
extract_diffuse(&sd->rLambBack, sd->rb); |
619 |
< |
extract_diffuse(&sd->tLamb, sd->tf); |
619 |
> |
extract_diffuse(&sd->tLamb, (sd->tf != NULL) ? sd->tf : sd->tb); |
620 |
|
/* return success */ |
621 |
|
return SDEnone; |
622 |
|
} |
756 |
|
} |
757 |
|
cdlast = NULL; /* check for it in cache list */ |
758 |
|
for (cd = (SDMatCDst *)sdc->cdList; cd != NULL; |
759 |
< |
cdlast = cd, cd = (SDMatCDst *)cd->next) |
759 |
> |
cdlast = cd, cd = cd->next) |
760 |
|
if (cd->indx == myCD.indx && (cd->calen == myCD.calen) & |
761 |
|
(cd->ob_priv == myCD.ob_priv) & |
762 |
|
(cd->ob_vec == myCD.ob_vec)) |
775 |
|
} |
776 |
|
if (cdlast != NULL) { /* move entry to head of cache list */ |
777 |
|
cdlast->next = cd->next; |
778 |
< |
cd->next = sdc->cdList; |
778 |
> |
cd->next = (SDMatCDst *)sdc->cdList; |
779 |
|
sdc->cdList = (SDCDst *)cd; |
780 |
|
} |
781 |
|
return (SDCDst *)cd; /* ready to go */ |
795 |
|
/* binary search to find index */ |
796 |
|
ilower = 0; iupper = mcd->calen; |
797 |
|
while ((i = (iupper + ilower) >> 1) != ilower) |
798 |
< |
if ((long)target >= (long)mcd->carr[i]) |
798 |
> |
if (target >= mcd->carr[i]) |
799 |
|
ilower = i; |
800 |
|
else |
801 |
|
iupper = i; |