@@ -17,38 +17,88 @@ typedef struct RTreeH RTreeH;
1717
1818typedef struct RTreeNodeH RTreeNodeH ;
1919
20+ /**
21+ * Returns a new tree containing the given objects. The input arrays must have the same length.
22+ * Returns an empty tree if the input arrays are empty.
23+ * Supported dimensions are currently 1, 2, and 3. Returns an InvalidDimension error for unsupported dimensions.
24+ * You must free the returned tree with `rtree_free`.
25+ */
2026RTreeError rtree_bulk_load (struct RTreeH * * tree ,
2127 const double * mins ,
2228 const double * maxs ,
2329 const size_t * ids ,
2430 size_t n ,
2531 uint32_t dim );
2632
33+ /**
34+ * Returns a new empty tree with the given dimension.
35+ */
2736RTreeError rtree_create (struct RTreeH * * tree , uint32_t dim );
2837
29- RTreeError rtree_depth (const struct RTreeH * tree , size_t * depth_out );
38+ /**
39+ * Returns the depth of the tree, defined as the number of edges in the longest path from the root to a leaf.
40+ * An empty tree has depth 0.
41+ */
42+ RTreeError rtree_depth (const struct RTreeH * tree ,
43+ size_t * depth_out );
3044
45+ /**
46+ * Frees the given tree.
47+ */
3148RTreeError rtree_free (struct RTreeH * tree );
3249
50+ /**
51+ * Frees the ids returned by `rtree_locate_all_at_point`.
52+ */
3353RTreeError rtree_free_ids (size_t * ids , size_t n );
3454
55+ /**
56+ * Returns the dimension of the tree.
57+ */
3558RTreeError rtree_get_dimension (const struct RTreeH * tree , uint32_t * dim );
3659
60+ /**
61+ * Returns the ids of all objects in the tree that contain the given point.
62+ * If no objects contain the point, returns nids_out = 0.
63+ * You must free the returned ids with `rtree_free_ids`.
64+ */
3765RTreeError rtree_locate_all_at_point (const struct RTreeH * tree ,
3866 const double * point ,
3967 size_t * * ids_out ,
4068 size_t * nids_out );
4169
70+ /**
71+ * Returns the child nodes of a given node. You must free the returned child nodes with `rtree_node_children_free`.
72+ * If the node is a leaf, or a root node of an empty tree, returns nchildren = 0.
73+ */
4274RTreeError rtree_node_children (const struct RTreeNodeH * node ,
4375 struct RTreeNodeH * * * children ,
4476 size_t * nchildren );
4577
78+ /**
79+ * Frees the child nodes returned by `rtree_node_children`.
80+ */
4681RTreeError rtree_node_children_free (struct RTreeNodeH * * children , size_t n );
4782
83+ /**
84+ * Returns the minimum bounding box that covers all the boxes in the node.
85+ * Returns an EmptyNodeEnvelope error if given a root node of an empty tree, which has no envelope.
86+ */
4887RTreeError rtree_node_envelope (const struct RTreeNodeH * node , double * min_out , double * max_out );
4988
89+ /**
90+ * Frees the node returned by `rtree_root_node`.
91+ */
5092RTreeError rtree_node_free (struct RTreeNodeH * node );
5193
94+ /**
95+ * Returns the root node of a tree. You must free the returned node with `rtree_node_free`.
96+ * If the tree is empty, returns an EmptyNode.
97+ */
5298RTreeError rtree_root_node (const struct RTreeH * tree , struct RTreeNodeH * * node );
5399
100+ /**
101+ * Returns the size of the tree, defined as the number of objects in the tree.
102+ * An empty tree has size 0.
103+ */
54104RTreeError rtree_size (const struct RTreeH * tree , size_t * size_out );
0 commit comments