Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /* Purpose: This file contains declarations which are visible |
14 | | * only within the H5RT package. Source files outside |
15 | | * the H5RT package should include H5RTprivate.h instead. |
16 | | */ |
17 | | |
18 | | #if !(defined H5RT_FRIEND || defined H5RT_MODULE) |
19 | | #error "Do not include this file outside the H5RT package!" |
20 | | #endif |
21 | | |
22 | | #ifndef H5RTpkg_H |
23 | | #define H5RTpkg_H |
24 | | |
25 | | /* Get package's private header */ |
26 | | #include "H5RTprivate.h" |
27 | | |
28 | | /* Other private headers needed by this file */ |
29 | | |
30 | 0 | #define H5RT_MAX_NODE_SIZE 16 |
31 | | |
32 | | /* Forward declaration */ |
33 | | typedef struct H5RT_node_t H5RT_node_t; |
34 | | |
35 | | /* Internal node of the r-tree */ |
36 | | typedef struct H5RT_node_t { |
37 | | hsize_t min[H5S_MAX_RANK]; /* Invalid for root node */ |
38 | | hsize_t max[H5S_MAX_RANK]; /* Invalid for root node */ |
39 | | union { |
40 | | H5RT_node_t *nodes[H5RT_MAX_NODE_SIZE]; |
41 | | H5RT_leaf_t *leaves; |
42 | | } children; |
43 | | int nchildren; |
44 | | bool children_are_leaves; |
45 | | } H5RT_node_t; |
46 | | |
47 | | /* Overall r-tree */ |
48 | | struct H5RT_t { |
49 | | H5RT_node_t root; |
50 | | H5RT_leaf_t *leaves; |
51 | | int rank; |
52 | | size_t nleaves; |
53 | | }; |
54 | | |
55 | | /* Inline function to check if two hyper-rectangles intersect */ |
56 | | static inline bool |
57 | | H5RT__leaves_intersect(int rank, hsize_t min1[], hsize_t max1[], hsize_t min2[], hsize_t max2[]) |
58 | 0 | { |
59 | 0 | for (int i = 0; i < rank; i++) |
60 | 0 | if (min1[i] > max2[i] || min2[i] > max1[i]) |
61 | 0 | return false; /* No overlap in i-th dimension */ |
62 | | |
63 | 0 | return true; |
64 | 0 | } |
65 | | |
66 | | #endif /* H5RTpkg_H */ |