MCPcopy Create free account
hub / github.com/creatale/node-dv / SearchRec

Method SearchRec

deps/tesseract/classify/kdtree.cpp:402–440  ·  view source on GitHub ↗

---------------------------------------------------------------------------*/ * Recursively accumulate the k_closest points to query_point_ into results_. * @param Level level in tree of sub-tree to be searched * @param SubTree sub-tree to be searched */

Source from the content-addressed store, hash-verified

400 * @param SubTree sub-tree to be searched
401 */
402void KDTreeSearch::SearchRec(int level, KDNODE *sub_tree) {
403 if (level >= tree_->KeySize)
404 level = 0;
405
406 if (!BoxIntersectsSearch(sb_min_, sb_max_))
407 return;
408
409 results_.insert(DistanceSquared(tree_->KeySize, tree_->KeyDesc,
410 query_point_, sub_tree->Key),
411 sub_tree->Data);
412
413 if (query_point_[level] < sub_tree->BranchPoint) {
414 if (sub_tree->Left != NULL) {
415 FLOAT32 tmp = sb_max_[level];
416 sb_max_[level] = sub_tree->LeftBranch;
417 SearchRec(NextLevel(tree_, level), sub_tree->Left);
418 sb_max_[level] = tmp;
419 }
420 if (sub_tree->Right != NULL) {
421 FLOAT32 tmp = sb_min_[level];
422 sb_min_[level] = sub_tree->RightBranch;
423 SearchRec(NextLevel(tree_, level), sub_tree->Right);
424 sb_min_[level] = tmp;
425 }
426 } else {
427 if (sub_tree->Right != NULL) {
428 FLOAT32 tmp = sb_min_[level];
429 sb_min_[level] = sub_tree->RightBranch;
430 SearchRec(NextLevel(tree_, level), sub_tree->Right);
431 sb_min_[level] = tmp;
432 }
433 if (sub_tree->Left != NULL) {
434 FLOAT32 tmp = sb_max_[level];
435 sb_max_[level] = sub_tree->LeftBranch;
436 SearchRec(NextLevel(tree_, level), sub_tree->Left);
437 sb_max_[level] = tmp;
438 }
439 }
440}
441
442
443/*---------------------------------------------------------------------------*/

Callers

nothing calls this directly

Calls 3

DistanceSquaredFunction · 0.85
NextLevelFunction · 0.85
insertMethod · 0.45

Tested by

no test coverage detected