NearestNeighbor.h
Go to the documentation of this file.
1 #ifndef GfxTL__NEARESTNEIGHBOR_HEADER__
2 #define GfxTL__NEARESTNEIGHBOR_HEADER__
3 
4 namespace GfxTL
5 {
6 
7  template< class ScalarT, class IndexT = size_t >
8  struct NN
9  {
10  typedef ScalarT ScalarType;
11  typedef IndexT IndexType;
14  NN() {}
16  : sqrDist(d)
17  , index(i)
18  {}
19  bool operator<(const NN& nn) const
20  {
21  return sqrDist < nn.sqrDist;
22  }
23  bool operator>(const NN& nn) const
24  {
25  return sqrDist > nn.sqrDist;
26  }
27  bool operator<=(const NN& nn) const
28  {
29  return sqrDist <= nn.sqrDist;
30  }
31  bool operator>=(const NN& nn) const
32  {
33  return sqrDist >= nn.sqrDist;
34  }
35  bool operator==(const NN& nn) const
36  {
37  return sqrDist == nn.sqrDist && index == nn.index;
38  }
39  bool operator!=(const NN& nn) const
40  {
41  return sqrDist != nn.sqrDist || index != nn.index;
42  }
43  operator IndexType() const
44  {
45  return index;
46  }
47  operator IndexType& ()
48  {
49  return index;
50  }
51  operator ScalarType() const
52  {
53  return sqrDist;
54  }
55  };
56 
57 };
58 
59 #endif
GfxTL::NN::operator==
bool operator==(const NN &nn) const
Definition: NearestNeighbor.h:35
GfxTL::NN::operator<=
bool operator<=(const NN &nn) const
Definition: NearestNeighbor.h:27
GfxTL::NN::IndexType
IndexT IndexType
Definition: NearestNeighbor.h:11
GfxTL::NN::operator!=
bool operator!=(const NN &nn) const
Definition: NearestNeighbor.h:39
GfxTL::NN::NN
NN()
Definition: NearestNeighbor.h:14
GfxTL::NN::sqrDist
ScalarType sqrDist
Definition: NearestNeighbor.h:12
GfxTL::NN::ScalarType
ScalarT ScalarType
Definition: NearestNeighbor.h:10
GfxTL::NN
Definition: NearestNeighbor.h:8
GfxTL::NN::operator>
bool operator>(const NN &nn) const
Definition: NearestNeighbor.h:23
GfxTL::NN::NN
NN(ScalarType d, IndexType i)
Definition: NearestNeighbor.h:15
GfxTL
Definition: AABox.h:8
GfxTL::NN::operator>=
bool operator>=(const NN &nn) const
Definition: NearestNeighbor.h:31
GfxTL::NN::index
IndexType index
Definition: NearestNeighbor.h:13
GfxTL::NN::operator<
bool operator<(const NN &nn) const
Definition: NearestNeighbor.h:19