File indexing completed on 2024-04-06 12:01:08
0001 #ifndef COMMONTOOLS_RECOALGOS_FKDPOINT_H
0002 #define COMMONTOOLS_RECOALGOS_FKDPOINT_H
0003 #include <array>
0004 #include <utility>
0005
0006
0007 template <class TYPE, int numberOfDimensions>
0008 class FKDPoint {
0009 public:
0010 FKDPoint() : theElements(), theId(0) {}
0011
0012 FKDPoint(TYPE x, TYPE y, unsigned int id = 0) {
0013 static_assert(numberOfDimensions == 2, "FKDPoint number of arguments does not match the number of dimensions");
0014
0015 theId = id;
0016 theElements[0] = x;
0017 theElements[1] = y;
0018 }
0019
0020 FKDPoint(TYPE x, TYPE y, TYPE z, unsigned int id = 0) {
0021 static_assert(numberOfDimensions == 3, "FKDPoint number of arguments does not match the number of dimensions");
0022
0023 theId = id;
0024 theElements[0] = x;
0025 theElements[1] = y;
0026 theElements[2] = z;
0027 }
0028
0029 FKDPoint(TYPE x, TYPE y, TYPE z, TYPE w, unsigned int id = 0) {
0030 static_assert(numberOfDimensions == 4, "FKDPoint number of arguments does not match the number of dimensions");
0031 theId = id;
0032 theElements[0] = x;
0033 theElements[1] = y;
0034 theElements[2] = z;
0035 theElements[3] = w;
0036 }
0037
0038
0039 TYPE& operator[](unsigned int const i) { return theElements[i]; }
0040
0041 TYPE const& operator[](unsigned int const i) const { return theElements[i]; }
0042
0043 void setDimension(unsigned int i, const TYPE& value) { theElements[i] = value; }
0044
0045 void setId(const unsigned int id) { theId = id; }
0046
0047 unsigned int getId() const { return theId; }
0048
0049 private:
0050 std::array<TYPE, numberOfDimensions> theElements;
0051 unsigned int theId;
0052 };
0053
0054 #endif