htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 5d0b7cfc06ac55dbb1c9cb15aae397903a57494b
parent 9805c7c9e9308f16016a49dc853b4fdadfe00889
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 24 Jul 2018 15:20:01 +0200

Fix several minor issues

Diffstat:
Msrc/htrdr.c | 27++++++++++++++++++---------
Msrc/htrdr_args.h | 2+-
Msrc/htrdr_draw_radiance_sw.c | 3++-
Msrc/htrdr_sky.c | 2+-
Msrc/htrdr_sun.c | 2+-
5 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/htrdr.c b/src/htrdr.c @@ -145,6 +145,7 @@ static void dump_buffer(struct htrdr_buffer* buf, FILE* output) { struct htrdr_buffer_layout buf_layout; + double max_val = -DBL_MAX; size_t x, y; ASSERT(buf && output); @@ -158,7 +159,15 @@ dump_buffer(struct htrdr_buffer* buf, FILE* output) FOR_EACH(x, 0, buf_layout.width) { const struct htrdr_accum* acc = htrdr_buffer_at(buf, x, y); const double E = acc->nweights ? acc->sum_weights/(double)acc->nweights:0; - const uint16_t val_ui16 = (uint16_t)(E * 65535.0 + 0.5/*round*/); + max_val = MMAX(E, max_val); + } + } + FOR_EACH(y, 0, buf_layout.height) { + FOR_EACH(x, 0, buf_layout.width) { + const struct htrdr_accum* acc = htrdr_buffer_at(buf, x, y); + const double E = acc->nweights ? acc->sum_weights/(double)acc->nweights:0; + const double En = E / (double)max_val; + const uint16_t val_ui16 = (uint16_t)(En * 65535.0 + 0.5/*round*/); fprintf(output, "%u %u %u\n", val_ui16, val_ui16, val_ui16); } } @@ -239,6 +248,13 @@ htrdr_init htrdr->nthreads = MMIN(args->nthreads, (unsigned)omp_get_num_procs()); htrdr->spp = args->image.spp; + if(!args->output) { + htrdr->output = stdout; + } else { + res = open_output_stream(htrdr, args); + if(res != RES_OK) goto error; + } + res = svx_device_create (&htrdr->logger, htrdr->allocator, args->verbose, &htrdr->svx); if(res != RES_OK) { @@ -257,7 +273,7 @@ htrdr_init (double)args->image.definition[0] / (double)args->image.definition[1]; res = htrdr_camera_create(htrdr, args->camera.pos, args->camera.tgt, - args->camera.up, proj_ratio, args->camera.fov_x, &htrdr->cam); + args->camera.up, proj_ratio, MDEG2RAD(args->camera.fov_x), &htrdr->cam); if(res != RES_OK) goto error; res = htrdr_buffer_create(htrdr, @@ -303,13 +319,6 @@ htrdr_init res = setup_geometry(htrdr, args->filename_obj); if(res != RES_OK) goto error; - if(!args->output) { - htrdr->output = stdout; - } else { - res = open_output_stream(htrdr, args); - if(res != RES_OK) goto error; - } - exit: return res; error: diff --git a/src/htrdr_args.h b/src/htrdr_args.h @@ -71,7 +71,7 @@ struct htrdr_args { {32, 32}, /* image definition */ \ 1 /* #samples per pixel */ \ }, \ - {0, 0, -1}, /* Main direction */ \ + {0, 0, 1}, /* Main direction */ \ (unsigned)~0, /* #threads */ \ 0, /* Force overwriting */ \ 0, /* dump VTK */ \ diff --git a/src/htrdr_draw_radiance_sw.c b/src/htrdr_draw_radiance_sw.c @@ -14,6 +14,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "htrdr.h" +#include "htrdr_c.h" #include "htrdr_buffer.h" #include "htrdr_camera.h" #include "htrdr_solve.h" @@ -93,7 +94,7 @@ draw_tile /* Compute the radiance that reach the pixel through the ray */ weight = htrdr_compute_radiance_sw - (htrdr, rng, ray_org, ray_dir, -1/*FIXME wavelength*/); + (htrdr, rng, ray_org, ray_dir, SW_WAVELENGTH_MIN/*FIXME wavelength*/); ASSERT(weight >= 0); /* Update the pixel accumulator */ diff --git a/src/htrdr_sky.c b/src/htrdr_sky.c @@ -712,7 +712,7 @@ htrdr_sky_fetch_svx_voxel_property double a, b, data; double gas = 0; double particle = 0; - ASSERT(sky && prop && voxel); + ASSERT(sky && voxel); ASSERT((unsigned)prop < HTRDR_PROPERTIES_COUNT__); ASSERT((unsigned)op < HTRDR_SVX_OPS_COUNT__); (void)sky, (void)wavelength; diff --git a/src/htrdr_sun.c b/src/htrdr_sun.c @@ -100,7 +100,7 @@ htrdr_sun_create(struct htrdr* htrdr, struct htrdr_sun** out_sun) sun->htrdr = htrdr; darray_double_init(htrdr->allocator, &sun->radiances_sw); darray_double_init(htrdr->allocator, &sun->wavenumbers_sw); - sun->half_angle = 4.6524e3; + sun->half_angle = 4.6524e-3; sun->cos_half_angle = cos(sun->half_angle); sun->solid_angle = 2*PI*(1-sun->cos_half_angle); d33_basis(sun->frame, main_dir);