42#ifndef UFO_CONTAINER_TREE_COORD_HPP
43#define UFO_CONTAINER_TREE_COORD_HPP
46#include <ufo/numeric/detail/vec.hpp>
47#include <ufo/utility/type_traits.hpp>
56template <std::
size_t Dim,
class T =
float>
59 using coord_t =
typename Point::value_type;
60 using depth_t = unsigned;
68 template <std::
size_t D,
class U>
77 template <std::
size_t D,
class U>
87 template <std::
size_t D,
class U>
92 template <std::
size_t D,
class U>
94 :
Point(coord), depth(depth)
98 template <
class... Args,
99 std::enable_if_t<Dim ==
sizeof...(Args) && (std::is_scalar_v<Args> && ...),
101 constexpr TreeCoord(Args&&... args) noexcept :
Point(std::forward<Args>(args)...)
105 template <
class... Args, std::enable_if_t<Dim + 1 ==
sizeof...(Args) &&
106 (std::is_scalar_v<Args> && ...),
108 constexpr TreeCoord(Args&&... args) noexcept
109 :
TreeCoord(std::integral_constant<std::size_t, Dim>{}, std::forward<Args>(args)...)
114 template <std::size_t NumTimes,
class First,
class... Rest>
115 constexpr TreeCoord(std::integral_constant<std::size_t, NumTimes>, First&& first,
116 Rest&&... rest) noexcept
117 :
TreeCoord(std::integral_constant<std::size_t, NumTimes - 1>{},
118 std::forward<Rest>(rest)..., std::forward<First>(first))
122 template <
class Depth,
class... Args>
123 constexpr TreeCoord(std::integral_constant<std::size_t, 0>, Depth&& depth,
124 Args&&... args) noexcept
125 :
Point(std::forward<Args>(args)...), depth(std::forward<Depth>(depth))
134template <std::
size_t Dim,
class T>
137template <std::
size_t Dim,
class T>
140template <std::
size_t Dim,
class T>
143 return lhs.depth == rhs.depth &&
147template <std::
size_t Dim,
class T>
148constexpr bool operator!=(TreeCoord<Dim, T>
const& lhs, TreeCoord<Dim, T>
const& rhs)
150 return !(lhs == rhs);
153template <std::
size_t Dim,
class T>
154std::ostream& operator<<(std::ostream& out, TreeCoord<Dim, T>
const& tc)
156 return out << static_cast<Vec<Dim, T>
const&>(tc) <<
" d: " << tc.depth;
159using BinaryCoord = TreeCoord<1, float>;
160using QuadCoord = TreeCoord<2, float>;
161using OctCoord = TreeCoord<3, float>;
162using HexCoord = TreeCoord<4, float>;
164template <
class T =
float>
165using Coord1 = TreeCoord<1, T>;
166template <
class T =
float>
167using Coord2 = TreeCoord<2, T>;
168template <
class T =
float>
169using Coord3 = TreeCoord<3, T>;
170template <
class T =
float>
171using Coord4 = TreeCoord<4, T>;
173using Coord1f = TreeCoord<1, float>;
174using Coord2f = TreeCoord<2, float>;
175using Coord3f = TreeCoord<3, float>;
176using Coord4f = TreeCoord<4, float>;
178using Coord1d = TreeCoord<1, double>;
179using Coord2d = TreeCoord<2, double>;
180using Coord3d = TreeCoord<3, double>;
181using Coord4d = TreeCoord<4, double>;
All vision-related classes and functions.
A fixed-size arithmetic vector of up to 4 dimensions.