star-line

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

sln_tree_c.h (2639B)


      1 /* Copyright (C) 2022, 2026 |Méso|Star> (contact@meso-star.com)
      2  * Copyright (C) 2026 Université de Lorraine
      3  * Copyright (C) 2022 Centre National de la Recherche Scientifique
      4  * Copyright (C) 2022 Université Paul Sabatier
      5  *
      6  * This program is free software: you can redistribute it and/or modify
      7  * it under the terms of the GNU General Public License as published by
      8  * the Free Software Foundation, either version 3 of the License, or
      9  * (at your option) any later version.
     10  *
     11  * This program is distributed in the hope that it will be useful,
     12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     14  * GNU General Public License for more details.
     15  *
     16  * You should have received a copy of the GNU General Public License
     17  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     18 
     19 #ifndef SLN_TREE_C_H
     20 #define SLN_TREE_C_H
     21 
     22 #include "sln.h"
     23 #include "sln_line.h"
     24 
     25 #include <rsys/dynamic_array.h>
     26 #include <rsys/ref_count.h>
     27 
     28 /* Maximum number of lines per leaf */
     29 #define MAX_NLINES_PER_LEAF 1
     30 
     31 /* Current version of the serialized tree data. One should increment it and
     32  * perform a version management onto serialized tree when these data are
     33  * updated. */
     34 static const int SLN_TREE_VERSION = 1;
     35 
     36 /* Forward declaration */
     37 struct shtr_isotope_metadata;
     38 struct shtr_line_list;
     39 struct sln_device;
     40 struct sln_tree_create_args;
     41 
     42 struct sln_node { /* 32 Bytes */
     43   /* Range of the line indices corresponding to the node.
     44    * Both boundaries are inclusives */
     45   uint64_t range[2];
     46   uint64_t ivertex; /* Index toward the 1st vertex */
     47   uint32_t nvertices; /* #vertices */
     48   uint32_t offset; /* Offset toward the node's children  */
     49 };
     50 #define SLN_NODE_NULL__ {{0,0},0,0,0}
     51 static const struct sln_node SLN_NODE_NULL = SLN_NODE_NULL__;
     52 
     53 /* Generate the dynamic array of nodes */
     54 #define DARRAY_DATA struct sln_node
     55 #define DARRAY_NAME node
     56 #include <rsys/dynamic_array.h>
     57 
     58 /* Generate the dynamic array of vertices */
     59 #define DARRAY_DATA struct sln_vertex
     60 #define DARRAY_NAME vertex
     61 #include <rsys/dynamic_array.h>
     62 
     63 struct sln_tree {
     64   struct darray_node nodes; /* Nodes used to partition the lines */
     65   struct darray_vertex vertices; /* List of vertices */
     66 
     67   struct sln_tree_create_args args;
     68   struct sln_device* sln;
     69   ref_T ref;
     70 };
     71 
     72 extern LOCAL_SYM res_T
     73 tree_build
     74   (struct sln_tree* tree);
     75 
     76 /* Assume that the node is an internal node */
     77 extern LOCAL_SYM unsigned
     78 node_child_count
     79   (const struct sln_tree* tree,
     80    const size_t inode,
     81    size_t* out_nlines_per_child); /* Max #lines per child. May be NULL */
     82 
     83 #endif /* SLN_TREE_C_H */