IOLink  IOL_v1.1.0_release
RegionX.h
1 #pragma once
2 
3 #include <iolink/IOLinkAPI.h>
4 #include <iolink/VectorX.h>
5 
6 namespace iolink
7 {
8 
12 template <typename T>
13 class RegionX final
14 {
15 public:
16  using VectorType = VectorX<T>;
17  using SizeType = VectorX<T>;
18 
19  static RegionX fromIndex(const VectorX<T>& index);
20 
26  explicit RegionX(size_t dimension);
27 
31  RegionX(const VectorType& origin, const SizeType& size);
32 
36  static RegionX createFullRegion(const SizeType& regionSize);
37 
41  size_t dimensionCount() const;
42 
46  const VectorType& origin() const;
47 
51  const SizeType& size() const;
52 
58  VectorType min() const;
59 
63  VectorType max() const;
64 
71  size_t elementCount() const;
72 
79  bool isEmpty() const;
80 
85  bool contains(const RegionX& other) const;
86 
91  bool contains(const VectorType& position) const;
92 
97  bool intersect(const RegionX& other) const;
98 
105  RegionX intersection(const RegionX& other) const;
106 
125  RegionX extractSliceFromAxis(size_t dimension, T origin) const;
126 
127  bool operator==(const RegionX& other) const;
128  bool operator!=(const RegionX& other) const;
129 
133  std::string toString() const;
134 
135 private:
136  VectorType m_origin;
137  SizeType m_size;
138 };
139 
140 // ============================ //
141 // Extern template declarations //
142 // ============================ //
143 
144 extern template class IOLINK_API_IMPORT RegionX<uint64_t>;
145 
146 // ================= //
147 // Alias definitions //
148 // ================= //
149 
151 
152 } // end namespace iolink