solstice

Compute collected power and efficiencies of a solar plant
git clone git://git.meso-star.com/solstice.git
Log | Files | Refs | README | LICENSE

commit b616ce8d0d5a84bb1470927497271fef284a1c38
parent a62512a326f9247c1b7bee49adb5951a345cef10
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue,  6 Dec 2016 16:07:55 +0100

Handle the new ssol_param_buffer API

Diffstat:
Msrc/solstice_material.c | 38+++++++++++++++++++-------------------
Msrc/solstice_object.c | 4++--
2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/solstice_material.c b/src/solstice_material.c @@ -18,6 +18,11 @@ #include <solstice/ssol.h> +struct mirror_param { + double reflectivity; + double roughness; +}; + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -51,10 +56,9 @@ mirror_get_reflectivity const double w[3], double* val) { - const void* p; + const struct mirror_param* param = ssol_param_buffer_get(buf); (void)dev, (void)wavelength, (void)P, (void)Ng, (void)Ns, (void)uv, (void)w; - SSOL(param_buffer_get(buf, "reflectivity", &p)); - *val = *(double*)p; + *val = param->reflectivity; } static void @@ -69,10 +73,9 @@ mirror_get_roughness const double w[3], double* val) { - const void* p; + const struct mirror_param* param = ssol_param_buffer_get(buf); (void)dev, (void)wavelength, (void)P, (void)Ng, (void)Ns, (void)uv, (void)w; - SSOL(param_buffer_get(buf, "roughness", &p)); - *val = *(double*)p; + *val = param->roughness; } static res_T @@ -95,6 +98,7 @@ create_material_mirror struct ssol_mirror_shader shader = SSOL_MIRROR_SHADER_NULL; struct ssol_material* mtl = NULL; struct ssol_param_buffer* pbuf = NULL; + struct mirror_param* param; res_T res = RES_OK; ASSERT(solstice && mirror && out_mtl); @@ -104,27 +108,23 @@ create_material_mirror goto error; } - res = ssol_param_buffer_create(solstice->ssol, &pbuf); + res = ssol_param_buffer_create + (solstice->ssol, sizeof(struct mirror_param), &pbuf); if(res != RES_OK) { fprintf(stderr, "Could not create the Solstice Solver parameter buffer.\n"); goto error; } - res = ssol_param_buffer_set(pbuf, "reflectivity", sizeof(double), - ALIGNOF(double), &mirror->reflectivity); - if(res != RES_OK) { - fprintf(stderr, - "Could not set the mirror reflectivity into the parameter buffer.\n"); + param = ssol_param_buffer_allocate + (pbuf, sizeof(struct mirror_param), ALIGNOF(struct mirror_param)); + if(!param) { + fprintf(stderr, "Could not allocate the mirror parameters.\n"); + res = RES_MEM_ERR; goto error; } - res = ssol_param_buffer_set(pbuf, "roughness", sizeof(double), - ALIGNOF(double), &mirror->roughness); - if(res != RES_OK) { - fprintf(stderr, - "Could not set the material roughness into the parameter buffer.\n"); - goto error; - } + param->reflectivity = mirror->reflectivity; + param->roughness = mirror->roughness; shader.normal = mirror_get_normal; shader.reflectivity = mirror_get_reflectivity; diff --git a/src/solstice_object.c b/src/solstice_object.c @@ -269,13 +269,13 @@ create_ssol_shape_punched_surface res = ssol_shape_create_punched_surface(solstice->ssol, &ssol_shape); if(res != RES_OK) { - fprintf(stderr, "Could not create a Solstice Solver parabol.\n"); + fprintf(stderr, "Could not create a Solstice Solver punched surface.\n"); goto error; } res = ssol_punched_surface_setup(ssol_shape, &punched_surf); if(res != RES_OK) { - fprintf(stderr, "Could not setup the Solstice Solver parabol.\n"); + fprintf(stderr, "Could not setup the Solstice Solver punched surface.\n"); goto error; } exit: