CortidQCT  1.2.2.52
VolumeSize.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include <cassert>
15 #include <cstddef>
16 
17 namespace CortidQCT {
18 
22 struct VolumeSize {
24  std::size_t width = 0;
26  std::size_t height = 0;
28  std::size_t depth = 0;
29 
40  inline constexpr float operator[](std::size_t idx) const noexcept {
41  assert(idx < 3 && "Index out of bounds");
42  switch (idx) {
43  case 0:
44  return width;
45  case 1:
46  return height;
47  case 2:
48  return depth;
49  default:
50  return width; // Just to return anything
51  }
52  }
53 
64  inline std::size_t &operator[](std::size_t idx) noexcept {
65  assert(idx < 3 && "Index out of bounds");
66  switch (idx) {
67  case 0:
68  return width;
69  case 1:
70  return height;
71  case 2:
72  return depth;
73  default:
74  return width; // Just to return anything
75  }
76  }
77 
79  inline constexpr std::size_t linear() const noexcept {
80  return width * height * depth;
81  }
82 
85 
86  inline constexpr bool operator==(VolumeSize const &rhs) const {
87  return width == rhs.width && height == rhs.height && depth == rhs.depth;
88  }
89 
90  inline constexpr bool operator!=(VolumeSize const &rhs) const {
91  return !(*this == rhs);
92  }
93 
95 };
96 
97 } // namespace CortidQCT
Name namespace for CortidQCT library.
Definition: CortidQCT.h:23
std::size_t height
Size along the y-axis.
Definition: VolumeSize.h:26
std::size_t width
Size along the x-axis.
Definition: VolumeSize.h:24
constexpr std::size_t linear() const noexcept
Returns the linear size (i.e. width * height * depth)
Definition: VolumeSize.h:79
Size type for a 3D voxel.
Definition: VolumeSize.h:22
std::size_t & operator[](std::size_t idx) noexcept
subscript operator for dimension access
Definition: VolumeSize.h:64
std::size_t depth
Size along the z-axis.
Definition: VolumeSize.h:28
constexpr float operator[](std::size_t idx) const noexcept
subscript operator for dimension access
Definition: VolumeSize.h:40