Blender  V3.3
BLI_kdtree_impl.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include "BLI_compiler_attrs.h"
9 #include "BLI_sys_types.h"
10 
11 #define _BLI_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) MACRO_ARG1##MACRO_ARG2
12 #define _BLI_CONCAT(MACRO_ARG1, MACRO_ARG2) _BLI_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2)
13 #define BLI_kdtree_nd_(id) _BLI_CONCAT(KDTREE_PREFIX_ID, _##id)
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 struct KDTree;
20 typedef struct KDTree KDTree;
21 
22 typedef struct KDTreeNearest {
23  int index;
24  float dist;
25  float co[KD_DIMS];
27 
28 KDTree *BLI_kdtree_nd_(new)(unsigned int maxsize);
31 
32 void BLI_kdtree_nd_(insert)(KDTree *tree, int index, const float co[KD_DIMS]) ATTR_NONNULL(1, 3);
34  const float co[KD_DIMS],
35  KDTreeNearest *r_nearest) ATTR_NONNULL(1, 2);
36 
38  const float co[KD_DIMS],
39  KDTreeNearest *r_nearest,
40  uint nearest_len_capacity) ATTR_NONNULL(1, 2, 3);
41 
43  const float co[KD_DIMS],
44  KDTreeNearest **r_nearest,
46 
48  const KDTree *tree,
49  const float co[KD_DIMS],
50  int (*filter_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq),
51  void *user_data,
52  KDTreeNearest *r_nearest);
54  const KDTree *tree,
55  const float co[KD_DIMS],
56  float range,
57  bool (*search_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq),
58  void *user_data);
59 
61  float range,
62  bool use_index_order,
63  int *doubles);
64 
66 
69  const KDTree *tree,
70  const float co[KD_DIMS],
71  KDTreeNearest *r_nearest,
72  uint nearest_len_capacity,
73  float (*len_sq_fn)(const float co_search[KD_DIMS],
74  const float co_test[KD_DIMS],
75  const void *user_data),
76  const void *user_data) ATTR_NONNULL(1, 2, 3);
78  const KDTree *tree,
79  const float co[KD_DIMS],
80  KDTreeNearest **r_nearest,
81  float range,
82  float (*len_sq_fn)(const float co_search[KD_DIMS],
83  const float co_test[KD_DIMS],
84  const void *user_data),
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #ifdef __cplusplus
92 template<typename Fn>
93 inline void BLI_kdtree_nd_(range_search_cb_cpp)(const KDTree *tree,
94  const float co[KD_DIMS],
95  float distance,
96  const Fn &fn)
97 {
99  tree,
100  co,
101  distance,
102  [](void *user_data, const int index, const float *co, const float dist_sq) {
103  const Fn &fn = *static_cast<const Fn *>(user_data);
104  return fn(index, co, dist_sq);
105  },
106  const_cast<Fn *>(&fn));
107 }
108 #endif
109 
110 #undef _BLI_CONCAT_AUX
111 #undef _BLI_CONCAT
112 #undef BLI_kdtree_nd_
typedef float(TangentPoint)[2]
#define ATTR_NONNULL(...)
#define KD_DIMS
Definition: BLI_kdtree.h:44
int BLI_kdtree_nd_() find_nearest_n_with_len_squared_cb(const KDTree *tree, const float co[KD_DIMS], KDTreeNearest *r_nearest, uint nearest_len_capacity, float(*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data), const void *user_data) ATTR_NONNULL(1
void BLI_kdtree_nd_() int BLI_kdtree_nd_() find_nearest(const KDTree *tree, const float co[KD_DIMS], KDTreeNearest *r_nearest) ATTR_NONNULL(1
void BLI_kdtree_nd_() range_search_cb(const KDTree *tree, const float co[KD_DIMS], float range, bool(*search_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data)
Definition: kdtree_impl.h:729
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() range_search(const KDTree *tree, const float co[KD_DIMS], KDTreeNearest **r_nearest, float range) ATTR_NONNULL(1
int BLI_kdtree_nd_() int BLI_kdtree_nd_() range_search_with_len_squared_cb(const KDTree *tree, const float co[KD_DIMS], KDTreeNearest **r_nearest, float range, float(*len_sq_fn)(const float co_search[KD_DIMS], const float co_test[KD_DIMS], const void *user_data), const void *user_data) ATTR_NONNULL(1
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() ATTR_WARN_UNUSED_RESULT
int BLI_kdtree_nd_() deduplicate(KDTree *tree)
Definition: kdtree_impl.h:967
struct KDTreeNearest KDTreeNearest
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
void BLI_kdtree_nd_() balance(KDTree *tree) ATTR_NONNULL(1)
Definition: kdtree_impl.h:190
void BLI_kdtree_nd_() int BLI_kdtree_nd_() int BLI_kdtree_nd_() find_nearest_n(const KDTree *tree, const float co[KD_DIMS], KDTreeNearest *r_nearest, uint nearest_len_capacity) ATTR_NONNULL(1
int BLI_kdtree_nd_() find_nearest_cb(const KDTree *tree, const float co[KD_DIMS], int(*filter_cb)(void *user_data, int index, const float co[KD_DIMS], float dist_sq), void *user_data, KDTreeNearest *r_nearest)
Definition: kdtree_impl.h:328
int BLI_kdtree_nd_() calc_duplicates_fast(const KDTree *tree, float range, bool use_index_order, int *doubles)
Definition: kdtree_impl.h:873
#define BLI_kdtree_nd_(id)
void BLI_kdtree_nd_() insert(KDTree *tree, int index, const float co[KD_DIMS]) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
void * user_data
void * tree
T distance(const T &a, const T &b)
float co[KD_DIMS]