50#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_XYZ_H
51#define LASS_GUARDIAN_OF_INCLUSION_PRIM_XYZ_H
65 static constexpr size_t dimension = 3;
69 constexpr XYZ(): value_(0) {}
96 throw util::Exception(
"Invalid parameter axis. Try 'x', 'X', 'y', 'Y', 'z' or 'Z'.", LASS_PRETTY_FUNCTION);
103 explicit constexpr XYZ(
int value): value_(value) {}
109 if (
axis.length() != 1)
111 LASS_THROW(
"Invalid parameter axis '" <<
axis <<
"'. It must be a single character.");
116 constexpr XYZ(
const XYZ& other) =
default;
117 constexpr XYZ& operator=(
const XYZ& other) =
default;
123 LASS_ASSERT(value_ >= 0 && value_ <
static_cast<int>(dimension));
124 constexpr char axes[] = {
'x',
'y',
'z' };
128 constexpr operator int()
const {
return value_; }
129 constexpr operator size_t()
const {
return static_cast<size_t>(value_); }
131 constexpr XYZ& operator++()
136 constexpr XYZ& operator--()
142 constexpr XYZ operator++(
int)
144 const XYZ result(*
this);
148 constexpr XYZ operator--(
int)
150 const XYZ result(*
this);
155 constexpr XYZ& operator+=(
int offset)
160 constexpr XYZ& operator-=(
int offset)
166 constexpr XYZ operator+(
int offset)
const
168 return XYZ(value_ + offset);
170 constexpr XYZ operator-(
int offset)
const
172 return XYZ(value_ - offset);
175 constexpr bool operator==(
XYZ other)
const
177 return value_ == other.value_;
179 constexpr bool operator==(
int other)
const
181 return static_cast<int>(value_) == other;
183 constexpr bool operator==(
size_t other)
const
185 return static_cast<size_t>(value_) == other;
187 constexpr bool operator==(
char other)
const
189 return *
this ==
XYZ(other);
191 bool operator==(
const std::string& other)
const
193 return *
this ==
XYZ(other);
196 constexpr bool operator!=(
XYZ other)
const
198 return value_ != other.value_;
200 constexpr bool operator!=(
int other)
const
202 return static_cast<int>(value_) != other;
204 constexpr bool operator!=(
size_t other)
const
206 return static_cast<size_t>(value_) != other;
208 constexpr bool operator!=(
char other)
const
210 return *
this !=
XYZ(other);
212 bool operator!=(
const std::string& other)
const
214 return *
this !=
XYZ(other);
219 typedef num::Modulo<dimension, int> TValue;
226inline constexpr bool operator==(
int a,
const XYZ& b)
233inline constexpr bool operator==(
size_t a,
const XYZ& b)
240inline constexpr bool operator==(
char a,
const XYZ& b)
247inline bool operator==(
const std::string& a,
const XYZ& b)
254inline constexpr bool operator!=(
int a,
const XYZ& b)
261inline constexpr bool operator!=(
size_t a,
const XYZ& b)
268inline constexpr bool operator!=(
char a,
const XYZ& b)
275inline bool operator!=(
const std::string& a,
const XYZ& b)
282template <
typename Char,
typename Traits>
283std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& stream,
const XYZ& xyz)
285 stream << xyz.axis();
295#define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_XYZ
296#ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
cyclic iterator over xyz indices
XYZ(const std::string &axis)
initializes iterator to an axis by character: "x", "y" or "z".
constexpr XYZ(int value)
initializes iterator to an axis by number.
constexpr XYZ(char axis)
initializes iterator to an axis by character: 'x', 'y' or 'z'.
constexpr char axis() const
return axis by character: 'x', 'y' or 'z'.
constexpr XYZ()
intializes iterator to x axis.
type of all exceptions in lass
set of geometrical primitives
Library for Assembled Shared Sources.