Commit 5c43839b authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Improve box interface.

parent 319eaaa3
......@@ -125,6 +125,22 @@ namespace mln::experimental
/// \brief Returns the top-left corner point
using Impl::tl;
/// \brief Returns the x coordinate of the top-left corner point
constexpr int x() const noexcept { return this->__begin(0); }
/// \brief Returns the y coordinate of the top-left corner point
template <int d = ndim, class = std::enable_if_t<d == -1 || d >= 2>>
constexpr int y() const noexcept { return this->__begin(1); }
/// \brief Returns the z coordinate of the top-left corner point
template <int d = ndim, class = std::enable_if_t<d == -1 || d >= 3>>
constexpr int z() const noexcept { return this->__begin(2); }
/// \brief Returns the w coordinate of the top-left corner point
template <int d = ndim, class = std::enable_if_t<d == -1 || d >= 4>>
constexpr int w() const noexcept { return this->__begin(3); }
/// \brief Returns the k-th coordinate of the top-left corner point
constexpr int tl(int k) const noexcept { return this->__begin(k); }
......@@ -320,14 +336,30 @@ namespace mln::experimental
assert(width >= 0);
}
template <int d = D, class = std::enable_if_t<d == 2>>
constexpr _bstorage(int width, int height)
constexpr _bstorage(int x, int width) requires(D == 1)
: m_begin{x}
, m_end{x + width}
{
assert(width >= 0);
}
constexpr _bstorage(int width, int height) requires (D == 2)
: m_begin{0, 0}
, m_end{width, height}
{
assert(width >= 0 && height >= 0);
}
constexpr _bstorage(int x, int y, int width, int height) requires(D == 2)
: m_begin{x, y}
, m_end{x + width, y + height}
{
assert(width >= 0 && height >= 0);
}
template <int d = D, class = std::enable_if_t<d == 3>>
constexpr _bstorage(int width, int height, int depth)
: m_begin{0, 0, 0}
......@@ -336,14 +368,31 @@ namespace mln::experimental
assert(width >= 0 && height >= 0 && depth >= 0);
}
template <int d = D, class = std::enable_if_t<d == 4>>
constexpr _bstorage(int width, int height, int depth, int duration)
template <int d = D, class = std::enable_if_t<d == 3>>
constexpr _bstorage(int x, int y, int z, int width, int height, int depth)
: m_begin{x, y, z}
, m_end{x + width, y + height, z + depth}
{
assert(width >= 0 && height >= 0 && depth >= 0);
}
constexpr _bstorage(int width, int height, int depth, int duration) requires (D == 4)
: m_begin{0, 0, 0, 0}
, m_end{width, height, depth, duration}
{
assert(width >= 0 && height >= 0 && depth >= 0 && duration >= 0);
}
template <int d = D, class = std::enable_if_t<d == 4>>
constexpr _bstorage(int x, int y, int z, int w, int width, int height, int depth, int duration)
: m_begin{x, y, z, w}
, m_end{x + width, y + height, z + depth, w + duration}
{
assert(width >= 0 && height >= 0 && depth >= 0 && duration >= 0);
}
static constexpr int dim() noexcept { return D; }
constexpr const T* data() const noexcept { return m_begin.data(); }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment