CVB++ 14.0
decl_image_plane.hpp
1#pragma once
2
3#include <algorithm>
4#include <memory>
5#include <new>
6#include <system_error>
7#include <utility>
8
9#include "../_cexports/c_img.h"
10#include "../_cexports/c_utilities.h"
11
12#include "../global.hpp"
13#include "../point_2d.hpp"
14
15#include "../data_type.hpp"
16#include "../iarray.hpp"
17#include "../image_plane_contiguous_iterator.hpp"
18#include "../image_plane_linear_iterator.hpp"
19#include "../image_plane_vpat_iterator.hpp"
20
21
22namespace Cvb
23{
24
25CVB_BEGIN_INLINE_NS
26
27
28
30
31class ImagePlane final
32 : public IArray
33{
35 friend Image;
37
38 public:
39
40
42
46 ImagePlane(ImagePlane && other) noexcept = default;
47
48
50
56 ImagePlane(const class Plane & plane);
57
58
59
60 ~ImagePlane() = default;
61
62 ImagePlane & operator=(ImagePlane && other) noexcept = default;
63
64
66
72 void* Handle() const noexcept;
73
75
84 bool TryContiguousAccess(std::uint8_t *&basePtr) const noexcept;
85
87
94 std::uint8_t *ContiguousAccess() const;
95
97
108 bool TryLinearAccess(LinearAccessData & linearAccessData) const noexcept;
109
111
119
120
121
122 class DataType DataType() const noexcept override;
123
124 int Rank() const noexcept
125 {
126 return 2;
127 }
128
130
134 const Image& Parent() const noexcept;
135
137
146 class Vpat Vpat() const;
147
148
149
151
155 std::unique_ptr<Image> Map() const;
156
157
158
160
165 double GetPixel(Point2D<int> position) const;
166
167
169 int Plane() const noexcept
170 {
171 return plane_;
172 }
173
175
181 template <class Type>
182 ContiguousIterator<Type> BeginContiguous();
183
185
191 template <class Type>
192 ContiguousIterator<Type> EndContiguous();
193
195
201 template <class Type>
203
205
211 template <class Type>
213
215
221 template <class Type>
222 ContiguousConstIterator<Type> CBeginContiguous() const;
223
225
231 template <class Type>
232 ContiguousConstIterator<Type> BeginContiguous() const
233 {
234 return CBeginContiguous<Type>();
235 }
236
238
244 template <class Type>
245 ContiguousConstIterator<Type> CEndContiguous() const;
246
248
254 template <class Type>
255 ContiguousConstIterator<Type> EndContiguous() const
256 {
257 return CEndContiguous<Type>();
258 }
259
261
267 template <class Type>
269
271
277 template <class Type>
279 {
280 return CRBeginContiguous<Type>();
281 }
282
284
290 template <class Type>
292
294
300 template <class Type>
302 {
303 return CEndContiguous<Type>();
304 }
305
307
313 template <class Type>
314 LinearIterator<Type> BeginLinear();
315
317
323 template <class Type>
324 LinearIterator<Type> EndLinear();
325
327
333 template <class Type>
335
337
343 template <class Type>
345
347
353 template <class Type>
354 LinearConstIterator<Type> CBeginLinear() const;
355
357
363 template <class Type>
364 LinearConstIterator<Type> BeginLinear() const
365 {
366 return CBeginLinear<Type>();
367 }
368
370
376 template <class Type>
377 LinearConstIterator<Type> CEndLinear() const;
378
380
386 template <class Type>
387 LinearConstIterator<Type> EndLinear() const
388 {
389 return CEndLinear<Type>();
390 }
391
393
399 template <class Type>
401
403
409 template <class Type>
411 {
412 return CRBeginLinear<Type>();
413 }
414
416
422 template <class Type>
424
426
432 template <class Type>
434 {
435 return CREndLinear<Type>();
436 }
437
439
445 template <class Type>
446 VpatIterator<Type> BeginVpat();
447
449
455 template <class Type>
456 VpatIterator<Type> EndVpat();
457
459
465 template <class Type>
467
469
475 template <class Type>
477
479
485 template <class Type>
486 VpatConstIterator<Type> CBeginVpat() const;
487
489
495 template <class Type>
496 VpatConstIterator<Type> BeginVpat() const
497 {
498 return CBeginVpat<Type>();
499 }
500
502
508 template <class Type>
509 VpatConstIterator<Type> CEndVpat() const;
510
512
518 template <class Type>
519 VpatConstIterator<Type> EndVpat() const
520 {
521 return CEndVpat<Type>();
522 }
523
525
531 template <class Type>
533
535
541 template <class Type>
543 {
544 return CRBeginVpat<Type>();
545 }
546
548
554 template <class Type>
556
558
564 template <class Type>
566 {
567 return CREndVpat<Type>();
568 }
569
570 private:
571
572
573
574 ImagePlane(int plane, const Image & image) noexcept
575 : plane_(plane)
576 , parentImage_(&image)
577 {
578 }
579
580 int plane_;
581
582 const Image * parentImage_ = nullptr;
583
585};
586
587template <>
588struct PlaneTraits<ImagePlane>
589{
590 using PlaneT = ImagePlane;
591 using TypeList = DispatchableTypeList<std::uint8_t, std::int8_t, std::uint16_t, std::int16_t, std::uint32_t,
592 std::int32_t, std::uint64_t, std::int64_t, float, double>;
593
594 static constexpr bool HasVpat = true;
595
596 static int GetWidth(const ImagePlane &plane);
597 static int GetHeight(const ImagePlane &plane);
598
599 static Cvb::DataType GetDataType(const ImagePlane &plane)
600 {
601 return plane.DataType();
602 }
603
604 static constexpr int GetRank(const ImagePlane &)
605 {
606 return 2;
607 }
608
609 static Cvb::Vpat GetVpat(const ImagePlane &plane)
610 {
611 return plane.Vpat();
612 }
613};
614
615CVB_END_INLINE_NS
616
617}
618
619
620
621
622
Data type description for an image plane.
Definition: data_type.hpp:28
Array interface.
Definition: iarray.hpp:16
The Common Vision Blox image.
Definition: decl_image.hpp:45
Image plane information container.
Definition: decl_image_plane.hpp:33
std::uint8_t * ContiguousAccess() const
Attempt a contiguous access on the plane's pixels.
Definition: detail_image_plane.hpp:56
VpatConstIterator< Type > EndVpat() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:519
VpatConstIterator< Type > BeginVpat() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:496
std::reverse_iterator< LinearConstIterator< Type > > REndLinear() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:433
VpatIterator< Type > EndVpat()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:295
LinearConstIterator< Type > BeginLinear() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:364
ContiguousConstIterator< Type > CBeginContiguous() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:214
std::reverse_iterator< LinearIterator< Type > > RBeginLinear()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:252
std::reverse_iterator< ContiguousConstIterator< Type > > RBeginContiguous() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:278
ImagePlane(ImagePlane &&other) noexcept=default
Move constructor.
std::reverse_iterator< ContiguousIterator< Type > > REndContiguous()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:208
VpatConstIterator< Type > CEndVpat() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:321
ContiguousIterator< Type > BeginContiguous()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:189
ContiguousIterator< Type > EndContiguous()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:195
std::reverse_iterator< VpatConstIterator< Type > > RBeginVpat() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:542
LinearConstIterator< Type > EndLinear() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:387
bool TryLinearAccess(LinearAccessData &linearAccessData) const noexcept
Attempt a linear access on the plane's pixels.
Definition: detail_image_plane.hpp:64
std::reverse_iterator< VpatConstIterator< Type > > CRBeginVpat() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:328
VpatConstIterator< Type > CBeginVpat() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:315
std::reverse_iterator< LinearConstIterator< Type > > CREndLinear() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:283
int Rank() const noexcept
Gets the number of dimensions for this array.
Definition: decl_image_plane.hpp:124
LinearConstIterator< Type > CEndLinear() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:270
VpatIterator< Type > BeginVpat()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:289
std::reverse_iterator< LinearConstIterator< Type > > CRBeginLinear() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:277
std::reverse_iterator< VpatConstIterator< Type > > CREndVpat() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:334
std::reverse_iterator< LinearConstIterator< Type > > RBeginLinear() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:410
std::reverse_iterator< ContiguousConstIterator< Type > > CRBeginContiguous() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:227
LinearIterator< Type > EndLinear()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:245
std::unique_ptr< Image > Map() const
Create a map from a single image plane that shares its memory with the original plane.
Definition: detail_image_plane.hpp:100
ContiguousConstIterator< Type > BeginContiguous() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:232
bool TryContiguousAccess(std::uint8_t *&basePtr) const noexcept
Attempt a contiguous access on the plane's pixels.
Definition: detail_image_plane.hpp:41
std::reverse_iterator< VpatIterator< Type > > REndVpat()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:308
std::reverse_iterator< ContiguousIterator< Type > > RBeginContiguous()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:202
std::reverse_iterator< VpatConstIterator< Type > > REndVpat() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:565
double GetPixel(Point2D< int > position) const
Gets the pixel value at the given position.
Definition: detail_image_plane.hpp:108
ContiguousConstIterator< Type > CEndContiguous() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:220
ContiguousConstIterator< Type > EndContiguous() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:255
std::reverse_iterator< VpatIterator< Type > > RBeginVpat()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:302
void * Handle() const noexcept
Classic API image handle.
Definition: detail_image_plane.hpp:36
const Image & Parent() const noexcept
Image to which this plane descriptor refers to.
Definition: detail_image_plane.hpp:87
LinearIterator< Type > BeginLinear()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:239
LinearConstIterator< Type > CBeginLinear() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:264
std::reverse_iterator< LinearIterator< Type > > REndLinear()
Get iterator access to the plane.
Definition: detail_image_plane.hpp:258
std::reverse_iterator< ContiguousConstIterator< Type > > REndContiguous() const
Get iterator access to the plane.
Definition: decl_image_plane.hpp:301
std::reverse_iterator< ContiguousConstIterator< Type > > CREndContiguous() const
Get iterator access to the plane.
Definition: detail_image_plane.hpp:233
Linear access properties.
Definition: decl_linear_access.hpp:25
Plane information container.
Definition: decl_plane.hpp:28
Multi-purpose 2D vector class.
Definition: point_2d.hpp:20
Virtual Pixel Access Table.
Definition: decl_vpat.hpp:24
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24