star-line

Structure for accelerating line importance sampling
git clone git://git.meso-star.fr/star-line.git
Log | Files | Refs | README | LICENSE

commit 6c067e20b5eda4531d2b9a1d9e1d4adf12fd71f0
parent 41ab725967951a6dfaea922136fbec61b35895f7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  5 Mar 2026 11:15:18 +0100

Add the number of lines to the tree descriptor

Diffstat:
Msrc/sln.h | 5+++--
Msrc/sln_get.c | 1+
Msrc/sln_tree.c | 5++---
Msrc/test_sln_tree.c | 6++----
4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/sln.h b/src/sln.h @@ -157,12 +157,13 @@ struct sln_tree_desc { enum sln_mesh_type mesh_type; enum sln_line_profile line_profile; - unsigned depth; + unsigned depth; /* #edges from the root to the deepest leaf */ + size_t nlines; size_t nvertices; size_t nnodes; }; #define SLN_TREE_DESC_NULL__ { \ - 0, 0, SLN_MESH_TYPES_COUNT__, SLN_LINE_PROFILES_COUNT__, 0, 0, 0 \ + 0, 0, SLN_MESH_TYPES_COUNT__, SLN_LINE_PROFILES_COUNT__, 0, 0, 0, 0 \ } static const struct sln_tree_desc SLN_TREE_DESC_NULL = SLN_TREE_DESC_NULL__; diff --git a/src/sln_get.c b/src/sln_get.c @@ -168,6 +168,7 @@ print_descriptor(const struct cmd* cmd) res = sln_tree_get_desc(cmd->tree, &desc); if(res != RES_OK) goto error; + printf("#lines: %lu\n", (unsigned long)desc.nlines); printf("#nodes: %lu\n", (unsigned long)desc.nnodes); printf("depth: %u\n", desc.depth); printf("#vertices: %lu\n", (unsigned long)desc.nvertices); diff --git a/src/sln_tree.c b/src/sln_tree.c @@ -507,7 +507,6 @@ sln_tree_ref_put(struct sln_tree* tree) res_T sln_tree_get_desc(const struct sln_tree* tree, struct sln_tree_desc* desc) { - size_t nlines = 0; size_t nlines_adjusted = 0; unsigned depth = 0; @@ -520,8 +519,8 @@ sln_tree_get_desc(const struct sln_tree* tree, struct sln_tree_desc* desc) desc->nnodes = darray_node_size_get(&tree->nodes); desc->nvertices = darray_vertex_size_get(&tree->vertices); - SHTR(line_list_get_size(tree->args.lines, &nlines)); - nlines_adjusted = round_up_pow2(nlines); + SHTR(line_list_get_size(tree->args.lines, &desc->nlines)); + nlines_adjusted = round_up_pow2(desc->nlines); for(depth=0; depth<64 && !(BIT_U64(depth) & nlines_adjusted); ++depth); desc->depth = depth; diff --git a/src/test_sln_tree.c b/src/test_sln_tree.c @@ -157,7 +157,6 @@ test_tree const struct sln_node* node = NULL; struct shtr_line line = SHTR_LINE_NULL; size_t nlines = 0; - unsigned depth = 0; CHK(sln && tree_args_in && line_list); tree_args = *tree_args_in; @@ -177,16 +176,15 @@ test_tree CHK(desc.mesh_decimation_err == tree_args.mesh_decimation_err); CHK(desc.mesh_type == tree_args.mesh_type); CHK(desc.line_profile == tree_args.line_profile); + CHK(desc.nlines == nlines); CHK(desc.nvertices >= 1); CHK(desc.nnodes >= 1); + CHK(desc.depth == (unsigned)log2i((int)round_up_pow2(desc.nlines))); - depth = 0; CHK(node = sln_tree_get_root(tree)); while(!sln_node_is_leaf(node)) { node = sln_node_get_child(node, 0); - ++depth; } - CHK(desc.depth == depth); CHK(sln_node_get_lines_count(node) <= desc.max_nlines_per_leaf); CHK(sln_node_get_line(NULL, node, 0, &line) == RES_BAD_ARG);