commit 74fdffe2c6ad99adca85a8aa923961c5ae261524
parent 7860dd659c29871c143e6a0beb5a476027bd73aa
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 20 Mar 2017 15:44:47 +0100
Merge remote-tracking branch 'origin/feature_tracked_paths' into develop
Diffstat:
13 files changed, 366 insertions(+), 32 deletions(-)
diff --git a/src/ssol.h b/src/ssol.h
@@ -66,6 +66,12 @@ enum ssol_side_flag {
SSOL_INVALID_SIDE = BIT(2)
};
+enum ssol_path_type {
+ SSOL_PATH_MISSING, /* The path misses the receivers */
+ SSOL_PATH_SHADOW, /* The path is occluded before the sampled geometry */
+ SSOL_PATH_SUCCESS /* The path contributes to at least one receiver */
+};
+
enum ssol_material_type {
SSOL_MATERIAL_MATTE,
SSOL_MATERIAL_MIRROR,
@@ -298,6 +304,27 @@ struct ssol_instantiated_shaded_shape {
static const struct ssol_instantiated_shaded_shape
SSOL_INSTANTIATED_SHADED_SHAPE_NULL = SSOL_INSTANTIATED_SHADED_SHAPE_NULL__;
+struct ssol_path_tracker {
+ /* Control the length of the path segment starting/ending from/to the
+ * infinite. A value less than zero means for default value */
+ double sun_ray_length;
+ double infinite_ray_length;
+};
+
+#define SSOL_PATH_TRACKER_DEFAULT__ {-1, -1}
+static const struct ssol_path_tracker SSOL_PATH_TRACKER_DEFAULT =
+ SSOL_PATH_TRACKER_DEFAULT__;
+
+struct ssol_path {
+ /* Internal data */
+ const void* path__;
+};
+
+struct ssol_path_vertex {
+ double pos[3]; /* Position */
+ double weight; /* Monte-Carlo weight */
+};
+
struct ssol_mc_result {
double E; /* Expectation */
double V; /* Variance */
@@ -969,6 +996,36 @@ ssol_estimator_get_sampled_area
double* area);
/*******************************************************************************
+ * Tracked paths
+ ******************************************************************************/
+SSOL_API res_T
+ssol_estimator_get_tracked_paths_count
+ (const struct ssol_estimator* estimator,
+ size_t* npaths);
+
+SSOL_API res_T
+ssol_estimator_get_tracked_path
+ (const struct ssol_estimator* estimator,
+ const size_t ipath,
+ struct ssol_path* path);
+
+SSOL_API res_T
+ssol_path_get_vertices_count
+ (const struct ssol_path* path,
+ size_t* nvertices);
+
+SSOL_API res_T
+ssol_path_get_vertex
+ (const struct ssol_path* path,
+ const size_t ivertex,
+ struct ssol_path_vertex* vertex);
+
+SSOL_API res_T
+ssol_path_get_type
+ (const struct ssol_path* path,
+ enum ssol_path_type* type);
+
+/*******************************************************************************
* Per receiver MC estimations
******************************************************************************/
SSOL_API res_T
@@ -998,6 +1055,7 @@ ssol_solve
(struct ssol_scene* scn,
struct ssp_rng* rng,
const size_t realisations_count,
+ const struct ssol_path_tracker* tracker, /* NULL<=>Do not record the paths */
FILE* output, /* May be NULL <=> does not ouput ssol_receiver_data */
struct ssol_estimator** estimator);
diff --git a/src/ssol_estimator.c b/src/ssol_estimator.c
@@ -20,9 +20,10 @@
#include "ssol_device_c.h"
#include "ssol_instance_c.h"
-#include <rsys/rsys.h>
+#include <rsys/double3.h>
#include <rsys/mem_allocator.h>
#include <rsys/ref_count.h>
+#include <rsys/rsys.h>
#include <math.h>
@@ -79,6 +80,7 @@ estimator_release(ref_T* ref)
dev = estimator->dev;
htable_receiver_release(&estimator->mc_receivers);
htable_sampled_release(&estimator->mc_sampled);
+ darray_path_release(&estimator->paths);
ASSERT(dev && dev->allocator);
MEM_RM(dev->allocator, estimator);
SSOL(device_ref_put(dev));
@@ -202,6 +204,60 @@ ssol_estimator_get_sampled_area
return RES_OK;
}
+res_T
+ssol_estimator_get_tracked_paths_count
+ (const struct ssol_estimator* estimator, size_t* npaths)
+{
+ if(!estimator || !npaths) return RES_BAD_ARG;
+ *npaths = darray_path_size_get(&estimator->paths);
+ return RES_OK;
+}
+
+res_T
+ssol_estimator_get_tracked_path
+ (const struct ssol_estimator* estimator,
+ const size_t ipath,
+ struct ssol_path* path)
+{
+ if(!estimator || ipath >= darray_path_size_get(&estimator->paths) || !path)
+ return RES_BAD_ARG;
+ path->path__ = darray_path_cdata_get(&estimator->paths) + ipath;
+ return RES_OK;
+}
+
+res_T
+ssol_path_get_vertices_count(const struct ssol_path* path, size_t* nvertices)
+{
+ const struct path* p;
+ if(!path || !nvertices) return RES_BAD_ARG;
+ p = path->path__;
+ *nvertices = darray_path_vertex_size_get(&p->vertices);
+ return RES_OK;
+}
+
+res_T
+ssol_path_get_vertex
+ (const struct ssol_path* path,
+ const size_t ivertex,
+ struct ssol_path_vertex* vertex)
+{
+ const struct path* p;
+ if(!path || !vertex) return RES_BAD_ARG;
+ p = path->path__;
+ if(ivertex >= darray_path_vertex_size_get(&p->vertices)) return RES_BAD_ARG;
+ *vertex = darray_path_vertex_cdata_get(&p->vertices)[ivertex];
+ return RES_OK;
+}
+
+res_T
+ssol_path_get_type(const struct ssol_path* path, enum ssol_path_type* type)
+{
+ ASSERT(path && type);
+ if(!path || !type) return RES_BAD_ARG;
+ *type = ((struct path*)path->path__)->type;
+ return RES_OK;
+}
+
/*******************************************************************************
* Local function
******************************************************************************/
@@ -227,6 +283,7 @@ estimator_create
htable_receiver_init(dev->allocator, &estimator->mc_receivers);
htable_sampled_init(dev->allocator, &estimator->mc_sampled);
+ darray_path_init(dev->allocator, &estimator->paths);
SSOL(device_ref_get(dev));
estimator->dev = dev;
ref_init(&estimator->ref);
diff --git a/src/ssol_estimator_c.h b/src/ssol_estimator_c.h
@@ -377,6 +377,77 @@ error:
#include <rsys/hash_table.h>
/*******************************************************************************
+ * Radiative path
+ ******************************************************************************/
+#define DARRAY_NAME path_vertex
+#define DARRAY_DATA struct ssol_path_vertex
+#include <rsys/dynamic_array.h>
+
+struct path {
+ enum ssol_path_type type;
+ struct darray_path_vertex vertices;
+};
+
+static INLINE void
+path_init(struct mem_allocator* allocator, struct path* path)
+{
+ ASSERT(path);
+ path->type = SSOL_PATH_MISSING;
+ darray_path_vertex_init(allocator, &path->vertices);
+}
+
+static INLINE void
+path_release(struct path* path)
+{
+ ASSERT(path);
+ darray_path_vertex_release(&path->vertices);
+}
+
+static INLINE res_T
+path_copy(struct path* dst, const struct path* src)
+{
+ ASSERT(dst && src);
+ dst->type = src->type;
+ return darray_path_vertex_copy(&dst->vertices, &src->vertices);
+}
+
+static INLINE res_T
+path_copy_and_release(struct path* dst, struct path* src)
+{
+ ASSERT(dst && src);
+ dst->type = src->type;
+ return darray_path_vertex_copy_and_release(&dst->vertices, &src->vertices);
+}
+
+static INLINE res_T
+path_copy_and_clear(struct path* dst, struct path* src)
+{
+ ASSERT(dst && src);
+ dst->type = src->type;
+ return darray_path_vertex_copy_and_clear(&dst->vertices, &src->vertices);
+}
+
+static INLINE res_T
+path_add_vertex(struct path* path, const double pos[3], const double weight)
+{
+ struct ssol_path_vertex vertex;
+ ASSERT(path && pos && weight >= 0);
+ vertex.pos[0] = pos[0];
+ vertex.pos[1] = pos[1];
+ vertex.pos[2] = pos[2];
+ vertex.weight = weight;
+ return darray_path_vertex_push_back(&path->vertices, &vertex);
+}
+
+#define DARRAY_NAME path
+#define DARRAY_DATA struct path
+#define DARRAY_FUNCTOR_INIT path_init
+#define DARRAY_FUNCTOR_RELEASE path_release
+#define DARRAY_FUNCTOR_COPY path_copy
+#define DARRAY_FUNCTOR_COPY_AND_RELEASE path_copy_and_release
+#include <rsys/dynamic_array.h>
+
+/*******************************************************************************
* Estimator data structure
******************************************************************************/
struct ssol_estimator {
@@ -391,6 +462,8 @@ struct ssol_estimator {
struct htable_receiver mc_receivers; /* Per receiver MC */
struct htable_sampled mc_sampled; /* Per sampled instance MC */
+ struct darray_path paths; /* Tracked paths */
+
/* Overall area of the sampled instances. Actually this is not the area that
* is effectively sampled since an instance may be sampled through a proxy
* geometry */
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -55,6 +55,7 @@ struct thread_context {
struct mc_data cos_loss;
struct htable_receiver mc_rcvs;
struct htable_sampled mc_samps;
+ struct darray_path paths; /* paths */
};
static void
@@ -65,6 +66,7 @@ thread_context_release(struct thread_context* ctx)
if(ctx->bsdf) SSF(bsdf_ref_put(ctx->bsdf));
htable_receiver_release(&ctx->mc_rcvs);
htable_sampled_release(&ctx->mc_samps);
+ darray_path_release(&ctx->paths);
}
static res_T
@@ -76,6 +78,7 @@ thread_context_init(struct mem_allocator* allocator, struct thread_context* ctx)
memset(ctx, 0, sizeof(ctx[0]));
htable_receiver_init(allocator, &ctx->mc_rcvs);
htable_sampled_init(allocator, &ctx->mc_samps);
+ darray_path_init(allocator, &ctx->paths);
res = ssf_bsdf_create(allocator, &ctx->bsdf);
if(res != RES_OK) goto error;
@@ -104,6 +107,8 @@ thread_context_copy
if(res != RES_OK) return res;
res = htable_sampled_copy(&dst->mc_samps, &src->mc_samps);
if(res != RES_OK) return res;
+ res = darray_path_copy(&dst->paths, &src->paths);
+ if(res != RES_OK) return res;
return RES_OK;
}
@@ -114,6 +119,7 @@ thread_context_clear(struct thread_context* ctx)
if(ctx->rng) SSP(rng_ref_put(ctx->rng));
htable_receiver_clear(&ctx->mc_rcvs);
htable_sampled_clear(&ctx->mc_samps);
+ darray_path_clear(&ctx->paths);
}
static res_T
@@ -447,6 +453,36 @@ check_scene(const struct ssol_scene* scene, const char* caller)
return RES_OK;
}
+/* Compute an empirical length of the path segment coming from/going to the
+ * infinite, wrt the scene bounding box */
+static INLINE double
+compute_infinite_path_segment_extend(struct s3d_scene_view* view)
+{
+ float lower[3], upper[3], size[3];
+ ASSERT(view);
+ S3D(scene_view_get_aabb(view, lower, upper));
+ f3_sub(size, upper, lower);
+ return MMAX(size[0], MMAX(size[1], size[2])) * 0.75;
+}
+
+static INLINE res_T
+path_register_and_clear
+ (struct darray_path* paths,
+ struct path* path)
+{
+ struct path* dst_path;
+ size_t ipath;
+ res_T res = RES_OK;
+ ASSERT(paths && path);
+
+ ipath = darray_path_size_get(paths);
+ res = darray_path_resize(paths, ipath + 1);
+ if(res != RES_OK) return res;
+
+ dst_path = darray_path_data_get(paths) + ipath;
+ return path_copy_and_clear(dst_path, path);
+}
+
static res_T
accum_mc_receivers_1side
(struct mc_receiver_1side* dst,
@@ -620,7 +656,7 @@ update_mc
res = mc_shape_1side_get_mc_primitive(mc_shape1, pt->prim.prim_id, &mc_prim1);
if(res != RES_OK) goto error;
- #define ACCUM_WEIGHT(Name, W) { \
+ #define ACCUM_WEIGHT(Name, W) { \
mc_prim1->Name.weight += (W); \
mc_prim1->Name.sqr_weight += (W)*(W); \
} (void)0
@@ -647,8 +683,10 @@ trace_radiative_path
struct s3d_scene_view* view_rt,
struct ranst_sun_dir* ran_sun_dir,
struct ranst_sun_wl* ran_sun_wl,
+ const struct ssol_path_tracker* tracker, /* May be NULL */
FILE* output) /* May be NULL */
{
+ struct path path;
struct s3d_hit hit = S3D_HIT_NULL;
struct point pt;
float org[3], dir[3], range[2] = { 0, FLT_MAX };
@@ -657,16 +695,35 @@ trace_radiative_path
res_T res = RES_OK;
ASSERT(thread_ctx && scn && view_samp && view_rt && ran_sun_dir && ran_sun_wl);
+ if(tracker) path_init(scn->dev->allocator, &path);
+
/* Find a new starting point of the radiative random walk */
res = point_init(&pt, sampled_area_proxy, scn, &thread_ctx->mc_samps,
view_samp, view_rt, ran_sun_dir, ran_sun_wl, thread_ctx->rng, &is_lit);
if(res != RES_OK) goto error;
+ if(tracker) {
+ /* Add the first point of the starting segment */
+ if(tracker->sun_ray_length > 0) {
+ double pos[3], wi[3];
+ d3_minus(wi, pt.dir);
+ d3_muld(wi, wi, tracker->sun_ray_length);
+ d3_add(pos, pt.pos, wi);
+ res = path_add_vertex(&path, pos, scn->sun->dni);
+ if(res != RES_OK) goto error;
+ }
+
+ /* Register the init position onto the sampled geometry */
+ res = path_add_vertex(&path, pt.pos, pt.weight);
+ if(res != RES_OK) goto error;
+ }
+
if(!is_lit) { /* The starting point is not lit */
pt.mc_samp->shadowed.weight += pt.weight;
pt.mc_samp->shadowed.sqr_weight += pt.weight;
thread_ctx->shadowed.weight += pt.weight;
thread_ctx->shadowed.sqr_weight += pt.weight * pt.weight;
+ if(tracker) path.type = SSOL_PATH_SHADOW;
} else {
int hit_a_receiver = 0;
@@ -719,7 +776,17 @@ trace_radiative_path
ray_data.range_min = range[0];
ray_data.dst = FLT_MAX;
S3D(scene_view_trace_ray(view_rt, org, dir, range, &ray_data, &hit));
- if(S3D_HIT_NONE(&hit)) break;
+ if(S3D_HIT_NONE(&hit)) {
+ /* Add the point of the last path segment going to the infinite */
+ if(tracker && tracker->infinite_ray_length > 0) {
+ double pos[3], wi[3];
+ d3_set_f3(wi, dir);
+ d3_add(pos, pt.pos, d3_muld(wi, wi, tracker->infinite_ray_length));
+ res = path_add_vertex(&path, pos, pt.weight);
+ if(res != RES_OK) goto error;
+ }
+ break;
+ }
depth += mtl->type != SSOL_MATERIAL_VIRTUAL;
@@ -734,14 +801,28 @@ trace_radiative_path
/* Update the point */
point_update_from_hit(&pt, scn, org, dir, &hit, &ray_data);
+
+ if(tracker) {
+ res = path_add_vertex(&path, pt.pos, pt.weight);
+ if(res != RES_OK) goto error;
+ }
}
if(!hit_a_receiver) {
thread_ctx->missing.weight += pt.weight;
thread_ctx->missing.sqr_weight += pt.weight*pt.weight;
}
+ if(tracker) {
+ path.type = hit_a_receiver ? SSOL_PATH_SUCCESS : SSOL_PATH_MISSING;
+ }
+ }
+
+ if(tracker) {
+ res = path_register_and_clear(&thread_ctx->paths, &path);
+ if(res != RES_OK) goto error;
}
exit:
+ if(tracker) path_release(&path);
return res;
error:
goto exit;
@@ -755,6 +836,7 @@ ssol_solve
(struct ssol_scene* scn,
struct ssp_rng* rng_state,
const size_t realisations_count,
+ const struct ssol_path_tracker* path_tracker,
FILE* output,
struct ssol_estimator** out_estimator)
{
@@ -766,6 +848,7 @@ ssol_solve
struct ranst_sun_wl* ran_sun_wl = NULL;
struct darray_thread_ctx thread_ctxs;
struct ssol_estimator* estimator = NULL;
+ struct ssol_path_tracker tracker;
struct ssp_rng_proxy* rng_proxy = NULL;
double sampled_area;
double sampled_area_proxy;
@@ -818,6 +901,17 @@ ssol_solve
if(res != RES_OK) goto error;
}
+ /* Setup the path tracker */
+ if(path_tracker) {
+ tracker = *path_tracker;
+ if(tracker.sun_ray_length < 0 || tracker.infinite_ray_length < 0) {
+ const double extend = compute_infinite_path_segment_extend(view_rt);
+ if(tracker.sun_ray_length < 0) tracker.sun_ray_length = extend;
+ if(tracker.infinite_ray_length < 0) tracker.infinite_ray_length = extend;
+ }
+ path_tracker = &tracker;
+ }
+
/* Launch the parallel MC estimation */
#pragma omp parallel for schedule(static)
for(i = 0; i < nrealisations; ++i) {
@@ -832,7 +926,7 @@ ssol_solve
/* Execute a MC experiment */
res_local = trace_radiative_path((size_t)i, sampled_area_proxy, thread_ctx,
- scn, view_samp, view_rt, ran_sun_dir, ran_sun_wl, output);
+ scn, view_samp, view_rt, ran_sun_dir, ran_sun_wl, path_tracker, output);
if(res_local != RES_OK) {
ATOMIC_SET(&res, res_local);
continue;
@@ -901,6 +995,23 @@ ssol_solve
}
}
+ /* Merge per thread tracked paths */
+ if(path_tracker) {
+ FOR_EACH(i, 0, nthreads) {
+ struct thread_context* thread_ctx;
+ size_t ipath, npaths;
+
+ thread_ctx = darray_thread_ctx_data_get(&thread_ctxs) + i;
+ npaths = darray_path_size_get(&thread_ctx->paths);
+ FOR_EACH(ipath, 0, npaths) {
+ struct path* path;
+ path = darray_path_data_get(&thread_ctx->paths) + ipath;
+ res = path_register_and_clear(&estimator->paths, path);
+ if(res != RES_OK) goto error;
+ }
+ }
+ }
+
estimator->realisation_count = realisations_count;
estimator->sampled_area = sampled_area;
diff --git a/src/test_ssol_by_receiver_integration.c b/src/test_ssol_by_receiver_integration.c
@@ -134,19 +134,19 @@ main(int argc, char** argv)
#define S_DNI_cos (4 * 1000 * cos(PI / 4))
#define GET_MC_RCV ssol_estimator_get_mc_receiver
#define GET_MC_SAMP_X_RCV ssol_estimator_get_mc_sampled_x_receiver
- CHECK(ssol_solve(scene, rng, N__, NULL, &estimator1), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, NULL, &estimator1), RES_OK);
CHECK(GET_MC_RCV(estimator1, target, SSOL_FRONT, &mc_rcv), RES_OK);
printf("Ir(target) = %g +/- %g\n",
mc_rcv.integrated_irradiance.E, mc_rcv.integrated_irradiance.SE);
CHECK(ssol_instance_set_receiver(heliostat, SSOL_FRONT, 0), RES_OK);
CHECK(eq_eps(mc_rcv.integrated_irradiance.E, S_DNI_cos, S_DNI_cos * 2e-1), 1);
- CHECK(ssol_solve(scene, rng, 8 * N__, NULL, &estimator2), RES_OK);
+ CHECK(ssol_solve(scene, rng, 8 * N__, 0, NULL, &estimator2), RES_OK);
CHECK(GET_MC_RCV(estimator2, target, SSOL_FRONT, &mc_rcv), RES_OK);
printf("Ir(target) = %g +/- %g\n",
mc_rcv.integrated_irradiance.E, mc_rcv.integrated_irradiance.SE);
CHECK(eq_eps(mc_rcv.integrated_irradiance.E, S_DNI_cos, S_DNI_cos * 5e-2), 1);
CHECK(ssol_estimator_ref_put(estimator1), RES_OK);
- CHECK(ssol_solve(scene, rng, 3 * N__, NULL, &estimator1), RES_OK);
+ CHECK(ssol_solve(scene, rng, 3 * N__, 0, NULL, &estimator1), RES_OK);
CHECK(GET_MC_RCV(estimator1, target, SSOL_FRONT, &mc_rcv), RES_OK);
printf("Ir(target) = %g +/- %g\n",
mc_rcv.integrated_irradiance.E, mc_rcv.integrated_irradiance.SE);
diff --git a/src/test_ssol_solver1.c b/src/test_ssol_solver1.c
@@ -73,6 +73,8 @@ main(int argc, char** argv)
struct ssol_mc_receiver mc_rcv;
struct ssol_mc_shape mc_shape;
struct ssol_mc_primitive mc_prim;
+ struct ssol_path path;
+ struct ssol_path_vertex vertex;
double dir[3];
double wavelengths[3] = { 1, 2, 3 };
double intensities[3] = { 1, 0.8, 1 };
@@ -120,14 +122,14 @@ main(int argc, char** argv)
CHECK(ssol_scene_create(dev, &scene), RES_OK);
CHECK(ssol_scene_attach_sun(scene, sun), RES_OK);
- CHECK(ssol_solve(NULL, rng, 10, NULL, &estimator), RES_BAD_ARG);
- CHECK(ssol_solve(scene, NULL, 10, NULL, &estimator), RES_BAD_ARG);
- CHECK(ssol_solve(scene, rng, 0, NULL, &estimator), RES_BAD_ARG);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
- CHECK(ssol_solve(scene, rng, 10, NULL, NULL), RES_BAD_ARG);
+ CHECK(ssol_solve(NULL, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, NULL, 10, 0, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 0, 0, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, NULL), RES_BAD_ARG);
/* No geometry */
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
/* Create scene content */
CHECK(ssol_shape_create_mesh(dev, &dummy), RES_OK);
@@ -162,7 +164,40 @@ main(int argc, char** argv)
CHECK(ssol_instance_set_receiver(target, SSOL_FRONT, 0), RES_OK);
CHECK(ssol_scene_attach_instance(scene, target), RES_OK);
- CHECK(ssol_solve(scene, rng, 1, NULL, &estimator), RES_OK);
+ CHECK(ssol_solve
+ (scene, rng, 1, &SSOL_PATH_TRACKER_DEFAULT, NULL, &estimator), RES_OK);
+
+ CHECK(ssol_estimator_get_tracked_paths_count(NULL, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_paths_count(estimator, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_paths_count(NULL, &count), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_paths_count(estimator, &count), RES_OK);
+ CHECK(count, 1);
+
+ CHECK(ssol_estimator_get_tracked_path(NULL, count, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(estimator, count, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(NULL, 0, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(estimator, 0, NULL), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(NULL, count, &path), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(estimator, count, &path), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(NULL, 0, &path), RES_BAD_ARG);
+ CHECK(ssol_estimator_get_tracked_path(estimator, 0, &path), RES_OK);
+
+ CHECK(ssol_path_get_vertices_count(NULL, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertices_count(&path, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertices_count(NULL, &count), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertices_count(&path, &count), RES_OK);
+ NCHECK(count, 0);
+
+ CHECK(ssol_path_get_vertex(NULL, count, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(&path, count, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(NULL, 0, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(&path, 0, NULL), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(NULL, count, &vertex), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(&path, count, &vertex), RES_BAD_ARG);
+ CHECK(ssol_path_get_vertex(NULL, 0, &vertex), RES_BAD_ARG);
+ FOR_EACH(i, 0, count) {
+ CHECK(ssol_path_get_vertex(&path, i, &vertex), RES_OK);
+ }
CHECK(ssol_estimator_get_sampled_area(NULL, NULL), RES_BAD_ARG);
CHECK(ssol_estimator_get_sampled_area(estimator, NULL), RES_BAD_ARG);
@@ -196,7 +231,7 @@ main(int argc, char** argv)
CHECK(ssol_instance_sample(target, 0), RES_OK);
CHECK(ssol_instance_sample(secondary, 0), RES_OK);
CHECK(ssol_instance_sample(heliostat, 0), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
CHECK(ssol_instance_sample(target, 1), RES_OK);
CHECK(ssol_instance_sample(secondary, 1), RES_OK);
@@ -204,7 +239,7 @@ main(int argc, char** argv)
/* No attached sun */
CHECK(ssol_scene_detach_sun(scene, sun), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
CHECK(ssol_sun_ref_put(sun), RES_OK);
/* Sun with no spectrum */
@@ -212,7 +247,7 @@ main(int argc, char** argv)
CHECK(ssol_sun_set_direction(sun, d3(dir, 1, 0, -1)), RES_OK);
CHECK(ssol_sun_set_dni(sun, 1000), RES_OK);
CHECK(ssol_scene_attach_sun(scene, sun), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
CHECK(ssol_scene_detach_sun(scene, sun), RES_OK);
CHECK(ssol_sun_ref_put(sun), RES_OK);
@@ -221,14 +256,14 @@ main(int argc, char** argv)
CHECK(ssol_sun_set_direction(sun, d3(dir, 1, 0, -1)), RES_OK);
CHECK(ssol_sun_set_spectrum(sun, spectrum), RES_OK);
CHECK(ssol_scene_attach_sun(scene, sun), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_BAD_ARG);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_BAD_ARG);
CHECK(ssol_sun_set_dni(sun, 1000), RES_OK);
/* No receiver in scene */
CHECK(ssol_instance_set_receiver(heliostat, 0, 0), RES_OK);
CHECK(ssol_instance_set_receiver(secondary, 0, 0), RES_OK);
CHECK(ssol_instance_set_receiver(target, 0, 0), RES_OK);
- CHECK(ssol_solve(scene, rng, 10, NULL, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, 10, 0, NULL, &estimator), RES_OK);
CHECK(ssol_instance_set_receiver(heliostat, SSOL_FRONT, 0), RES_OK);
CHECK(ssol_instance_set_receiver(secondary, SSOL_FRONT, 0), RES_OK);
CHECK(ssol_instance_set_receiver(target, SSOL_FRONT, 0), RES_OK);
@@ -243,7 +278,7 @@ main(int argc, char** argv)
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, NULL, &estimator), RES_BAD_ARG);
+ 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);
@@ -253,7 +288,7 @@ main(int argc, char** argv)
#define N__ 10000
#define GET_MC_RCV ssol_estimator_get_mc_receiver
#define GET_MC_GLOBAL ssol_estimator_get_mc_global
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target, &r_id), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
@@ -302,7 +337,7 @@ main(int argc, char** argv)
CHECK(ssol_instance_sample(secondary, 0), RES_OK);
NCHECK(tmp = tmpfile(), 0);
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
CHECK(pp_sum(tmp, (int32_t)r_id, count, &m, &std), RES_OK);
@@ -333,7 +368,7 @@ main(int argc, char** argv)
CHECK(ssol_scene_attach_atmosphere(scene, atm), RES_OK);
NCHECK(tmp = tmpfile(), 0);
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
CHECK(pp_sum(tmp, (int32_t)r_id, count, &m, &std), RES_OK);
@@ -381,7 +416,7 @@ main(int argc, char** argv)
CHECK(ssol_instance_set_receiver(target, SSOL_FRONT, 1), RES_OK);
NCHECK(tmp = tmpfile(), 0);
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
CHECK(pp_sum(tmp, (int32_t)r_id, count, &a_m, &a_std), RES_OK);
@@ -481,7 +516,7 @@ main(int argc, char** argv)
desc.count = 2;
CHECK(ssol_spectrum_setup(abs, get_wlen, 2, &desc), RES_OK);
NCHECK(tmp = tmpfile(), 0);
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
CHECK(pp_sum(tmp, (int32_t)r_id, count, &m, &std), RES_OK);
diff --git a/src/test_ssol_solver2.c b/src/test_ssol_solver2.c
@@ -180,7 +180,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 10000
#define GET_MC_RCV ssol_estimator_get_mc_receiver
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target, &r_id), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
diff --git a/src/test_ssol_solver2b.c b/src/test_ssol_solver2b.c
@@ -183,7 +183,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 50000
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target, &r_id), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
diff --git a/src/test_ssol_solver3.c b/src/test_ssol_solver3.c
@@ -137,7 +137,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 20000
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target, &r_id), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
diff --git a/src/test_ssol_solver4.c b/src/test_ssol_solver4.c
@@ -146,7 +146,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 10000
#define GET_MC_RCV ssol_estimator_get_mc_receiver
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target1, &r_id1), RES_OK);
CHECK(ssol_instance_get_id(target2, &r_id2), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
diff --git a/src/test_ssol_solver5.c b/src/test_ssol_solver5.c
@@ -138,7 +138,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 10000
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(ssol_instance_get_id(target, &r_id), RES_OK);
CHECK(ssol_estimator_get_count(estimator, &count), RES_OK);
CHECK(count, N__);
diff --git a/src/test_ssol_solver6.c b/src/test_ssol_solver6.c
@@ -178,7 +178,7 @@ main(int argc, char** argv)
NCHECK(tmp = tmpfile(), 0);
#define N__ 10000
#define GET_MC_RCV ssol_estimator_get_mc_receiver
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(fclose(tmp), 0);
CHECK(ssol_estimator_get_mc_global(estimator, &mc_global), RES_OK);
printf("Shadows = %g +/- %g\n", mc_global.shadowed.E, mc_global.shadowed.SE);
diff --git a/src/test_ssol_solver7.c b/src/test_ssol_solver7.c
@@ -198,7 +198,7 @@ main(int argc, char** argv)
#define GET_MC_RCV ssol_estimator_get_mc_receiver
NCHECK(tmp = tmpfile(), 0);
- CHECK(ssol_solve(scene, rng, N__, tmp, &estimator), RES_OK);
+ CHECK(ssol_solve(scene, rng, N__, 0, tmp, &estimator), RES_OK);
CHECK(fclose(tmp), 0);
printf("Total = %g\n", TOTAL);