queso-0.53.0
Classes | Typedefs | Functions | Variables
kd_tree.h File Reference
#include <ANN/ANNx.h>
Include dependency graph for kd_tree.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ANNkd_node
 
class  ANNkd_leaf
 
class  ANNkd_split
 

Typedefs

typedef void(* ANNkd_splitter )(ANNpointArray pa, ANNidxArray pidx, const ANNorthRect &bnds, int n, int dim, int &cut_dim, ANNcoord &cut_val, int &n_lo)
 

Functions

ANNkd_ptr rkd_tree (ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter)
 

Variables

ANNkd_leafKD_TRIVIAL
 

Typedef Documentation

typedef void(* ANNkd_splitter)(ANNpointArray pa,ANNidxArray pidx,const ANNorthRect &bnds,int n,int dim,int &cut_dim,ANNcoord &cut_val,int &n_lo)

Definition at line 72 of file kd_tree.h.

Function Documentation

ANNkd_ptr rkd_tree ( ANNpointArray  pa,
ANNidxArray  pidx,
int  n,
int  dim,
int  bsp,
ANNorthRect bnd_box,
ANNkd_splitter  splitter 
)

Definition at line 314 of file kd_tree.cpp.

References dim, KD_TRIVIAL, and rkd_tree().

Referenced by ANNkd_tree::ANNkd_tree(), and rkd_tree().

322 {
323  if (n <= bsp) { // n small, make a leaf node
324  if (n == 0) // empty leaf node
325  return KD_TRIVIAL; // return (canonical) empty leaf
326  else // construct the node and return
327  return new ANNkd_leaf(n, pidx);
328  }
329  else { // n large, make a splitting node
330  int cd; // cutting dimension
331  ANNcoord cv; // cutting value
332  int n_lo; // number on low side of cut
333  ANNkd_node *lo, *hi; // low and high children
334 
335  // invoke splitting procedure
336  (*splitter)(pa, pidx, bnd_box, n, dim, cd, cv, n_lo);
337 
338  ANNcoord lv = bnd_box.lo[cd]; // save bounds for cutting dimension
339  ANNcoord hv = bnd_box.hi[cd];
340 
341  bnd_box.hi[cd] = cv; // modify bounds for left subtree
342  lo = rkd_tree( // build left subtree
343  pa, pidx, n_lo, // ...from pidx[0..n_lo-1]
344  dim, bsp, bnd_box, splitter);
345  bnd_box.hi[cd] = hv; // restore bounds
346 
347  bnd_box.lo[cd] = cv; // modify bounds for right subtree
348  hi = rkd_tree( // build right subtree
349  pa, pidx + n_lo, n-n_lo,// ...from pidx[n_lo..n-1]
350  dim, bsp, bnd_box, splitter);
351  bnd_box.lo[cd] = lv; // restore bounds
352 
353  // create the splitting node
354  ANNkd_split *ptr = new ANNkd_split(cd, cv, lv, hv, lo, hi);
355 
356  return ptr; // return pointer to this node
357  }
358 }
ANNkd_ptr rkd_tree(ANNpointArray pa, ANNidxArray pidx, int n, int dim, int bsp, ANNorthRect &bnd_box, ANNkd_splitter splitter)
Definition: kd_tree.cpp:314
double ANNcoord
Definition: ANN.h:158
ANNkd_leaf * KD_TRIVIAL
Definition: kd_tree.cpp:50
int dim
Definition: ann2fig.cpp:81

Variable Documentation

ANNkd_leaf* KD_TRIVIAL

Generated on Thu Jun 11 2015 13:52:33 for queso-0.53.0 by  doxygen 1.8.5