star-line

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

commit 70df096314ca59941e4b1aa38fb02775b6e46704
parent 132c1678ad05eb3fd56b3c78fba680eeff4441f4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 15 Apr 2026 15:29:25 +0200

sln-build: Added an option to collapse polylines

This option allows to use the algorithm that constructs polylines
from internal nodes by successively grouping their child polylines in
pairs.

Diffstat:
Mdoc/sln-build.1 | 16++++++++++++++--
Msrc/sln_build.c | 8++++++--
2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/doc/sln-build.1 b/doc/sln-build.1 @@ -15,7 +15,7 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.Dd April 8, 2026 +.Dd April 15, 2026 .Dt SLN-BUILD 1 .Os .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -25,7 +25,7 @@ .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh SYNOPSIS .Nm -.Op Fl hsv +.Op Fl chsv .Op Fl a Ar arity .Op Fl e Ar polyline_opt Ns Op : Ns Ar polyline_opt No ... .Op Fl l Ar line_profile @@ -56,6 +56,18 @@ Maximum number of children of an internal node in the constructed tree that partitions the input lines. It cannot be less than 2, which is its default value. .\"""""""""""""""""""""""""""""""""" +.It Fl c +For each internal node, construct its polyline by merging the polylines +of its children in pairs and then simplifying the result of this merge. +The process is repeated on the resulting polylines until only a single +polyline remains, which becomes the polyline of the internal node. +In other words, these polylines are constructed by successively +collapsing the polylines of the child nodes. +.Pp +By default, the polylines of the internal nodes are constructed in a +single step of merging and simplification that takes into account all +child polylines at once. +.\"""""""""""""""""""""""""""""""""" .It Fl e Ar polyline_opt Ns Op : Ns Ar polyline_opt No ... Configure the polylines, i.e., the data used to encode the shape of the spectrum in the acceleration structure. diff --git a/src/sln_build.c b/src/sln_build.c @@ -51,6 +51,7 @@ struct args { double mesh_decimation_err; unsigned nvertices_hint; enum sln_mesh_type mesh_type; + int collapse_polylines; /* Miscellaneous */ int quit; @@ -75,6 +76,7 @@ struct args { 0.01, \ 16, \ SLN_MESH_UPPER, \ + 0, \ \ /* Miscellaneous */ \ 0, /* Quit */ \ @@ -105,7 +107,7 @@ static void usage(FILE* stream) { fprintf(stream, -"usage: sln-build [-hsv] [-a arity] [-e polyline_opt[:polyline_opt ...]]\n" +"usage: sln-build [-chsv] [-a arity] [-e polyline_opt[:polyline_opt ...]]\n" " [-l line_profile] [-o accel_struct] -P pressure -T temperature\n" " -m molparams -x mixture [lines]\n"); } @@ -225,12 +227,13 @@ args_init(struct args* args, int argc, char** argv) *args = ARGS_DEFAULT; - while((opt = getopt(argc, argv, "a:e:hl:o:P:sT:m:vx:")) != -1) { + while((opt = getopt(argc, argv, "a:ce:hl:o:P:sT:m:vx:")) != -1) { switch(opt) { case 'a': res = cstr_to_uint(optarg, &args->arity); if(res == RES_OK && args->arity < 2) res = RES_BAD_ARG; break; + case 'c': args->collapse_polylines = 1; break; case 'e': res = cstr_parse_list(optarg, ':', parse_polyline_opt, args); break; @@ -449,6 +452,7 @@ cmd_run(struct cmd* cmd) tree_args.mesh_decimation_err = cmd->args.mesh_decimation_err; tree_args.mesh_type = cmd->args.mesh_type; tree_args.arity = cmd->args.arity; + tree_args.collapse_polylines = cmd->args.collapse_polylines; if(cmd->args.output) { write_args.filename = cmd->args.output;