msl 1.3.0
Loading...
Searching...
No Matches
MaskBase.h
Go to the documentation of this file.
1// Copyright 2026 Julien Lamy, ICube, Université de Strasbourg-CNRS.
2// Part of msl, distributed under the terms of the MIT license.
3
4#ifndef _31e10e07_6c23_4af5_aac6_117908c89aaf
5#define _31e10e07_6c23_4af5_aac6_117908c89aaf
6
7#include <vector>
8
9#include "msl/Vector.h"
10
11namespace msl
12{
13
15template<typename T>
17{
18public:
20 using Point = Vector2l;
22 using Shape = Vector2l;
23
25 using Points = std::vector<Point>;
26
28 static bool lessX(Point const & p, Point const & q);
29
31 static bool lessKy(Point const & p, Point const & q);
32
34 static bool lessY(Point const & p, Point const & q);
35
37 static bool lessKz(Point const & p, Point const & q);
38
40 MaskBase(Shape const & shape={}, T value=T());
41
42 MaskBase(MaskBase const &) = default;
43 MaskBase(MaskBase &&) = default;
44 MaskBase & operator=(MaskBase const &) = default;
45 MaskBase & operator=(MaskBase &&) = default;
46 virtual ~MaskBase() = default;
47
49 std::size_t size() const;
50
52 Shape const & shape() const;
53
55 void fill(T value);
56
61 T const & operator[](Point const & p) const;
62
67 T & operator[](Point const & p);
68
69protected:
72
74 std::vector<T> _mask;
75
77 std::size_t _index(Point const & p) const;
78};
79
80}
81
82#include "MaskBase.txx"
83
84#endif // _31e10e07_6c23_4af5_aac6_117908c89aaf
Base class for masks, boolean and non-boolean.
Definition MaskBase.h:17
static bool lessKy(Point const &p, Point const &q)
Compare points according to their ky coordinate.
static bool lessX(Point const &p, Point const &q)
Compare points according to their x coordinate.
Shape const & shape() const
Return the shape of the mask.
std::size_t _index(Point const &p) const
Return the linear index corresponding to a point.
std::size_t size() const
Return the total number of points in the mask.
std::vector< Point > Points
Container of Point.
Definition MaskBase.h:25
Shape _shape
Shape of the mask.
Definition MaskBase.h:71
static bool lessY(Point const &p, Point const &q)
Compare points according to their y coordinate.
static bool lessKz(Point const &p, Point const &q)
Compare points according to their kz coordinate.
T const & operator[](Point const &p) const
Read-only access to a mask item.
T & operator[](Point const &p)
Read/write access to a mask item.
MaskBase(Shape const &shape={}, T value=T())
Create a constant mask.
std::vector< T > _mask
Linear container of mask points.
Definition MaskBase.h:74
void fill(T value)
Fill all points of mask with value.
Vector2l Point
2D point, as (column, row), (x, y) or (ky,kz)
Definition MaskBase.h:20
Vector2l Shape
Shape of the mask, as (column, row), (x, y) or (ky,kz).
Definition MaskBase.h:22
Top-level namespace of the msl library.
Definition acceleration.h:17
Vector< 2, long > Vector2l
2D vector of longs
Definition Vector.h:130