star-schiff

Library for estimating radiative properties
git clone git://git.meso-star.com/star-schiff.git
Log | Files | Refs | README | LICENSE

commit 0889a42b7073b16a470157e8755f8f85219b96d2
parent 7855c7c4d96c776016bd5623ce6ccfaa3c49fea6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 19 Oct 2015 15:15:12 +0200

Add some minor comments

Diffstat:
Msrc/sschiff.h | 4+++-
Msrc/sschiff_estimator.c | 18++++++++++++------
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/sschiff.h b/src/sschiff.h @@ -56,7 +56,7 @@ struct s3d_device; struct s3d_shape; struct ssp_rng; -/* Optical properties of a material handled by the Schiff integrator. */ +/* Optical properties of a material handled by the Schiff integrator */ struct sschiff_material_properties { double medium_refractive_index; double relative_real_refractive_index; @@ -75,6 +75,7 @@ struct sschiff_material { static const struct sschiff_material SSCHIFF_NULL_MATERIAL = { NULL, NULL }; +/* User defined distribution of the geometries */ struct sschiff_geometry_distribution { res_T (*sample) /* Sample a geometry i.e. a shape and its material */ (struct ssp_rng* rng, @@ -159,6 +160,7 @@ sschiff_estimator_get_average_projected_area (struct sschiff_estimator* estimator, struct sschiff_estimator_status* status); +/* TODO Not implemented yet */ SSCHIFF_API res_T sschiff_estimator_get_phase_function (struct sschiff_estimator* estimator, diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c @@ -221,9 +221,12 @@ compute_monte_carlo_weight /* Compute the origin of the projection plane */ f3_add(org, pos, f3_mulf(org, axis_z, lower[2])); - /* Uniformly sample a position onto the projection plane and use it as the - * origin of the ray to trace */ + FOR_EACH(i, 0, WEIGHTS_COUNT) + weights[i] = 0; + do { + /* Uniformly sample a position onto the projection plane and use it as the + * origin of the ray to trace */ sample[0] = ssp_rng_uniform_double(rng, -1.0, 1.0); sample[1] = ssp_rng_uniform_double(rng, -1.0, 1.0); f3_mulf(x, axis_x, (float)sample[0]); @@ -232,14 +235,13 @@ compute_monte_carlo_weight S3D(scene_trace_ray(scn, ray_org, axis_z, range, &hit)); - FOR_EACH(i, 0, WEIGHTS_COUNT) weights[i] = 0; if(!S3D_HIT_NONE(&hit)) { double n_r, k_r; double n_e, k_e, lambda_e; double path_length; res = compute_path_length(dev, scn, &hit, ray_org, axis_z, &path_length); - if(res != RES_OK) { + if(res != RES_OK) { /* Handle numerical/geometry issues */ ++nfailures; continue; } @@ -264,6 +266,7 @@ compute_monte_carlo_weight weights[WEIGHT_AVERAGE_PROJECTED_AREA] = rcp_pdf; } } while(res != RES_OK && nfailures < MAX_FAILURES); + if(res != RES_OK) { log_error(dev, "Too many failures in computing the radiative path length. The sampled geometry\n" @@ -272,7 +275,7 @@ compute_monte_carlo_weight return res; } -/* Cast rays into the RT volume */ +/* Dump a thumbnail of the sampled geometry in given sampled direction */ static INLINE void draw_thumbnail (struct s3d_scene* scn, @@ -420,8 +423,8 @@ radiative_properties FOR_EACH(i, 0, WEIGHTS_COUNT) weights_dirs[i] += weights[i]; #if 0 - /* Compute an image of the shape transformed in the footprint space */ { + /* Compute an image of the shape transformed in the footprint space */ char thumb_name[64]; sprintf(thumb_name, "%d_%lu.ppm", istep, idir); draw_thumbnail(scene, basis, centroid, lower, upper, thumb_name); @@ -553,6 +556,7 @@ sschiff_integrate struct sschiff_material material = SSCHIFF_NULL_MATERIAL; struct sschiff_material_properties props; + /* Sample a geometry, i.e. a shape and its associated material */ res = distrib->sample(rng, &material, shape, distrib->context); if(res != RES_OK) { log_error(dev, "Error in sampling a Schiff geometry.\n"); @@ -560,8 +564,10 @@ sschiff_integrate } material.get_property(material.material, wavelength, &props); + /* Build the Star-3D representation of the sampled shape */ S3D(scene_begin_session(scene, S3D_TRACE)); + /* Schiff Estimation */ res = radiative_properties(dev, rng, (int)i, wavelength, sampled_directions_count, scene, &props, estimator->accums); if(res != RES_OK) goto error;