Classes | Defines | Typedefs | Enumerations | Functions | Variables

ANN.h File Reference

#include <cmath>
#include <iostream>
#include <climits>
#include <cfloat>

Go to the source code of this file.

Classes

class  ANNpointSet
class  ANNbruteForce
class  ANNkd_tree
class  ANNbd_tree

Defines

#define DLL_API
#define ANNversion   "1.0"
#define ANNversionCmt   ""
#define ANNcopyright   "David M. Mount and Sunil Arya"
#define ANNlatestRev   "Mar 1, 2005"
#define ANN_POW(v)   ((v)*(v))
#define ANN_ROOT(x)   sqrt(x)
#define ANN_SUM(x, y)   ((x) + (y))
#define ANN_DIFF(x, y)   ((y) - (x))

Typedefs

typedef float ANNcoord
typedef float ANNdist
typedef int ANNidx
typedef ANNcoordANNpoint
typedef ANNpointANNpointArray
typedef ANNdistANNdistArray
typedef ANNidxANNidxArray
typedef ANNkd_nodeANNkd_ptr

Enumerations

enum  ANNbool { ANNfalse = 0, ANNtrue = 1 }
enum  ANNsplitRule {
  ANN_KD_STD = 0, ANN_KD_MIDPT = 1, ANN_KD_FAIR = 2, ANN_KD_SL_MIDPT = 3,
  ANN_KD_SL_FAIR = 4, ANN_KD_SUGGEST = 5
}
enum  ANNshrinkRule { ANN_BD_NONE = 0, ANN_BD_SIMPLE = 1, ANN_BD_CENTROID = 2, ANN_BD_SUGGEST = 3 }

Functions

ANNdist annDist (int dim, ANNpoint p, ANNpoint q)
ANNpoint annAllocPt (int dim, ANNcoord c=0)
ANNpointArray annAllocPts (int n, int dim)
void annDeallocPt (ANNpoint &p)
void annDeallocPts (ANNpointArray &pa)
ANNpoint annCopyPt (int dim, ANNpoint source)
void annMaxPtsVisit (int maxPts)
void annClose ()

Variables

const double ANN_DBL_MAX = DBL_MAX
const ANNidx ANN_NULL_IDX = -1
const ANNdist ANN_DIST_INF = FLT_MAX
const int ANNcoordPrec = 15
const ANNbool ANN_ALLOW_SELF_MATCH = ANNtrue
const int ANN_N_SPLIT_RULES = 6
const int ANN_N_SHRINK_RULES = 4

Define Documentation

#define ANN_DIFF (   x,
  y 
)    ((y) - (x))
#define ANN_POW (   v )    ((v)*(v))
#define ANN_ROOT (   x )    sqrt(x)

Definition at line 343 of file ANN.h.

#define ANN_SUM (   x,
  y 
)    ((x) + (y))
#define ANNcopyright   "David M. Mount and Sunil Arya"

Definition at line 129 of file ANN.h.

#define ANNlatestRev   "Mar 1, 2005"

Definition at line 130 of file ANN.h.

#define ANNversion   "1.0"

Definition at line 127 of file ANN.h.

#define ANNversionCmt   ""

Definition at line 128 of file ANN.h.

#define DLL_API

Definition at line 93 of file ANN.h.


Typedef Documentation

typedef float ANNcoord

Definition at line 164 of file ANN.h.

typedef float ANNdist

Definition at line 165 of file ANN.h.

Definition at line 383 of file ANN.h.

typedef int ANNidx

Definition at line 181 of file ANN.h.

typedef ANNidx* ANNidxArray

Definition at line 384 of file ANN.h.

Definition at line 708 of file ANN.h.

typedef ANNcoord* ANNpoint

Definition at line 381 of file ANN.h.

Definition at line 382 of file ANN.h.


Enumeration Type Documentation

enum ANNbool
Enumerator:
ANNfalse 
ANNtrue 

Definition at line 138 of file ANN.h.

{ANNfalse = 0, ANNtrue = 1}; // ANN boolean type (non ANSI C++)
Enumerator:
ANN_BD_NONE 
ANN_BD_SIMPLE 
ANN_BD_CENTROID 
ANN_BD_SUGGEST 

Definition at line 611 of file ANN.h.

                   {
                ANN_BD_NONE                             = 0,    // no shrinking at all (just kd-tree)
                ANN_BD_SIMPLE                   = 1,    // simple splitting
                ANN_BD_CENTROID                 = 2,    // centroid splitting
                ANN_BD_SUGGEST                  = 3};   // the authors' suggested choice
Enumerator:
ANN_KD_STD 
ANN_KD_MIDPT 
ANN_KD_FAIR 
ANN_KD_SL_MIDPT 
ANN_KD_SL_FAIR 
ANN_KD_SUGGEST 

Definition at line 602 of file ANN.h.

                  {
                ANN_KD_STD                              = 0,    // the optimized kd-splitting rule
                ANN_KD_MIDPT                    = 1,    // midpoint split
                ANN_KD_FAIR                             = 2,    // fair split
                ANN_KD_SL_MIDPT                 = 3,    // sliding midpoint splitting method
                ANN_KD_SL_FAIR                  = 4,    // sliding fair split method
                ANN_KD_SUGGEST                  = 5};   // the authors' suggestion for best

Function Documentation

ANNpoint annAllocPt ( int  dim,
ANNcoord  c = 0 
)

Definition at line 108 of file ANN.cpp.

Referenced by ANNorthRect::ANNorthRect(), annReadDump(), mitk::PointLocator::InitANN(), and ipMITKSegmentationGetCutPoints().

{
        ANNpoint p = new ANNcoord[dim];
        for (int i = 0; i < dim; i++) p[i] = c;
        return p;
}
ANNpointArray annAllocPts ( int  n,
int  dim 
)

Definition at line 115 of file ANN.cpp.

Referenced by annReadDump(), ipMITKSegmentationGetCutPoints(), and mitk::PointLocator::SetPoints().

{
        ANNpointArray pa = new ANNpoint[n];                     // allocate points
        ANNpoint          p  = new ANNcoord[n*dim];             // allocate space for coords
        for (int i = 0; i < n; i++) {
                pa[i] = &(p[i*dim]);
        }
        return pa;
}
void annClose (  )

Definition at line 221 of file kd_tree.cpp.

References KD_TRIVIAL.

{
        if (KD_TRIVIAL != NULL) {
                delete KD_TRIVIAL;
                KD_TRIVIAL = NULL;
        }
}
ANNpoint annCopyPt ( int  dim,
ANNpoint  source 
)

Definition at line 138 of file ANN.cpp.

Referenced by ANNbd_tree::ANNbd_tree(), ANNkd_tree::ANNkd_tree(), and ANNorthRect::ANNorthRect().

{
        ANNpoint p = new ANNcoord[dim];
        for (int i = 0; i < dim; i++) p[i] = source[i];
        return p;
}
void annDeallocPt ( ANNpoint p )

Definition at line 125 of file ANN.cpp.

Referenced by mitk::PointLocator::DestroyANN(), ipMITKSegmentationGetCutPoints(), ANNkd_tree::~ANNkd_tree(), and ANNorthRect::~ANNorthRect().

{
        delete [] p;
        p = NULL;
}
void annDeallocPts ( ANNpointArray pa )

Definition at line 131 of file ANN.cpp.

Referenced by mitk::PointLocator::DestroyANN(), and ipMITKSegmentationGetCutPoints().

{
        delete [] pa[0];                                                        // dealloc coordinate storage
        delete [] pa;                                                           // dealloc points
        pa = NULL;
}
ANNdist annDist ( int  dim,
ANNpoint  p,
ANNpoint  q 
)

Definition at line 44 of file ANN.cpp.

References ANN_COORD, ANN_FLOP, ANN_POW, ANN_PTS, ANN_SUM, and QuadProgPP::dist().

Referenced by ANNbruteForce::annkFRSearch(), and ANNbruteForce::annkSearch().

{
        register int d;
        register ANNcoord diff;
        register ANNcoord dist;

        dist = 0;
        for (d = 0; d < dim; d++) {
                diff = p[d] - q[d];
                dist = ANN_SUM(dist, ANN_POW(diff));
        }
        ANN_FLOP(3*dim)                                 // performance counts
        ANN_PTS(1)
        ANN_COORD(dim)
        return dist;
}
void annMaxPtsVisit ( int  maxPts )

Definition at line 195 of file ANN.cpp.

References ANNmaxPtsVisited.

{
        ANNmaxPtsVisited = maxPts;
}

Variable Documentation

const ANNbool ANN_ALLOW_SELF_MATCH = ANNtrue
const double ANN_DBL_MAX = DBL_MAX

Definition at line 124 of file ANN.h.

Referenced by ANNsampStat::reset().

const ANNdist ANN_DIST_INF = FLT_MAX

Definition at line 205 of file ANN.h.

const int ANN_N_SHRINK_RULES = 4

Definition at line 616 of file ANN.h.

const int ANN_N_SPLIT_RULES = 6

Definition at line 609 of file ANN.h.

const ANNidx ANN_NULL_IDX = -1

Definition at line 182 of file ANN.h.

const int ANNcoordPrec = 15

Definition at line 228 of file ANN.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines