Tesseract  3.02
KDTreeSearch Class Reference

List of all members.

Public Member Functions

 KDTreeSearch (KDTREE *tree, FLOAT32 *query_point, int k_closest)
 ~KDTreeSearch ()
void Search (int *result_count, FLOAT32 *distances, void **results)

Detailed Description

Definition at line 121 of file kdtree.cpp.


Constructor & Destructor Documentation

KDTreeSearch::KDTreeSearch ( KDTREE tree,
FLOAT32 query_point,
int  k_closest 
)

Definition at line 140 of file kdtree.cpp.

                                                                            :
    tree_(tree),
    query_point_(query_point) {
  results_ = new MinK<FLOAT32, void *>(MAXSEARCH, k_closest);
  sb_min_ = new FLOAT32[tree->KeySize];
  sb_max_ = new FLOAT32[tree->KeySize];
}
KDTreeSearch::~KDTreeSearch ( )

Definition at line 148 of file kdtree.cpp.

                            {
  delete results_;
  delete[] sb_min_;
  delete[] sb_max_;
}

Member Function Documentation

void KDTreeSearch::Search ( int *  result_count,
FLOAT32 distances,
void **  results 
)

Definition at line 156 of file kdtree.cpp.

                                          {
  if (tree_->Root.Left == NULL) {
    *result_count = 0;
  } else {
    for (int i = 0; i < tree_->KeySize; i++) {
      sb_min_[i] = tree_->KeyDesc[i].Min;
      sb_max_[i] = tree_->KeyDesc[i].Max;
    }
    SearchRec(0, tree_->Root.Left);
    int count = results_->elements_count();
    *result_count = count;
    for (int j = 0; j < count; j++) {
      distances[j] = (FLOAT32) sqrt((FLOAT64)results_->elements()[j].key);
      results[j] = results_->elements()[j].value;
    }
  }
}

The documentation for this class was generated from the following file: