8 #ifndef BOOST_GIL_VIRTUAL_LOCATOR_HPP
9 #define BOOST_GIL_VIRTUAL_LOCATOR_HPP
11 #include <boost/gil/dynamic_step.hpp>
12 #include <boost/gil/position_iterator.hpp>
14 #include <boost/assert.hpp>
15 #include <boost/iterator/iterator_facade.hpp>
17 namespace boost {
namespace gil {
31 template <
typename DerefFn,
bool IsTransposed>
35 virtual_2d_locator<DerefFn, IsTransposed>,
36 position_iterator<DerefFn, IsTransposed>,
37 position_iterator<DerefFn, 1-IsTransposed>
49 using deref_fn_t = DerefFn;
51 using coord_t =
typename parent_t::coord_t;
52 using x_coord_t =
typename parent_t::x_coord_t;
53 using y_coord_t =
typename parent_t::y_coord_t;
57 template <
typename NewDerefFn>
62 static type make(
this_t const& loc, NewDerefFn
const& new_deref_fn)
64 return type(loc.pos(), loc.step(),
70 point_t
const& p = {0, 0},
71 point_t
const& step = {1, 1},
72 deref_fn_t
const& deref_fn = deref_fn_t())
73 : y_pos_(p, step, deref_fn)
76 template <
typename D,
bool TR>
78 : y_pos_(loc.pos(), point_t(loc.step().x, loc.step().y * y_step), loc.deref_fn())
81 template <
typename D,
bool TR>
85 point_t(loc.step().x * y_step, loc.step().y * x_step) :
86 point_t(loc.step().x * x_step, loc.step().y * y_step)
89 BOOST_ASSERT(transpose == (IsTransposed != TR));
92 template <
typename D,
bool TR>
98 bool operator==(
const this_t& p)
const {
return y_pos_ == p.y_pos_; }
100 auto x() -> x_iterator&
102 return *gil_reinterpret_cast<x_iterator*>(
this);
105 auto x()
const -> x_iterator
const&
107 return *gil_reinterpret_cast_c<x_iterator const*>(
this);
110 auto y() -> y_iterator& {
return y_pos_; }
111 auto y()
const -> y_iterator
const& {
return y_pos_; }
116 return (it2.pos()[1 - IsTransposed] - pos()[1 - IsTransposed])
117 / step()[1 - IsTransposed];
125 auto pos() const ->
point_t const& {
return y_pos_.pos(); }
126 auto step() const -> point_t const& {
return y_pos_.step(); }
127 auto deref_fn() const -> deref_fn_t const& {
return y_pos_.deref_fn(); }
130 template <
typename D,
bool TR>
131 friend class virtual_2d_locator;
140 template <
typename D,
bool TR>
141 struct channel_type<virtual_2d_locator<D, TR>>
142 : channel_type<typename virtual_2d_locator<D, TR>::parent_t>
146 template <
typename D,
bool TR>
147 struct color_space_type<virtual_2d_locator<D, TR>>
148 : color_space_type<typename virtual_2d_locator<D, TR>::parent_t>
152 template <
typename D,
bool TR>
153 struct channel_mapping_type<virtual_2d_locator<D, TR>>
154 : channel_mapping_type<typename virtual_2d_locator<D, TR>::parent_t>
158 template <
typename D,
bool TR>
159 struct is_planar<virtual_2d_locator<D, TR>>
160 : is_planar<typename virtual_2d_locator<D, TR>::parent_t>
168 template <
typename D,
bool TR>
169 struct dynamic_x_step_type<virtual_2d_locator<D,TR>>
171 using type = virtual_2d_locator<D,TR>;
178 template <
typename D,
bool TR>
179 struct dynamic_y_step_type<virtual_2d_locator<D,TR>>
181 using type = virtual_2d_locator<D,TR>;
188 template <
typename D,
bool IsTransposed>
189 struct transposed_type<virtual_2d_locator<D,IsTransposed>>
191 using type = virtual_2d_locator<D,1-IsTransposed>;
Composes two dereference function objects. Similar to std::unary_compose but needs to pull some alias...
Definition: utilities.hpp:131
base class for models of PixelLocatorConcept
Definition: locator.hpp:109
2D point both axes of which have the same dimension typeModels: Point2DConcept
Definition: point.hpp:36
A 2D locator over a virtual image Upon dereferencing, invokes a given function object passing it its ...
Definition: virtual_locator.hpp:39
auto y_distance_to(this_t const &it2, x_coord_t) const -> y_coord_t
Returns the y distance between two x_iterators given the difference of their x positions.
Definition: virtual_locator.hpp:114
bool is_1d_traversable(x_coord_t) const
Definition: virtual_locator.hpp:122
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
An iterator that remembers its current X,Y position and invokes a function object with it upon derefe...
Definition: position_iterator.hpp:35