commit 7559aa18de144147963551c9a4c9f37e3dc1fbd0
parent 980c19e338c6ad4255d4ddcc07a3f540d738413b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 4 May 2017 10:17:20 +0200
Merge branch 'feature_atmosphere' into develop
Diffstat:
11 files changed, 118 insertions(+), 170 deletions(-)
diff --git a/src/ssol.h b/src/ssol.h
@@ -637,7 +637,7 @@ ssol_scene_compute_aabb
/* Detach all the instances from the scene and release the reference that the
* scene takes onto them.
- * Also detach the attached sun if any. */
+ * Also detach the attached sun and atmosphere if any. */
SSOL_API res_T
ssol_scene_clear
(struct ssol_scene* scn);
@@ -1044,7 +1044,7 @@ ssol_sun_set_buie_param
******************************************************************************/
/* The atmosphere describes absorption along the light paths */
SSOL_API res_T
-ssol_atmosphere_create_uniform
+ssol_atmosphere_create
(struct ssol_device* dev,
struct ssol_atmosphere** atmosphere);
@@ -1056,11 +1056,10 @@ SSOL_API res_T
ssol_atmosphere_ref_put
(struct ssol_atmosphere* atmosphere);
-/* List of per wavelength power of the sun */
SSOL_API res_T
-ssol_atmosphere_set_uniform_absorption
+ssol_atmosphere_set_absorption
(struct ssol_atmosphere* atmosphere,
- struct ssol_spectrum* spectrum);
+ struct ssol_data* absorption);
/*******************************************************************************
* Estimator API - Describe the state of a simulation.
diff --git a/src/ssol_atmosphere.c b/src/ssol_atmosphere.c
@@ -33,48 +33,63 @@ atmosphere_release(ref_T* ref)
ASSERT(ref);
dev = atmosphere->dev;
ASSERT(dev && dev->allocator);
- switch (atmosphere->type) {
- case ATMOS_UNIFORM:
- if (atmosphere->data.uniform.spectrum)
- SSOL(spectrum_ref_put(atmosphere->data.uniform.spectrum));
- break;
- default: FATAL("Unreachable code\n"); break;
- }
+ ssol_data_clear(&atmosphere->absorption);
MEM_RM(dev->allocator, atmosphere);
SSOL(device_ref_put(dev));
}
+static INLINE int
+check_absorption(const struct ssol_data* absorption)
+{
+ if(!absorption) return 0;
+
+ /* Check absorptivity in [0, INF) */
+ switch(absorption->type) {
+ case SSOL_DATA_REAL:
+ if(absorption->value.real < 0 || absorption->value.real > 1)
+ return 0;
+ break;
+ case SSOL_DATA_SPECTRUM:
+ if(!absorption->value.spectrum
+ || !spectrum_check_data(absorption->value.spectrum, 0, 1))
+ return 0;
+ break;
+ default: FATAL("Unreachable code\n"); break;
+ }
+
+ return 1;
+}
+
/*******************************************************************************
* Exported ssol_atmosphere functions
******************************************************************************/
res_T
-ssol_atmosphere_create_uniform
+ssol_atmosphere_create
(struct ssol_device* dev,
struct ssol_atmosphere** out_atmosphere)
{
struct ssol_atmosphere* atmosphere = NULL;
res_T res = RES_OK;
- if (!dev || !out_atmosphere) {
+ if(!dev || !out_atmosphere) {
return RES_BAD_ARG;
}
atmosphere = (struct ssol_atmosphere*)MEM_CALLOC
(dev->allocator, 1, sizeof(struct ssol_atmosphere));
- if (!atmosphere) {
+ if(!atmosphere) {
res = RES_MEM_ERR;
goto error;
}
SSOL(device_ref_get(dev));
atmosphere->dev = dev;
- atmosphere->type = ATMOS_UNIFORM;
ref_init(&atmosphere->ref);
exit:
- if (out_atmosphere) *out_atmosphere = atmosphere;
+ if(out_atmosphere) *out_atmosphere = atmosphere;
return res;
error:
- if (atmosphere) {
+ if(atmosphere) {
SSOL(atmosphere_ref_put(atmosphere));
atmosphere = NULL;
}
@@ -85,8 +100,7 @@ res_T
ssol_atmosphere_ref_get
(struct ssol_atmosphere* atmosphere)
{
- if (!atmosphere)
- return RES_BAD_ARG;
+ if(!atmosphere) return RES_BAD_ARG;
ref_get(&atmosphere->ref);
return RES_OK;
}
@@ -95,27 +109,19 @@ res_T
ssol_atmosphere_ref_put
(struct ssol_atmosphere* atmosphere)
{
- if (!atmosphere)
- return RES_BAD_ARG;
+ if(!atmosphere) return RES_BAD_ARG;
ref_put(&atmosphere->ref, atmosphere_release);
return RES_OK;
}
res_T
-ssol_atmosphere_set_uniform_absorption
+ssol_atmosphere_set_absorption
(struct ssol_atmosphere* atmosphere,
- struct ssol_spectrum* spectrum)
+ struct ssol_data* absorption)
{
- struct atm_uniform* uni;
- if (!atmosphere || !spectrum || atmosphere->type != ATMOS_UNIFORM)
+ if(!atmosphere || !absorption || !check_absorption(absorption))
return RES_BAD_ARG;
- uni = &atmosphere->data.uniform;
- if (spectrum == uni->spectrum) /* no change */
- return RES_OK;
- if (uni->spectrum)
- SSOL(spectrum_ref_put(uni->spectrum));
- SSOL(spectrum_ref_get(spectrum));
- uni->spectrum = spectrum;
+ ssol_data_copy(&atmosphere->absorption, absorption);
return RES_OK;
}
@@ -123,13 +129,11 @@ ssol_atmosphere_set_uniform_absorption
* Local functions
******************************************************************************/
double
-atmosphere_uniform_get_absorption
+atmosphere_get_absorption
(const struct ssol_atmosphere* atmosphere,
const double wavelength)
{
- const struct ssol_spectrum* spectrum;
- ASSERT(atmosphere && atmosphere->type == ATMOS_UNIFORM && wavelength >= 0);
- spectrum = atmosphere->data.uniform.spectrum;
- return spectrum_interpolate(spectrum, wavelength);
+ ASSERT(atmosphere && wavelength >= 0);
+ return ssol_data_get_value(&atmosphere->absorption, wavelength);
}
diff --git a/src/ssol_atmosphere_c.h b/src/ssol_atmosphere_c.h
@@ -21,28 +21,16 @@
struct ssol_scene;
-enum atmosphere_type {
- ATMOS_UNIFORM,
- ATMOS_TYPES_COUNT__
-};
-
-struct atm_uniform {
- struct ssol_spectrum* spectrum;
-};
-
struct ssol_atmosphere {
- enum atmosphere_type type;
struct ssol_scene* scene_attachment;
- union {
- struct atm_uniform uniform;
- } data;
+ struct ssol_data absorption;
struct ssol_device* dev;
ref_T ref;
};
extern LOCAL_SYM double
-atmosphere_uniform_get_absorption
+atmosphere_get_absorption
(const struct ssol_atmosphere* atmosphere,
const double wavelength);
diff --git a/src/ssol_data.c b/src/ssol_data.c
@@ -62,17 +62,17 @@ ssol_data_copy(struct ssol_data* dst, const struct ssol_data* src)
{
ASSERT(dst && src);
if(dst == src) return dst;
- dst->type = src->type;
- switch(dst->type) {
+ ssol_data_clear(dst);
+ switch(src->type) {
case SSOL_DATA_REAL:
dst->value.real = src->value.real;
break;
case SSOL_DATA_SPECTRUM:
- dst->value.spectrum = src->value.spectrum;
- SSOL(spectrum_ref_get(dst->value.spectrum));
+ ssol_data_set_spectrum(dst, src->value.spectrum);
break;
default: FATAL("Unreachable code.\n"); break;
}
+ dst->type = src->type;
return dst;
}
diff --git a/src/ssol_scene.c b/src/ssol_scene.c
@@ -542,17 +542,6 @@ scene_check(const struct ssol_scene* scene, const char* caller)
log_error(scene->dev, "%s: sun's DNI undefined.\n", caller);
return RES_BAD_ARG;
}
-
- if(scene->atmosphere) {
- int i;
- ASSERT(scene->atmosphere->type == ATMOS_UNIFORM);
- i = spectrum_includes
- (scene->atmosphere->data.uniform.spectrum, scene->sun->spectrum);
- if(!i) {
- log_error(scene->dev, "%s: sun/atmosphere spectra mismatch.\n", caller);
- return RES_BAD_ARG;
- }
- }
return RES_OK;
}
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -746,7 +746,7 @@ trace_radiative_path
if(scn->atmosphere) {
/* Assume that the path starts from an uniform atmosphere */
ssol_data_set_real(&medium.absorptivity,
- atmosphere_uniform_get_absorption(scn->atmosphere, pt.wl));
+ atmosphere_get_absorption(scn->atmosphere, pt.wl));
}
if(tracker) {
diff --git a/src/ssol_spectrum.c b/src/ssol_spectrum.c
@@ -41,20 +41,6 @@ spectrum_release(ref_T* ref)
}
static int
-spectrum_includes_point
- (const struct ssol_spectrum* spectrum,
- const double wavelength)
-{
- const double* data;
- size_t sz;
- ASSERT(spectrum);
- sz = darray_double_size_get(&spectrum->wavelengths);
- ASSERT(sz && sz == darray_double_size_get(&spectrum->intensities));
- data = darray_double_cdata_get(&spectrum->wavelengths);
- return data[0] <= wavelength && wavelength <= data[sz - 1];
-}
-
-static int
eq_dbl(const void* key, const void* base)
{
const double k = *(const double*) key;
@@ -67,21 +53,6 @@ eq_dbl(const void* key, const void* base)
/*******************************************************************************
* Local ssol_spectrum functions
******************************************************************************/
-int
-spectrum_includes
- (const struct ssol_spectrum* reference,
- const struct ssol_spectrum* tested)
-{
- const double* test_data;
- size_t test_sz;
- ASSERT(reference && tested);
-
- test_sz = darray_double_size_get(&tested->wavelengths);
- test_data = darray_double_cdata_get(&tested->wavelengths);
- return spectrum_includes_point(reference, test_data[0])
- && spectrum_includes_point(reference, test_data[test_sz - 1]);
-}
-
double
spectrum_interpolate
(const struct ssol_spectrum* spectrum, const double wavelength)
@@ -121,11 +92,19 @@ int
spectrum_check_data
(const struct ssol_spectrum* spectrum, const double lower, const double upper)
{
- size_t i;
+ size_t sz, i;
+ double current_wl = 0;
ASSERT(spectrum && lower <= upper);
- FOR_EACH(i, 0, darray_double_size_get(&spectrum->intensities)) {
+ sz = darray_double_size_get(&spectrum->intensities);
+ if(!sz) return 0;
+ if(sz != darray_double_size_get(&spectrum->wavelengths)) return 0;
+ FOR_EACH(i, 0, sz) {
+ const double wl = darray_double_cdata_get(&spectrum->wavelengths)[i];
const double data = darray_double_cdata_get(&spectrum->intensities)[i];
if(data < lower || data > upper) return 0;
+ if(wl <= 0) return 0;
+ if(wl <= current_wl) return 0;
+ current_wl = wl;
}
return 1;
}
diff --git a/src/ssol_spectrum_c.h b/src/ssol_spectrum_c.h
@@ -27,12 +27,6 @@ struct ssol_spectrum {
ref_T ref;
};
-/* Check that the `tested' spectrum is included into `reference' */
-extern LOCAL_SYM int
-spectrum_includes
- (const struct ssol_spectrum* reference,
- const struct ssol_spectrum* tested);
-
/* Retrieve the linearly interpolated spectrum intensity for the commited
* wavelength */
extern LOCAL_SYM double
diff --git a/src/test_ssol_atmosphere.c b/src/test_ssol_atmosphere.c
@@ -16,14 +16,25 @@
#include "ssol.h"
#include "test_ssol_utils.h"
+static double wl[3] = { 1, 2, 3 };
+static double ab[3] = { 1, 0.8, 1.1 };
+
+static void
+get_wlen(const size_t i, double* wlen, double* data, void* ctx)
+{
+ (void)ctx;
+ *wlen = wl[i];
+ *data = ab[i];
+}
+
int
main(int argc, char** argv)
{
struct mem_allocator allocator;
struct ssol_device* dev;
- struct ssol_spectrum* spectrum;
- struct ssol_spectrum* spectrum2;
+ struct ssol_data absorption, absorption2;
struct ssol_atmosphere* atm;
+ struct ssol_spectrum* spectrum;
(void) argc, (void) argv;
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
@@ -31,12 +42,15 @@ main(int argc, char** argv)
CHECK(ssol_device_create
(NULL, &allocator, SSOL_NTHREADS_DEFAULT, 0, &dev), RES_OK);
+ absorption2.type = SSOL_DATA_SPECTRUM;
CHECK(ssol_spectrum_create(dev, &spectrum), RES_OK);
- CHECK(ssol_spectrum_create(dev, &spectrum2), RES_OK);
+ CHECK(ssol_spectrum_setup(spectrum, get_wlen, 2, NULL), RES_OK);
+ absorption2.type = SSOL_DATA_SPECTRUM;
+ absorption2.value.spectrum = spectrum;
- CHECK(ssol_atmosphere_create_uniform(NULL, &atm), RES_BAD_ARG);
- CHECK(ssol_atmosphere_create_uniform(dev, NULL), RES_BAD_ARG);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm), RES_OK);
+ CHECK(ssol_atmosphere_create(NULL, &atm), RES_BAD_ARG);
+ CHECK(ssol_atmosphere_create(dev, NULL), RES_BAD_ARG);
+ CHECK(ssol_atmosphere_create(dev, &atm), RES_OK);
CHECK(ssol_atmosphere_ref_get(NULL), RES_BAD_ARG);
CHECK(ssol_atmosphere_ref_get(atm), RES_OK);
@@ -44,17 +58,23 @@ main(int argc, char** argv)
CHECK(ssol_atmosphere_ref_put(NULL), RES_BAD_ARG);
CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(NULL, spectrum), RES_BAD_ARG);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, NULL), RES_BAD_ARG);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, spectrum), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, spectrum2), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, spectrum2), RES_OK);
+ absorption.type = SSOL_DATA_REAL;
+ absorption.value.real = 0.1;
+ CHECK(ssol_atmosphere_set_absorption(NULL, &absorption), RES_BAD_ARG);
+ CHECK(ssol_atmosphere_set_absorption(atm, NULL), RES_BAD_ARG);
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption), RES_OK);
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption), RES_OK);
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption2), RES_OK);
- CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
+ /* absorption values out of range */
+ absorption.value.real = 2;
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption), RES_BAD_ARG);
+ CHECK(ssol_spectrum_setup(spectrum, get_wlen, 3, NULL), RES_OK);
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption2), RES_BAD_ARG);
- CHECK(ssol_spectrum_ref_put(spectrum), RES_OK);
- CHECK(ssol_spectrum_ref_put(spectrum2), RES_OK);
+ CHECK(ssol_spectrum_ref_put(absorption2.value.spectrum), RES_OK);
CHECK(ssol_device_ref_put(dev), RES_OK);
+ CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
diff --git a/src/test_ssol_scene.c b/src/test_ssol_scene.c
@@ -45,17 +45,6 @@ instance_func(struct ssol_instance* inst, void* context)
return RES_OK;
}
-static void
-get_wlen(const size_t i, double* wlen, double* data, void* ctx)
-{
- double wavelengths[3] = { 10, 20, 30 };
- double intensities[3] = { 1, 2.1, 1.5 };
- CHECK(i < 3, 1);
- (void)ctx;
- *wlen = wavelengths[i];
- *data = intensities[i];
-}
-
int
main(int argc, char** argv)
{
@@ -87,9 +76,9 @@ main(int argc, char** argv)
struct ssol_sun* sun2;
struct ssol_scene* scene;
struct ssol_scene* scene2;
- struct ssol_spectrum* spectrum;
struct ssol_atmosphere* atm;
struct ssol_atmosphere* atm2;
+ struct ssol_data absorption;
struct ssol_vertex_data vdata;
struct scene_ctx ctx;
struct desc desc;
@@ -179,12 +168,12 @@ main(int argc, char** argv)
CHECK(ssol_scene_detach_sun(scene, sun), RES_BAD_ARG);
CHECK(ssol_scene_detach_sun(scene2, sun), RES_OK);
- CHECK(ssol_spectrum_create(dev, &spectrum), RES_OK);
- CHECK(ssol_spectrum_setup(spectrum, get_wlen, 3, NULL), RES_OK);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, spectrum), RES_OK);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm2), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm2, spectrum), RES_OK);
+ CHECK(ssol_atmosphere_create(dev, &atm), RES_OK);
+ absorption.type = SSOL_DATA_REAL;
+ absorption.value.real = 0.1;
+ CHECK(ssol_atmosphere_set_absorption(atm, &absorption), RES_OK);
+ CHECK(ssol_atmosphere_create(dev, &atm2), RES_OK);
+ CHECK(ssol_atmosphere_set_absorption(atm2, &absorption), RES_OK);
CHECK(ssol_scene_attach_atmosphere(NULL, atm), RES_BAD_ARG);
CHECK(ssol_scene_attach_atmosphere(scene, NULL), RES_BAD_ARG);
@@ -266,7 +255,6 @@ main(int argc, char** argv)
CHECK(ssol_object_ref_put(object), RES_OK);
CHECK(ssol_shape_ref_put(shape), RES_OK);
CHECK(ssol_sun_ref_put(sun), RES_OK);
- CHECK(ssol_spectrum_ref_put(spectrum), RES_OK);
CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
CHECK(ssol_atmosphere_ref_put(atm2), RES_OK);
CHECK(ssol_material_ref_put(material), RES_OK);
diff --git a/src/test_ssol_solver1.c b/src/test_ssol_solver1.c
@@ -66,7 +66,8 @@ main(int argc, char** argv)
struct ssol_sun* sun;
struct ssol_sun* sun_mono;
struct ssol_spectrum* spectrum;
- struct ssol_spectrum* abs;
+ struct ssol_spectrum* abs_spectrum;
+ struct ssol_data abs_data;
struct ssol_atmosphere* atm;
struct ssol_estimator* estimator;
struct ssol_mc_sampled sampled;
@@ -79,7 +80,6 @@ main(int argc, char** argv)
double dir[3];
double wavelengths[3] = { 1, 2, 3 };
double intensities[3] = { 1, 0.8, 1 };
- double mismatch[3] = { 1.5, 3.5, 0 };
double ka[3] = { 0, 0, 0 };
double mono = 1.21;
double transform1[12]; /* 3x4 column major matrix */
@@ -287,20 +287,6 @@ main(int argc, char** argv)
CHECK(ssol_instance_set_receiver(target, SSOL_FRONT, 0), RES_OK);
CHECK(ssol_estimator_ref_put(estimator), RES_OK);
- /* Spectra mismatch */
- desc.wavelengths = mismatch;
- desc.intensities = ka;
- desc.count = 2;
- CHECK(ssol_spectrum_create(dev, &abs), RES_OK);
- CHECK(ssol_spectrum_setup(abs, get_wlen, 2, &desc), RES_OK);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, abs), RES_OK);
- CHECK(ssol_scene_attach_atmosphere(scene, atm), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
- CHECK(ssol_scene_detach_atmosphere(scene, atm), RES_OK);
- CHECK(ssol_spectrum_ref_put(abs), RES_OK);
- CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
-
/* Can sample any geometry; variance is high */
NCHECK(tmp = tmpfile(), 0);
#define N__ 10000
@@ -379,13 +365,10 @@ main(int argc, char** argv)
CHECK(ssol_estimator_ref_put(estimator), RES_OK);
/* Check atmosphere model; with no absorption result is unchanged */
- desc.wavelengths = wavelengths;
- desc.intensities = ka;
- desc.count = 3;
- CHECK(ssol_spectrum_create(dev, &abs), RES_OK);
- CHECK(ssol_spectrum_setup(abs, get_wlen, 3, &desc), RES_OK);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, abs), RES_OK);
+ CHECK(ssol_atmosphere_create(dev, &atm), RES_OK);
+ abs_data.type = SSOL_DATA_REAL;
+ abs_data.value.real = 0;
+ CHECK(ssol_atmosphere_set_absorption(atm, &abs_data), RES_OK);
CHECK(ssol_scene_attach_atmosphere(scene, atm), RES_OK);
NCHECK(tmp = tmpfile(), 0);
@@ -398,7 +381,6 @@ main(int argc, char** argv)
CHECK(eq_eps(m, 4 * DNI_cos, MMAX(4 * DNI_cos * 1e-2, std)), 1);
CHECK(eq_eps(std, 0, 1e-4), 1);
CHECK(ssol_scene_detach_atmosphere(scene, atm), RES_OK);
- CHECK(ssol_spectrum_ref_put(abs), RES_OK);
CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
CHECK(ssol_estimator_get_mc_global(estimator, &mc_global), RES_OK);
printf("Shadows = %g +/- %g; ", mc_global.shadowed.E, mc_global.shadowed.SE);
@@ -431,11 +413,11 @@ main(int argc, char** argv)
CHECK(ssol_scene_attach_instance(scene, heliostat2), RES_OK);
#define KA 0.03
- ka[0] = ka[1] = ka[2] = KA;
- CHECK(ssol_spectrum_create(dev, &abs), RES_OK);
- CHECK(ssol_spectrum_setup(abs, get_wlen, 3, &desc), RES_OK);
- CHECK(ssol_atmosphere_create_uniform(dev, &atm), RES_OK);
- CHECK(ssol_atmosphere_set_uniform_absorption(atm, abs), RES_OK);
+ abs_data.value.real = KA;
+ CHECK(ssol_spectrum_create(dev, &abs_spectrum), RES_OK);
+ CHECK(ssol_spectrum_setup(abs_spectrum, get_wlen, 3, &desc), RES_OK);
+ CHECK(ssol_atmosphere_create(dev, &atm), RES_OK);
+ CHECK(ssol_atmosphere_set_absorption(atm, &abs_data), RES_OK);
CHECK(ssol_scene_attach_atmosphere(scene, atm), RES_OK);
CHECK(ssol_instance_set_receiver(target, SSOL_FRONT, 1), RES_OK);
@@ -547,8 +529,13 @@ main(int argc, char** argv)
ka[1] = 0.2; ka[0] = ka[2] = 0.1;
desc.wavelengths = wavelengths;
desc.intensities = ka;
- desc.count = 2;
- CHECK(ssol_spectrum_setup(abs, get_wlen, 2, &desc), RES_OK);
+ desc.count = 3;
+ CHECK(ssol_spectrum_setup(abs_spectrum, get_wlen, 3, &desc), RES_OK);
+ CHECK(ssol_spectrum_setup(abs_spectrum, get_wlen, 2, &desc), RES_OK);
+ abs_data.type = SSOL_DATA_SPECTRUM;
+ abs_data.value.spectrum = abs_spectrum;
+ CHECK(ssol_atmosphere_set_absorption(atm, &abs_data), RES_OK);
+
NCHECK(tmp = tmpfile(), 0);
CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_estimator_get_realisation_count(estimator, &count), RES_OK);
@@ -587,10 +574,10 @@ main(int argc, char** argv)
CHECK(ssol_material_ref_put(v_mtl), RES_OK);
CHECK(ssol_device_ref_put(dev), RES_OK);
CHECK(ssol_scene_ref_put(scene), RES_OK);
- CHECK(ssol_spectrum_ref_put(abs), RES_OK);
CHECK(ssol_atmosphere_ref_put(atm), RES_OK);
CHECK(ssol_estimator_ref_put(estimator), RES_OK);
CHECK(ssol_spectrum_ref_put(spectrum), RES_OK);
+ CHECK(ssol_spectrum_ref_put(abs_spectrum), RES_OK);
CHECK(ssol_sun_ref_put(sun), RES_OK);
CHECK(ssol_sun_ref_put(sun_mono), RES_OK);
CHECK(ssp_rng_ref_put(rng), RES_OK);