File indexing completed on 2025-01-18 09:36:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_PIXEL_LOCATOR_HPP
0009 #define BOOST_GIL_CONCEPTS_PIXEL_LOCATOR_HPP
0010
0011 #include <boost/gil/concepts/basic.hpp>
0012 #include <boost/gil/concepts/concept_check.hpp>
0013 #include <boost/gil/concepts/fwd.hpp>
0014 #include <boost/gil/concepts/pixel.hpp>
0015 #include <boost/gil/concepts/pixel_dereference.hpp>
0016 #include <boost/gil/concepts/pixel_iterator.hpp>
0017 #include <boost/gil/concepts/point.hpp>
0018 #include <boost/gil/concepts/detail/utility.hpp>
0019
0020 #include <cstddef>
0021 #include <iterator>
0022 #include <type_traits>
0023
0024 #if defined(BOOST_CLANG)
0025 #pragma clang diagnostic push
0026 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0027 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0028 #endif
0029
0030 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0031 #pragma GCC diagnostic push
0032 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0033 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
0034 #endif
0035
0036 namespace boost { namespace gil {
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103 template <typename Loc>
0104 struct RandomAccessNDLocatorConcept
0105 {
0106 void constraints()
0107 {
0108 gil_function_requires<Regular<Loc>>();
0109
0110
0111
0112 using value_type = typename Loc::value_type;
0113 ignore_unused_variable_warning(value_type{});
0114
0115
0116 using reference = typename Loc::reference;
0117
0118
0119
0120 using difference_type = typename Loc::difference_type;
0121 ignore_unused_variable_warning(difference_type{});
0122
0123
0124 using cached_location_t = typename Loc::cached_location_t;
0125 ignore_unused_variable_warning(cached_location_t{});
0126
0127
0128 using const_t = typename Loc::const_t;
0129 ignore_unused_variable_warning(const_t{});
0130
0131
0132 using point_t = typename Loc::point_t;
0133 ignore_unused_variable_warning(point_t{});
0134
0135 static std::size_t const N = Loc::num_dimensions; ignore_unused_variable_warning(N);
0136
0137 using first_it_type = typename Loc::template axis<0>::iterator;
0138 using last_it_type = typename Loc::template axis<N-1>::iterator;
0139 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type>>();
0140 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type>>();
0141
0142
0143
0144 gil_function_requires<PointNDConcept<point_t>>();
0145 static_assert(point_t::num_dimensions == N, "");
0146 static_assert(std::is_same
0147 <
0148 typename std::iterator_traits<first_it_type>::difference_type,
0149 typename point_t::template axis<0>::coord_t
0150 >::value, "");
0151 static_assert(std::is_same
0152 <
0153 typename std::iterator_traits<last_it_type>::difference_type,
0154 typename point_t::template axis<N-1>::coord_t
0155 >::value, "");
0156
0157 difference_type d;
0158 loc += d;
0159 loc -= d;
0160 loc = loc + d;
0161 loc = loc - d;
0162 reference r1 = loc[d]; ignore_unused_variable_warning(r1);
0163 reference r2 = *loc; ignore_unused_variable_warning(r2);
0164 cached_location_t cl = loc.cache_location(d); ignore_unused_variable_warning(cl);
0165 reference r3 = loc[d]; ignore_unused_variable_warning(r3);
0166
0167 first_it_type fi = loc.template axis_iterator<0>();
0168 fi = loc.template axis_iterator<0>(d);
0169 last_it_type li = loc.template axis_iterator<N-1>();
0170 li = loc.template axis_iterator<N-1>(d);
0171
0172 using deref_t = PixelDereferenceAdaptorArchetype<typename Loc::value_type>;
0173 using dtype = typename Loc::template add_deref<deref_t>::type;
0174
0175
0176 }
0177 Loc loc;
0178 };
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220 template <typename Loc>
0221 struct RandomAccess2DLocatorConcept
0222 {
0223 void constraints()
0224 {
0225 gil_function_requires<RandomAccessNDLocatorConcept<Loc>>();
0226 static_assert(Loc::num_dimensions == 2, "");
0227
0228 using dynamic_x_step_t = typename dynamic_x_step_type<Loc>::type;
0229 using dynamic_y_step_t = typename dynamic_y_step_type<Loc>::type;
0230 using transposed_t = typename transposed_type<Loc>::type;
0231
0232 using cached_location_t = typename Loc::cached_location_t;
0233 gil_function_requires<Point2DConcept<typename Loc::point_t>>();
0234
0235 using x_iterator = typename Loc::x_iterator;
0236 using y_iterator = typename Loc::y_iterator;
0237 using x_coord_t = typename Loc::x_coord_t;
0238 using y_coord_t = typename Loc::y_coord_t;
0239
0240 x_coord_t xd = 0; ignore_unused_variable_warning(xd);
0241 y_coord_t yd = 0; ignore_unused_variable_warning(yd);
0242
0243 typename Loc::difference_type d;
0244 typename Loc::reference r=loc(xd,yd); ignore_unused_variable_warning(r);
0245
0246 dynamic_x_step_t loc2(dynamic_x_step_t(), yd);
0247 dynamic_x_step_t loc3(dynamic_x_step_t(), xd, yd);
0248
0249 using dynamic_xy_step_transposed_t = typename dynamic_y_step_type
0250 <
0251 typename dynamic_x_step_type<transposed_t>::type
0252 >::type;
0253 dynamic_xy_step_transposed_t loc4(loc, xd,yd,true);
0254
0255 bool is_contiguous = loc.is_1d_traversable(xd);
0256 ignore_unused_variable_warning(is_contiguous);
0257
0258 loc.y_distance_to(loc, xd);
0259
0260 loc = loc.xy_at(d);
0261 loc = loc.xy_at(xd, yd);
0262
0263 x_iterator xit = loc.x_at(d);
0264 xit = loc.x_at(xd, yd);
0265 xit = loc.x();
0266
0267 y_iterator yit = loc.y_at(d);
0268 yit = loc.y_at(xd, yd);
0269 yit = loc.y();
0270
0271 cached_location_t cl = loc.cache_location(xd, yd);
0272 ignore_unused_variable_warning(cl);
0273 }
0274 Loc loc;
0275 };
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290 template <typename Loc>
0291 struct PixelLocatorConcept
0292 {
0293 void constraints()
0294 {
0295 gil_function_requires<RandomAccess2DLocatorConcept<Loc>>();
0296 gil_function_requires<PixelIteratorConcept<typename Loc::x_iterator>>();
0297 gil_function_requires<PixelIteratorConcept<typename Loc::y_iterator>>();
0298 using coord_t = typename Loc::coord_t;
0299 static_assert(std::is_same<typename Loc::x_coord_t, typename Loc::y_coord_t>::value, "");
0300 }
0301 Loc loc;
0302 };
0303
0304 namespace detail {
0305
0306
0307 template <typename Loc>
0308 struct RandomAccessNDLocatorIsMutableConcept
0309 {
0310 void constraints()
0311 {
0312 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept
0313 <
0314 typename Loc::template axis<0>::iterator
0315 >>();
0316 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept
0317 <
0318 typename Loc::template axis<Loc::num_dimensions-1>::iterator
0319 >>();
0320
0321 typename Loc::difference_type d; initialize_it(d);
0322 typename Loc::value_type v; initialize_it(v);
0323 typename Loc::cached_location_t cl = loc.cache_location(d);
0324 *loc = v;
0325 loc[d] = v;
0326 loc[cl] = v;
0327 }
0328 Loc loc;
0329 };
0330
0331
0332 template <typename Loc>
0333 struct RandomAccess2DLocatorIsMutableConcept
0334 {
0335 void constraints()
0336 {
0337 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc>>();
0338 typename Loc::x_coord_t xd = 0; ignore_unused_variable_warning(xd);
0339 typename Loc::y_coord_t yd = 0; ignore_unused_variable_warning(yd);
0340 typename Loc::value_type v; initialize_it(v);
0341 loc(xd, yd) = v;
0342 }
0343 Loc loc;
0344 };
0345
0346 }
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357 template <typename Loc>
0358 struct MutableRandomAccessNDLocatorConcept
0359 {
0360 void constraints()
0361 {
0362 gil_function_requires<RandomAccessNDLocatorConcept<Loc>>();
0363 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc>>();
0364 }
0365 };
0366
0367
0368
0369
0370
0371
0372
0373
0374 template <typename Loc>
0375 struct MutableRandomAccess2DLocatorConcept
0376 {
0377 void constraints()
0378 {
0379 gil_function_requires<RandomAccess2DLocatorConcept<Loc>>();
0380 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc>>();
0381 }
0382 };
0383
0384
0385
0386
0387
0388
0389
0390
0391 template <typename Loc>
0392 struct MutablePixelLocatorConcept
0393 {
0394 void constraints()
0395 {
0396 gil_function_requires<PixelLocatorConcept<Loc>>();
0397 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc>>();
0398 }
0399 };
0400
0401 }}
0402
0403 #if defined(BOOST_CLANG)
0404 #pragma clang diagnostic pop
0405 #endif
0406
0407 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0408 #pragma GCC diagnostic pop
0409 #endif
0410
0411 #endif