| 10 |
|
* |
| 11 |
|
*/ |
| 12 |
|
|
| 13 |
+ |
#define _USE_MATH_DEFINES |
| 14 |
|
#include <stdio.h> |
| 15 |
|
#include <stdlib.h> |
| 16 |
+ |
#include <string.h> |
| 17 |
|
#include <math.h> |
| 18 |
+ |
#include <ctype.h> |
| 19 |
|
#include "ezxml.h" |
| 20 |
|
#include "hilbert.h" |
| 21 |
|
#include "bsdf.h" |
| 109 |
|
if ((geom = ezxml_child(wdb, "Geometry")) == NULL || |
| 110 |
|
(mgfstr = ezxml_txt(geom)) == NULL) |
| 111 |
|
return SDEnone; |
| 112 |
+ |
while (isspace(*mgfstr)) |
| 113 |
+ |
++mgfstr; |
| 114 |
+ |
if (!*mgfstr) |
| 115 |
+ |
return SDEnone; |
| 116 |
|
if ((fmt = ezxml_attr(geom, "format")) != NULL && |
| 117 |
|
strcasecmp(fmt, "MGF")) { |
| 118 |
|
sprintf(SDerrorDetail, |
| 171 |
|
} |
| 172 |
|
/* load geometry if present */ |
| 173 |
|
lastErr = SDloadGeometry(sd, ezxml_child(wtl, "Material")); |
| 174 |
< |
if (lastErr) |
| 174 |
> |
if (lastErr) { |
| 175 |
> |
ezxml_free(fl); |
| 176 |
|
return lastErr; |
| 177 |
+ |
} |
| 178 |
|
/* try loading variable resolution data */ |
| 179 |
|
lastErr = SDloadTre(sd, wtl); |
| 180 |
|
/* check our result */ |
| 181 |
< |
switch (lastErr) { |
| 173 |
< |
case SDEformat: |
| 174 |
< |
case SDEdata: |
| 175 |
< |
case SDEsupport: /* possibly we just tried the wrong format */ |
| 181 |
> |
if (lastErr == SDEsupport) /* try matrix BSDF if not tree data */ |
| 182 |
|
lastErr = SDloadMtx(sd, wtl); |
| 183 |
< |
break; |
| 178 |
< |
default: /* variable res. OK else serious error */ |
| 179 |
< |
break; |
| 180 |
< |
} |
| 183 |
> |
|
| 184 |
|
/* done with XML file */ |
| 185 |
|
ezxml_free(fl); |
| 186 |
|
|
| 252 |
|
return; |
| 253 |
|
SDfreeCumulativeCache(df); |
| 254 |
|
for (n = df->ncomp; n-- > 0; ) |
| 255 |
< |
(*df->comp[n].func->freeSC)(df->comp[n].dist); |
| 255 |
> |
if (df->comp[n].dist != NULL) |
| 256 |
> |
(*df->comp[n].func->freeSC)(df->comp[n].dist); |
| 257 |
|
free(df); |
| 258 |
|
} |
| 259 |
|
|
| 425 |
|
cd = (*sdc->func->getCDist)(inVec, sdc); |
| 426 |
|
if (cd == NULL) |
| 427 |
|
return SDEmemory; |
| 428 |
< |
if (cd->cTotal <= 1e-7) { /* anything to sample? */ |
| 428 |
> |
if (cd->cTotal <= 1e-6) { /* anything to sample? */ |
| 429 |
|
sv->spec = c_dfcolor; |
| 430 |
|
sv->cieY = .0; |
| 431 |
|
memset(ioVec, 0, 3*sizeof(double)); |
| 500 |
|
SDError ec; |
| 501 |
|
int i; |
| 502 |
|
/* check arguments */ |
| 503 |
< |
if ((projSA == NULL) | (v1 == NULL)) |
| 503 |
> |
if ((projSA == NULL) | (v1 == NULL) | (sd == NULL)) |
| 504 |
|
return SDEargument; |
| 505 |
|
/* initialize extrema */ |
| 506 |
|
switch (qflags) { |
| 520 |
|
rdf = sd->rf; |
| 521 |
|
else |
| 522 |
|
rdf = sd->rb; |
| 523 |
< |
tdf = NULL; /* transmitted component? */ |
| 524 |
< |
if (v2 != NULL && v1[2] > 0 ^ v2[2] > 0) { |
| 525 |
< |
rdf = NULL; |
| 526 |
< |
tdf = sd->tf; |
| 527 |
< |
} |
| 523 |
> |
tdf = sd->tf; |
| 524 |
> |
if (v2 != NULL) /* bidirectional? */ |
| 525 |
> |
if (v1[2] > 0 ^ v2[2] > 0) |
| 526 |
> |
rdf = NULL; |
| 527 |
> |
else |
| 528 |
> |
tdf = NULL; |
| 529 |
|
ec = SDEdata; /* run through components */ |
| 530 |
|
for (i = (rdf==NULL) ? 0 : rdf->ncomp; i--; ) { |
| 531 |
|
ec = (*rdf->comp[i].func->queryProjSA)(projSA, v1, v2, |
| 687 |
|
} |
| 688 |
|
sv->cieY += cdarr[i]->cTotal; |
| 689 |
|
} |
| 690 |
< |
if (sv->cieY <= 1e-7) { /* anything to sample? */ |
| 690 |
> |
if (sv->cieY <= 1e-6) { /* anything to sample? */ |
| 691 |
|
sv->cieY = .0; |
| 692 |
|
memset(ioVec, 0, 3*sizeof(double)); |
| 693 |
|
return SDEnone; |
| 817 |
|
|
| 818 |
|
#include "standard.h" |
| 819 |
|
#include "paths.h" |
| 815 |
– |
#include <ctype.h> |
| 820 |
|
|
| 821 |
|
#define MAXLATS 46 /* maximum number of latitudes */ |
| 822 |
|
|
| 936 |
|
{ |
| 937 |
|
ANGLE_BASIS *ab = (ANGLE_BASIS *)p; |
| 938 |
|
int li, ndx; |
| 939 |
< |
double pol, azi, d; |
| 939 |
> |
double pol, azi; |
| 940 |
|
|
| 941 |
|
if ((v[2] < -1.0) | (v[2] > 1.0)) |
| 942 |
|
return(-1); |
| 1176 |
|
) |
| 1177 |
|
{ |
| 1178 |
|
double *omega_iarr, *omega_oarr; |
| 1179 |
< |
double dom, contrib, hemi_total, full_total; |
| 1179 |
> |
double dom, hemi_total, full_total; |
| 1180 |
|
int nneg; |
| 1181 |
|
FVECT v; |
| 1182 |
|
int i, o; |
| 1326 |
|
error(WARNING, errmsg); |
| 1327 |
|
ezxml_free(fl); |
| 1328 |
|
return(NULL); |
| 1329 |
< |
} |
| 1330 |
< |
load_angle_basis(ezxml_child(ezxml_child(wtl, |
| 1331 |
< |
"DataDefinition"), "AngleBasis")); |
| 1329 |
> |
} |
| 1330 |
> |
for (wld = ezxml_child(ezxml_child(wtl, |
| 1331 |
> |
"DataDefinition"), "AngleBasis"); |
| 1332 |
> |
wld != NULL; wld = wld->next) |
| 1333 |
> |
load_angle_basis(wld); |
| 1334 |
|
dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data)); |
| 1335 |
|
load_geometry(dp, ezxml_child(wtl, "Material")); |
| 1336 |
|
for (wld = ezxml_child(wtl, "WavelengthData"); |