queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
kd_tree.cpp File Reference

Go to the source code of this file.

Functions

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

Variables

static int IDX_TRIVIAL [] = {0}
 
ANNkd_leaf * KD_TRIVIAL = NULL
 
const double ANN_AR_TOOBIG = 1000
 

Function Documentation

void annClose ( )

Definition at line 221 of file kd_tree.cpp.

References KD_TRIVIAL.

Referenced by QUESO::distANN_XY(), and main().

222 {
223  if (KD_TRIVIAL != NULL) {
224  delete KD_TRIVIAL;
225  KD_TRIVIAL = NULL;
226  }
227 }
ANNkd_leaf * KD_TRIVIAL
Definition: kd_tree.cpp:50
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, and KD_TRIVIAL.

Referenced by ANNkd_tree::ANNkd_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 }
double ANNcoord
Definition: ANN.h:158
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
ANNkd_leaf * KD_TRIVIAL
Definition: kd_tree.cpp:50
int dim
Definition: ann_test.cpp:472

Variable Documentation

const double ANN_AR_TOOBIG = 1000

Definition at line 145 of file kd_tree.cpp.

int IDX_TRIVIAL[] = {0}
static

Definition at line 49 of file kd_tree.cpp.

Referenced by ANNkd_tree::SkeletonTree().

ANNkd_leaf* KD_TRIVIAL = NULL

Definition at line 50 of file kd_tree.cpp.

Referenced by annClose(), annReadTree(), rbd_tree(), rkd_tree(), and ANNkd_tree::SkeletonTree().


Generated on Tue Jun 5 2018 19:48:56 for queso-0.57.1 by  doxygen 1.8.5