star-line

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

sln_tree_c.h (2541B)


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