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 */ |
223 |
|
df->maxHemi = .0; |
224 |
|
df->ncomp = nc; |
225 |
|
memset(df->comp, 0, nc*sizeof(SDComponent)); |
226 |
+ |
return df; |
227 |
+ |
} |
228 |
+ |
|
229 |
+ |
/* Add component(s) to spectral distribution function */ |
230 |
+ |
SDSpectralDF * |
231 |
+ |
SDaddComponent(SDSpectralDF *odf, int nadd) |
232 |
+ |
{ |
233 |
+ |
SDSpectralDF *df; |
234 |
+ |
|
235 |
+ |
if (odf == NULL) |
236 |
+ |
return SDnewSpectralDF(nadd); |
237 |
+ |
if (nadd <= 0) |
238 |
+ |
return odf; |
239 |
+ |
df = (SDSpectralDF *)realloc(odf, sizeof(SDSpectralDF) + |
240 |
+ |
(odf->ncomp+nadd-1)*sizeof(SDComponent)); |
241 |
+ |
if (df == NULL) { |
242 |
+ |
sprintf(SDerrorDetail, |
243 |
+ |
"Cannot add %d component(s) to spectral DF", nadd); |
244 |
+ |
SDfreeSpectralDF(odf); |
245 |
+ |
return NULL; |
246 |
+ |
} |
247 |
+ |
memset(df->comp+df->ncomp, 0, nadd*sizeof(SDComponent)); |
248 |
+ |
df->ncomp += nadd; |
249 |
|
return df; |
250 |
|
} |
251 |
|
|