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 
15  NN()
16  {
17  }
18 
20  {
21  }
22 
23  bool
24  operator<(const NN& nn) const
25  {
26  return sqrDist < nn.sqrDist;
27  }
28 
29  bool
30  operator>(const NN& nn) const
31  {
32  return sqrDist > nn.sqrDist;
33  }
34 
35  bool
36  operator<=(const NN& nn) const
37  {
38  return sqrDist <= nn.sqrDist;
39  }
40 
41  bool
42  operator>=(const NN& nn) const
43  {
44  return sqrDist >= nn.sqrDist;
45  }
46 
47  bool
48  operator==(const NN& nn) const
49  {
50  return sqrDist == nn.sqrDist && index == nn.index;
51  }
52 
53  bool
54  operator!=(const NN& nn) const
55  {
56  return sqrDist != nn.sqrDist || index != nn.index;
57  }
58 
59  operator IndexType() const
60  {
61  return index;
62  }
63 
64  operator IndexType&()
65  {
66  return index;
67  }
68 
69  operator ScalarType() const
70  {
71  return sqrDist;
72  }
73  };
74 
75 }; // namespace GfxTL
76 
77 #endif
GfxTL::NN::operator==
bool operator==(const NN &nn) const
Definition: NearestNeighbor.h:48
GfxTL::NN::operator<=
bool operator<=(const NN &nn) const
Definition: NearestNeighbor.h:36
GfxTL::NN::IndexType
IndexT IndexType
Definition: NearestNeighbor.h:11
GfxTL::NN::operator!=
bool operator!=(const NN &nn) const
Definition: NearestNeighbor.h:54
GfxTL::NN::NN
NN()
Definition: NearestNeighbor.h:15
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:30
GfxTL::NN::NN
NN(ScalarType d, IndexType i)
Definition: NearestNeighbor.h:19
GfxTL
Definition: AABox.h:9
GfxTL::NN::operator>=
bool operator>=(const NN &nn) const
Definition: NearestNeighbor.h:42
GfxTL::NN::index
IndexType index
Definition: NearestNeighbor.h:13
GfxTL::NN::operator<
bool operator<(const NN &nn) const
Definition: NearestNeighbor.h:24