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, |
176 |
|
/* try loading variable resolution data */ |
177 |
|
lastErr = SDloadTre(sd, wtl); |
178 |
|
/* check our result */ |
179 |
< |
switch (lastErr) { |
173 |
< |
case SDEformat: |
174 |
< |
case SDEdata: |
175 |
< |
case SDEsupport: /* possibly we just tried the wrong format */ |
179 |
> |
if (lastErr == SDEsupport) /* try matrix BSDF if not tree data */ |
180 |
|
lastErr = SDloadMtx(sd, wtl); |
181 |
< |
break; |
178 |
< |
default: /* variable res. OK else serious error */ |
179 |
< |
break; |
180 |
< |
} |
181 |
> |
|
182 |
|
/* done with XML file */ |
183 |
|
ezxml_free(fl); |
184 |
|
|
250 |
|
return; |
251 |
|
SDfreeCumulativeCache(df); |
252 |
|
for (n = df->ncomp; n-- > 0; ) |
253 |
< |
(*df->comp[n].func->freeSC)(df->comp[n].dist); |
253 |
> |
if (df->comp[n].dist != NULL) |
254 |
> |
(*df->comp[n].func->freeSC)(df->comp[n].dist); |
255 |
|
free(df); |
256 |
|
} |
257 |
|
|
498 |
|
SDError ec; |
499 |
|
int i; |
500 |
|
/* check arguments */ |
501 |
< |
if ((projSA == NULL) | (v1 == NULL)) |
501 |
> |
if ((projSA == NULL) | (v1 == NULL) | (sd == NULL)) |
502 |
|
return SDEargument; |
503 |
|
/* initialize extrema */ |
504 |
|
switch (qflags) { |
518 |
|
rdf = sd->rf; |
519 |
|
else |
520 |
|
rdf = sd->rb; |
521 |
< |
tdf = NULL; /* transmitted component? */ |
522 |
< |
if (v2 != NULL && v1[2] > 0 ^ v2[2] > 0) { |
523 |
< |
rdf = NULL; |
524 |
< |
tdf = sd->tf; |
525 |
< |
} |
521 |
> |
tdf = sd->tf; |
522 |
> |
if (v2 != NULL) /* bidirectional? */ |
523 |
> |
if (v1[2] > 0 ^ v2[2] > 0) |
524 |
> |
rdf = NULL; |
525 |
> |
else |
526 |
> |
tdf = NULL; |
527 |
|
ec = SDEdata; /* run through components */ |
528 |
|
for (i = (rdf==NULL) ? 0 : rdf->ncomp; i--; ) { |
529 |
|
ec = (*rdf->comp[i].func->queryProjSA)(projSA, v1, v2, |
815 |
|
|
816 |
|
#include "standard.h" |
817 |
|
#include "paths.h" |
815 |
– |
#include <ctype.h> |
818 |
|
|
819 |
|
#define MAXLATS 46 /* maximum number of latitudes */ |
820 |
|
|
934 |
|
{ |
935 |
|
ANGLE_BASIS *ab = (ANGLE_BASIS *)p; |
936 |
|
int li, ndx; |
937 |
< |
double pol, azi, d; |
937 |
> |
double pol, azi; |
938 |
|
|
939 |
|
if ((v[2] < -1.0) | (v[2] > 1.0)) |
940 |
|
return(-1); |
1174 |
|
) |
1175 |
|
{ |
1176 |
|
double *omega_iarr, *omega_oarr; |
1177 |
< |
double dom, contrib, hemi_total, full_total; |
1177 |
> |
double dom, hemi_total, full_total; |
1178 |
|
int nneg; |
1179 |
|
FVECT v; |
1180 |
|
int i, o; |
1324 |
|
error(WARNING, errmsg); |
1325 |
|
ezxml_free(fl); |
1326 |
|
return(NULL); |
1327 |
< |
} |
1328 |
< |
load_angle_basis(ezxml_child(ezxml_child(wtl, |
1329 |
< |
"DataDefinition"), "AngleBasis")); |
1327 |
> |
} |
1328 |
> |
for (wld = ezxml_child(ezxml_child(wtl, |
1329 |
> |
"DataDefinition"), "AngleBasis"); |
1330 |
> |
wld != NULL; wld = wld->next) |
1331 |
> |
load_angle_basis(wld); |
1332 |
|
dp = (struct BSDF_data *)calloc(1, sizeof(struct BSDF_data)); |
1333 |
|
load_geometry(dp, ezxml_child(wtl, "Material")); |
1334 |
|
for (wld = ezxml_child(wtl, "WavelengthData"); |