sln_tree_c.h (2329B)
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 uint64_t range[2]; 42 uint64_t ivertex; /* Index toward the 1st vertex */ 43 uint32_t nvertices; /* #vertices */ 44 uint32_t offset; /* Offset toward the node's children (left then right) */ 45 }; 46 #define SLN_NODE_NULL__ {{0,0},0,0,0} 47 static const struct sln_node SLN_NODE_NULL = SLN_NODE_NULL__; 48 49 /* Generate the dynamic array of nodes */ 50 #define DARRAY_DATA struct sln_node 51 #define DARRAY_NAME node 52 #include <rsys/dynamic_array.h> 53 54 /* Generate the dynamic array of vertices */ 55 #define DARRAY_DATA struct sln_vertex 56 #define DARRAY_NAME vertex 57 #include <rsys/dynamic_array.h> 58 59 struct sln_tree { 60 struct darray_node nodes; /* Nodes used to partition the lines */ 61 struct darray_vertex vertices; /* List of vertices */ 62 63 struct sln_tree_create_args args; 64 struct sln_device* sln; 65 ref_T ref; 66 }; 67 68 extern LOCAL_SYM res_T 69 tree_build 70 (struct sln_tree* tree); 71 72 #endif /* SLN_TREE_C_H */