CMS 3D CMS Logo

FKDPoint.h
Go to the documentation of this file.
1 #ifndef COMMONTOOLS_RECOALGOS_FKDPOINT_H
2 #define COMMONTOOLS_RECOALGOS_FKDPOINT_H
3 #include <array>
4 #include <utility>
5 
6 //a K-dimensional point to interface with the FKDTree class
7 template<class TYPE, int numberOfDimensions>
8 class FKDPoint
9 {
10 
11  public:
13  theElements(), theId(0)
14  {
15  }
16 
17  FKDPoint(TYPE x, TYPE y, unsigned int id = 0)
18  {
19  static_assert(numberOfDimensions==2,"FKDPoint number of arguments does not match the number of dimensions");
20 
21  theId = id;
22  theElements[0] = x;
23  theElements[1] = y;
24  }
25 
26  FKDPoint(TYPE x, TYPE y, TYPE z, unsigned int id = 0)
27  {
28  static_assert(numberOfDimensions==3,"FKDPoint number of arguments does not match the number of dimensions");
29 
30  theId = id;
31  theElements[0] = x;
32  theElements[1] = y;
33  theElements[2] = z;
34  }
35 
36  FKDPoint(TYPE x, TYPE y, TYPE z, TYPE w, unsigned int id = 0)
37  {
38  static_assert(numberOfDimensions==4,"FKDPoint number of arguments does not match the number of dimensions");
39  theId = id;
40  theElements[0] = x;
41  theElements[1] = y;
42  theElements[2] = z;
43  theElements[3] = w;
44  }
45 
46  // the user should check that i < numberOfDimensions
47  TYPE& operator[](unsigned int const i)
48  {
49  return theElements[i];
50  }
51 
52  TYPE const& operator[](unsigned int const i) const
53  {
54  return theElements[i];
55  }
56 
57  void setDimension(unsigned int i, const TYPE& value)
58  {
59  theElements[i] = value;
60  }
61 
62  void setId(const unsigned int id)
63  {
64  theId = id;
65  }
66 
67  unsigned int getId() const
68  {
69  return theId;
70  }
71 
72  private:
73  std::array<TYPE, numberOfDimensions> theElements;
74  unsigned int theId;
75 };
76 
77 #endif
FKDPoint(TYPE x, TYPE y, unsigned int id=0)
Definition: FKDPoint.h:17
const double w
Definition: UKUtility.cc:23
unsigned int getId() const
Definition: FKDPoint.h:67
TYPE const & operator[](unsigned int const i) const
Definition: FKDPoint.h:52
FKDPoint(TYPE x, TYPE y, TYPE z, TYPE w, unsigned int id=0)
Definition: FKDPoint.h:36
unsigned int theId
Definition: FKDPoint.h:74
FKDPoint(TYPE x, TYPE y, TYPE z, unsigned int id=0)
Definition: FKDPoint.h:26
void setDimension(unsigned int i, const TYPE &value)
Definition: FKDPoint.h:57
Definition: value.py:1
FKDPoint()
Definition: FKDPoint.h:12
TYPE & operator[](unsigned int const i)
Definition: FKDPoint.h:47
void setId(const unsigned int id)
Definition: FKDPoint.h:62
std::array< TYPE, numberOfDimensions > theElements
Definition: FKDPoint.h:73