/home/rays/src/opensrc/tesseract-ocr/classify/kdtree.cpp File Reference

#include "kdtree.h"
#include "const.h"
#include "emalloc.h"
#include "freelist.h"
#include <stdio.h>
#include <math.h>

Classes

class  MinK< Key, Value >
struct  MinK< Key, Value >::Element
class  KDTreeSearch

Defines

#define Magnitude(X)   ((X) < 0 ? -(X) : (X))
#define NodeFound(N, K, D)   (( (N)->Key == (K) ) && ( (N)->Data == (D) ))
#define MINSEARCH   -MAX_FLOAT32
#define MAXSEARCH   MAX_FLOAT32

Functions

KDTREEMakeKDTree (inT16 KeySize, const PARAM_DESC KeyDesc[])
void KDStore (KDTREE *Tree, FLOAT32 *Key, void *Data)
void KDDelete (KDTREE *Tree, FLOAT32 Key[], void *Data)
void KDNearestNeighborSearch (KDTREE *Tree, FLOAT32 Query[], int QuerySize, FLOAT32 MaxDistance, int *NumberOfResults, void **NBuffer, FLOAT32 DBuffer[])
void KDWalk (KDTREE *Tree, void_proc action, void *context)
void FreeKDTree (KDTREE *Tree)
KDNODEMakeKDNode (KDTREE *tree, FLOAT32 Key[], void *Data, int Index)
void FreeKDNode (KDNODE *Node)
FLOAT32 DistanceSquared (int k, PARAM_DESC *dim, FLOAT32 p1[], FLOAT32 p2[])
FLOAT32 ComputeDistance (int k, PARAM_DESC *dim, FLOAT32 p1[], FLOAT32 p2[])
void Walk (KDTREE *tree, void_proc action, void *context, KDNODE *sub_tree, inT32 level)
void InsertNodes (KDTREE *tree, KDNODE *nodes)
void FreeSubTree (KDNODE *sub_tree)

Define Documentation

#define Magnitude (  )     ((X) < 0 ? -(X) : (X))
#define MAXSEARCH   MAX_FLOAT32
#define MINSEARCH   -MAX_FLOAT32
#define NodeFound ( N,
K,
 )     (( (N)->Key == (K) ) && ( (N)->Data == (D) ))

Function Documentation

FLOAT32 ComputeDistance ( int  k,
PARAM_DESC dim,
FLOAT32  p1[],
FLOAT32  p2[] 
)
FLOAT32 DistanceSquared ( int  k,
PARAM_DESC dim,
FLOAT32  p1[],
FLOAT32  p2[] 
)
void FreeKDNode ( KDNODE Node  ) 
void FreeKDTree ( KDTREE Tree  ) 
void FreeSubTree ( KDNODE sub_tree  ) 
void InsertNodes ( KDTREE tree,
KDNODE nodes 
)
void KDDelete ( KDTREE Tree,
FLOAT32  Key[],
void *  Data 
)

This routine deletes a node from Tree. The node to be deleted is specified by the Key for the node and the Data contents of the node. These two pointers must be identical to the pointers that were used for the node when it was originally stored in the tree. A node will be deleted from the tree only if its key and data pointers are identical to Key and Data respectively. The tree is re-formed by removing the affected subtree and inserting all elements but the root.

Parameters:
Tree K-D tree to delete node from
Key key of node to be deleted
Data data contents of node to be deleted
Note:
Exceptions: none
History: 3/13/89, DSJ, Created. 7/13/89, DSJ, Specify node indirectly by key and data.
void KDNearestNeighborSearch ( KDTREE Tree,
FLOAT32  Query[],
int  QuerySize,
FLOAT32  MaxDistance,
int *  NumberOfResults,
void **  NBuffer,
FLOAT32  DBuffer[] 
)
void KDStore ( KDTREE Tree,
FLOAT32 Key,
void *  Data 
)

This routine stores Data in the K-D tree specified by Tree using Key as an access key.

Parameters:
Tree K-D tree in which data is to be stored
Key ptr to key by which data can be retrieved
Data ptr to data to be stored in the tree
Note:
Exceptions: none
History: 3/10/89, DSJ, Created. 7/13/89, DSJ, Changed return to void.

void KDWalk ( KDTREE Tree,
void_proc  action,
void *  context 
)
KDNODE* MakeKDNode ( KDTREE tree,
FLOAT32  Key[],
void *  Data,
int  Index 
)
KDTREE* MakeKDTree ( inT16  KeySize,
const PARAM_DESC  KeyDesc[] 
)

Return a new KDTREE based on the specified parameters. Parameters: KeySize # of dimensions in the K-D tree KeyDesc array of params to describe key dimensions

void Walk ( KDTREE tree,
void_proc  action,
void *  context,
KDNODE sub_tree,
inT32  level 
)
Generated on Thu Feb 2 08:19:22 2012 for Tesseract by  doxygen 1.6.3