sln_tree_c.h (2366B)
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 /* Current version of the serialized tree data. One should increment it and 29 * perform a version management onto serialized tree when these data are 30 * updated. */ 31 static const int SLN_TREE_VERSION = 1; 32 33 /* Forward declaration */ 34 struct shtr_isotope_metadata; 35 struct shtr_line_list; 36 struct sln_device; 37 struct sln_tree_create_args; 38 39 struct sln_node { /* 32 Bytes */ 40 /* Range of the line indices corresponding to the node. 41 * Both boundaries are inclusives */ 42 uint64_t range[2]; 43 uint64_t ivertex; /* Index toward the 1st vertex */ 44 uint32_t nvertices; /* #vertices */ 45 uint32_t offset; /* Offset toward the node's children (left then right) */ 46 }; 47 #define SLN_NODE_NULL__ {{0,0},0,0,0} 48 static const struct sln_node SLN_NODE_NULL = SLN_NODE_NULL__; 49 50 /* Generate the dynamic array of nodes */ 51 #define DARRAY_DATA struct sln_node 52 #define DARRAY_NAME node 53 #include <rsys/dynamic_array.h> 54 55 /* Generate the dynamic array of vertices */ 56 #define DARRAY_DATA struct sln_vertex 57 #define DARRAY_NAME vertex 58 #include <rsys/dynamic_array.h> 59 60 struct sln_tree { 61 struct darray_node nodes; /* Nodes used to partition the lines */ 62 struct darray_vertex vertices; /* List of vertices */ 63 64 struct sln_tree_create_args args; 65 struct sln_device* sln; 66 ref_T ref; 67 }; 68 69 extern LOCAL_SYM res_T 70 tree_build 71 (struct sln_tree* tree); 72 73 #endif /* SLN_TREE_C_H */