cheshirekow  v0.1.0
Nearest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of mpblocks.
5  *
6  * mpblocks is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * mpblocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mpblocks. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef MPBLOCKS_KD_TREE_EUCLIDEAN_BLOCKS_NEAREST_H_
28 #define MPBLOCKS_KD_TREE_EUCLIDEAN_BLOCKS_NEAREST_H_
29 
30 
31 namespace mpblocks {
32 namespace kd_tree {
33 namespace euclidean {
34 namespace blocks {
35 
36 template <class Traits>
37 class Nearest
38 {
39  public:
40  typedef typename Traits::Format_t Format_t;
41  typedef typename Traits::Node Node_t;
42 
43  typedef Eigen::Matrix<Format_t,Traits::NDim,1> Point_t;
44 
48 
49  protected:
52 
53  public:
54  sigc::signal<void,Node_t*> sig_result;
55 
56  Nearest(Tree_t* tree=0):
57  m_tree(tree)
58  {}
59 
60  void setTree( Tree_t* tree )
61  { m_tree = tree; }
62 
63  void search( const Point_t& q )
64  {
65  m_search.reset();
66  if(m_tree)
67  {
69  sig_result.emit(m_search.result());
70  }
71  }
72 
73  sigc::slot<void,const Point_t&> slot_search()
74  { return sigc::mem_fun(this,&This_t::search); }
75 };
76 
77 
78 
79 
80 
81 } // namespace blocks
82 } // namespace euclidean
83 } // namespace kd_tree
84 } // namespace mpblocks
85 
86 
87 
88 
89 
90 
91 
92 
93 #endif // NEARESTNEIGHBOR_H_
a simple KDtree class
Definition: Tree.h:43
sigc::signal< void, Node_t * > sig_result
Definition: Nearest.h:54
void findNearest(const Point_t &q, NNIface_t &search)
generic NN search, specific search depends on the implementing class of the NNIface ...
Definition: Tree.hpp:91
void reset(Format_t inf=std::numeric_limits< Format_t >::max())
Definition: Nearest.hpp:39
the node class must be defined in traits since it uses the CTRP, it must derive from kd_tree::Node<Tr...
Definition: Traits.h:49
provides a search algorithm for finding the nearest point in the kd tree to some query point...
Definition: Nearest.h:38
sigc::slot< void, const Point_t & > slot_search()
Definition: Nearest.h:73
Eigen::Matrix< Format_t, Traits::NDim, 1 > Point_t
Definition: Nearest.h:43
double Format_t
number format (i.e. double, float)
Definition: Traits.h:38
euclidean::Nearest< Traits > Search_t
Definition: Nearest.h:46