8 #ifndef BOOST_GIL_VIRTUAL_LOCATOR_HPP
9 #define BOOST_GIL_VIRTUAL_LOCATOR_HPP
11 #include <boost/gil/position_iterator.hpp>
13 #include <boost/iterator/iterator_facade.hpp>
15 namespace boost {
namespace gil {
20 template <
typename Deref,
bool IsTransposed>
27 typedef Deref deref_fn_t;
30 typedef typename parent_t::coord_t coord_t;
31 typedef typename parent_t::x_coord_t x_coord_t;
32 typedef typename parent_t::y_coord_t y_coord_t;
34 typedef typename parent_t::y_iterator y_iterator;
36 template <
typename NewDeref>
struct add_deref {
45 : _p(loc.pos(),
point_t(loc.step().x,loc.step().y*y_step), loc.deref_fn()) {}
46 template <
typename D,
bool TR> virtual_2d_locator(
const virtual_2d_locator<D,TR>& loc, coord_t x_step, coord_t y_step,
bool transpose=
false)
47 : _p(loc.pos(), transpose ?
48 point_t(loc.step().x*y_step,loc.step().y*x_step) :
49 point_t(loc.step().x*x_step,loc.step().y*y_step), loc.deref_fn()) { assert(transpose==(IsTransposed!=TR));}
52 virtual_2d_locator(
const virtual_2d_locator& pl) : _p(pl._p) {}
54 bool operator==(
const this_t& p)
const {
return _p==p._p; }
57 y_iterator& y() {
return _p; }
58 x_iterator const& x()
const {
return *gil_reinterpret_cast_c<x_iterator const*>(
this); }
59 y_iterator
const& y()
const {
return _p; }
62 y_coord_t y_distance_to(
const this_t& it2, x_coord_t)
const {
return (it2.pos()[1-IsTransposed] - pos()[1-IsTransposed])/step()[1-IsTransposed]; }
63 bool is_1d_traversable(x_coord_t)
const {
return false; }
66 const point_t& pos()
const {
return _p.pos(); }
67 const point_t& step()
const {
return _p.step(); }
68 const deref_fn_t& deref_fn()
const {
return _p.deref_fn(); }
70 template <
typename D,
bool TR>
friend class virtual_2d_locator;
78 template <
typename D,
bool TR>
82 template <
typename D,
bool TR>
83 struct color_space_type<virtual_2d_locator<D,TR> > :
public color_space_type<typename virtual_2d_locator<D,TR>::parent_t> {
86 template <
typename D,
bool TR>
87 struct channel_mapping_type<virtual_2d_locator<D,TR> > :
public channel_mapping_type<typename virtual_2d_locator<D,TR>::parent_t> {
90 template <
typename D,
bool TR>
91 struct is_planar<virtual_2d_locator<D,TR> > :
public is_planar<typename virtual_2d_locator<D,TR>::parent_t> {
98 template <
typename D,
bool TR>
99 struct dynamic_x_step_type<virtual_2d_locator<D,TR> > {
100 typedef virtual_2d_locator<D,TR> type;
107 template <
typename D,
bool TR>
108 struct dynamic_y_step_type<virtual_2d_locator<D,TR> > {
109 typedef virtual_2d_locator<D,TR> type;
116 template <
typename D,
bool IsTransposed>
117 struct transposed_type<virtual_2d_locator<D,IsTransposed> > {
118 typedef virtual_2d_locator<D,1-IsTransposed> type;
base class for models of PixelLocatorConceptPixel locator is similar to a pixel iterator, but allows for 2D navigation of pixels within an image view. It has a 2D difference_type and supports random access operations like:
Definition: locator.hpp:105
An iterator that remembers its current X,Y position and invokes a function object with it upon derefe...
Definition: position_iterator.hpp:27
A 2D locator over a virtual image. Upon dereferencing, invokes a given function object passing it its...
Definition: virtual_locator.hpp:21
Composes two dereference function objects. Similar to std::unary_compose but needs to pull some typed...
Definition: utilities.hpp:105
Definition: color_convert.hpp:30
2D point both axes of which have the same dimension typeModels: Point2DConcept
Definition: concepts.hpp:42