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 |
+ |
|
252 |
|
/* Free cached cumulative distributions for BSDF component */ |
253 |
|
void |
254 |
|
SDfreeCumulativeCache(SDSpectralDF *df) |