File indexing completed on 2025-01-18 09:36:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_IMAGE_VIEW_HPP
0009 #define BOOST_GIL_CONCEPTS_IMAGE_VIEW_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/pixel_locator.hpp>
0018 #include <boost/gil/concepts/point.hpp>
0019 #include <boost/gil/concepts/detail/utility.hpp>
0020
0021 #include <cstddef>
0022 #include <iterator>
0023 #include <type_traits>
0024
0025 #if defined(BOOST_CLANG)
0026 #pragma clang diagnostic push
0027 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0028 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0029 #endif
0030
0031 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0032 #pragma GCC diagnostic push
0033 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0034 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
0035 #endif
0036
0037 namespace boost { namespace gil {
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 template <typename View>
0103 struct RandomAccessNDImageViewConcept
0104 {
0105 void constraints()
0106 {
0107 gil_function_requires<Regular<View>>();
0108
0109 using value_type = typename View::value_type;
0110 using reference = typename View::reference;
0111 using pointer = typename View::pointer;
0112 using difference_type = typename View::difference_type;
0113 using const_t = typename View::const_t;
0114 using point_t = typename View::point_t;
0115 using locator = typename View::locator;
0116 using iterator = typename View::iterator;
0117 using const_iterator = typename View::const_iterator;
0118 using reverse_iterator = typename View::reverse_iterator;
0119 using size_type = typename View::size_type;
0120 static const std::size_t N=View::num_dimensions;
0121
0122 gil_function_requires<RandomAccessNDLocatorConcept<locator>>();
0123 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<iterator>>();
0124 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<reverse_iterator>>();
0125
0126 using first_it_type = typename View::template axis<0>::iterator;
0127 using last_it_type = typename View::template axis<N-1>::iterator;
0128 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type>>();
0129 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type>>();
0130
0131
0132
0133
0134
0135 gil_function_requires<PointNDConcept<point_t>>();
0136 static_assert(point_t::num_dimensions == N, "");
0137 static_assert(std::is_same
0138 <
0139 typename std::iterator_traits<first_it_type>::difference_type,
0140 typename point_t::template axis<0>::coord_t
0141 >::value, "");
0142 static_assert(std::is_same
0143 <
0144 typename std::iterator_traits<last_it_type>::difference_type,
0145 typename point_t::template axis<N-1>::coord_t
0146 >::value, "");
0147
0148 point_t p;
0149 locator lc;
0150 iterator it;
0151 reverse_iterator rit;
0152 difference_type d; detail::initialize_it(d); ignore_unused_variable_warning(d);
0153
0154 View(p,lc);
0155
0156 p = view.dimensions();
0157 lc = view.pixels();
0158 size_type sz = view.size(); ignore_unused_variable_warning(sz);
0159 bool is_contiguous = view.is_1d_traversable();
0160 ignore_unused_variable_warning(is_contiguous);
0161
0162 it = view.begin();
0163 it = view.end();
0164 rit = view.rbegin();
0165 rit = view.rend();
0166
0167 reference r1 = view[d]; ignore_unused_variable_warning(r1);
0168 reference r2 = view(p); ignore_unused_variable_warning(r2);
0169
0170
0171 first_it_type fi = view.template axis_iterator<0>(p);
0172 ignore_unused_variable_warning(fi);
0173 last_it_type li = view.template axis_iterator<N-1>(p);
0174 ignore_unused_variable_warning(li);
0175
0176 using deref_t = PixelDereferenceAdaptorArchetype<typename View::value_type>;
0177 using dtype = typename View::template add_deref<deref_t>::type;
0178 }
0179 View view;
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 View>
0221 struct RandomAccess2DImageViewConcept
0222 {
0223 void constraints()
0224 {
0225 gil_function_requires<RandomAccessNDImageViewConcept<View>>();
0226 static_assert(View::num_dimensions == 2, "");
0227
0228
0229 gil_function_requires<RandomAccess2DLocatorConcept<typename View::locator>>();
0230
0231 using dynamic_x_step_t = typename dynamic_x_step_type<View>::type;
0232 using dynamic_y_step_t = typename dynamic_y_step_type<View>::type;
0233 using transposed_t = typename transposed_type<View>::type;
0234 using x_iterator = typename View::x_iterator;
0235 using y_iterator = typename View::y_iterator;
0236 using x_coord_t = typename View::x_coord_t;
0237 using y_coord_t = typename View::y_coord_t;
0238 using xy_locator = typename View::xy_locator;
0239
0240 x_coord_t xd = 0; ignore_unused_variable_warning(xd);
0241 y_coord_t yd = 0; ignore_unused_variable_warning(yd);
0242 x_iterator xit;
0243 y_iterator yit;
0244 typename View::point_t d;
0245
0246 View(xd, yd, xy_locator());
0247
0248 xy_locator lc = view.xy_at(xd, yd);
0249 lc = view.xy_at(d);
0250
0251 typename View::reference r = view(xd, yd);
0252 ignore_unused_variable_warning(r);
0253 xd = view.width();
0254 yd = view.height();
0255
0256 xit = view.x_at(d);
0257 xit = view.x_at(xd,yd);
0258 xit = view.row_begin(xd);
0259 xit = view.row_end(xd);
0260
0261 yit = view.y_at(d);
0262 yit = view.y_at(xd,yd);
0263 yit = view.col_begin(xd);
0264 yit = view.col_end(xd);
0265 }
0266 View view;
0267 };
0268
0269
0270
0271
0272
0273 template <typename View>
0274 struct CollectionImageViewConcept
0275 {
0276 void constraints()
0277 {
0278 using value_type = typename View::value_type;
0279 using iterator = typename View::iterator;
0280 using const_iterator = typename View::const_iterator;
0281 using reference = typename View::reference;
0282 using const_reference = typename View::const_reference;
0283 using pointer = typename View::pointer;
0284 using difference_type = typename View::difference_type;
0285 using size_type= typename View::size_type;
0286
0287 iterator i;
0288 i = view1.begin();
0289 i = view2.end();
0290
0291 const_iterator ci;
0292 ci = view1.begin();
0293 ci = view2.end();
0294
0295 size_type s;
0296 s = view1.size();
0297 s = view2.size();
0298 ignore_unused_variable_warning(s);
0299
0300 view1.empty();
0301
0302 view1.swap(view2);
0303 }
0304 View view1;
0305 View view2;
0306 };
0307
0308
0309
0310
0311
0312 template <typename View>
0313 struct ForwardCollectionImageViewConcept
0314 {
0315 void constraints()
0316 {
0317 gil_function_requires<CollectionImageViewConcept<View>>();
0318
0319 using reference = typename View::reference;
0320 using const_reference = typename View::const_reference;
0321
0322 reference r = view.front();
0323 ignore_unused_variable_warning(r);
0324
0325 const_reference cr = view.front();
0326 ignore_unused_variable_warning(cr);
0327 }
0328 View view;
0329 };
0330
0331
0332
0333
0334
0335 template <typename View>
0336 struct ReversibleCollectionImageViewConcept
0337 {
0338 void constraints()
0339 {
0340 gil_function_requires<CollectionImageViewConcept<View>>();
0341
0342 using reverse_iterator = typename View::reverse_iterator;
0343 using reference = typename View::reference;
0344 using const_reference = typename View::const_reference;
0345
0346 reverse_iterator i;
0347 i = view.rbegin();
0348 i = view.rend();
0349
0350 reference r = view.back();
0351 ignore_unused_variable_warning(r);
0352
0353 const_reference cr = view.back();
0354 ignore_unused_variable_warning(cr);
0355 }
0356 View view;
0357 };
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374 template <typename View>
0375 struct ImageViewConcept
0376 {
0377 void constraints()
0378 {
0379 gil_function_requires<RandomAccess2DImageViewConcept<View>>();
0380
0381
0382 gil_function_requires<PixelLocatorConcept<typename View::xy_locator>>();
0383
0384 static_assert(std::is_same<typename View::x_coord_t, typename View::y_coord_t>::value, "");
0385
0386 using coord_t = typename View::coord_t;
0387 std::size_t num_chan = view.num_channels(); ignore_unused_variable_warning(num_chan);
0388 }
0389 View view;
0390 };
0391
0392 namespace detail {
0393
0394
0395 template <typename View>
0396 struct RandomAccessNDImageViewIsMutableConcept
0397 {
0398 void constraints()
0399 {
0400 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<typename View::locator>>();
0401
0402 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::iterator>>();
0403
0404 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept
0405 <
0406 typename View::reverse_iterator
0407 >>();
0408
0409 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept
0410 <
0411 typename View::template axis<0>::iterator
0412 >>();
0413
0414 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept
0415 <
0416 typename View::template axis<View::num_dimensions - 1>::iterator
0417 >>();
0418
0419 typename View::difference_type diff;
0420 initialize_it(diff);
0421 ignore_unused_variable_warning(diff);
0422
0423 typename View::point_t pt;
0424 typename View::value_type v;
0425 initialize_it(v);
0426
0427 view[diff] = v;
0428 view(pt) = v;
0429 }
0430 View view;
0431 };
0432
0433
0434 template <typename View>
0435 struct RandomAccess2DImageViewIsMutableConcept
0436 {
0437 void constraints()
0438 {
0439 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View>>();
0440 typename View::x_coord_t xd = 0; ignore_unused_variable_warning(xd);
0441 typename View::y_coord_t yd = 0; ignore_unused_variable_warning(yd);
0442 typename View::value_type v; initialize_it(v);
0443 view(xd, yd) = v;
0444 }
0445 View view;
0446 };
0447
0448
0449 template <typename View>
0450 struct PixelImageViewIsMutableConcept
0451 {
0452 void constraints()
0453 {
0454 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View>>();
0455 }
0456 };
0457
0458 }
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469 template <typename View>
0470 struct MutableRandomAccessNDImageViewConcept
0471 {
0472 void constraints()
0473 {
0474 gil_function_requires<RandomAccessNDImageViewConcept<View>>();
0475 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View>>();
0476 }
0477 };
0478
0479
0480
0481
0482
0483
0484
0485
0486 template <typename View>
0487 struct MutableRandomAccess2DImageViewConcept
0488 {
0489 void constraints()
0490 {
0491 gil_function_requires<RandomAccess2DImageViewConcept<View>>();
0492 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View>>();
0493 }
0494 };
0495
0496
0497
0498
0499
0500
0501
0502
0503 template <typename View>
0504 struct MutableImageViewConcept
0505 {
0506 void constraints()
0507 {
0508 gil_function_requires<ImageViewConcept<View>>();
0509 gil_function_requires<detail::PixelImageViewIsMutableConcept<View>>();
0510 }
0511 };
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521 template <typename V1, typename V2>
0522 struct views_are_compatible
0523 : pixels_are_compatible<typename V1::value_type, typename V2::value_type>
0524 {
0525 };
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538 template <typename V1, typename V2>
0539 struct ViewsCompatibleConcept
0540 {
0541 void constraints()
0542 {
0543 static_assert(views_are_compatible<V1, V2>::value, "");
0544 }
0545 };
0546
0547 }}
0548
0549 #if defined(BOOST_CLANG)
0550 #pragma clang diagnostic pop
0551 #endif
0552
0553 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0554 #pragma GCC diagnostic pop
0555 #endif
0556
0557 #endif