BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Line.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Mask/Line.h
6 //! @brief Defines class Line.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_DEVICE_MASK_LINE_H
16 #define BORNAGAIN_DEVICE_MASK_LINE_H
17 
18 #include "Device/Mask/IShape2D.h"
19 
20 //! A line segment, for use in detector masks.
21 //! @ingroup mask
22 
23 class Line : public IShape2D {
24 public:
25  Line(double x1, double y1, double x2, double y2);
26  Line* clone() const { return new Line(m_x1, m_y1, m_x2, m_y2); }
27 
28  bool contains(double x, double y) const;
29  bool contains(const Bin1D& binx, const Bin1D& biny) const;
30 
31 private:
32  double m_x1, m_y1, m_x2, m_y2;
33 };
34 
35 //! An infinite vertical line.
36 //! @ingroup mask
37 
38 class VerticalLine : public IShape2D {
39 public:
40  VerticalLine(double x);
41  VerticalLine* clone() const { return new VerticalLine(m_x); }
42 
43  bool contains(double x, double y) const;
44  bool contains(const Bin1D& binx, const Bin1D& biny) const;
45 
46  double getXpos() const { return m_x; }
47 
48 private:
49  double m_x;
50 };
51 
52 //! An infinite horizontal line.
53 //! @ingroup mask
54 
55 class HorizontalLine : public IShape2D {
56 public:
57  HorizontalLine(double y);
58  HorizontalLine* clone() const { return new HorizontalLine(m_y); }
59 
60  bool contains(double x, double y) const;
61  bool contains(const Bin1D& binx, const Bin1D& biny) const;
62 
63  double getYpos() const { return m_y; }
64 
65 private:
66  double m_y;
67 };
68 
69 #endif // BORNAGAIN_DEVICE_MASK_LINE_H
Defines basic class for all 2D shapes.
An infinite horizontal line.
Definition: Line.h:55
bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Line.cpp:85
HorizontalLine * clone() const
Definition: Line.h:58
double m_y
Definition: Line.h:66
double getYpos() const
Definition: Line.h:63
HorizontalLine(double y)
Definition: Line.cpp:83
Basic class for all shapes in 2D.
Definition: IShape2D.h:27
A line segment, for use in detector masks.
Definition: Line.h:23
double m_x2
Definition: Line.h:32
double m_x1
Definition: Line.h:32
Line(double x1, double y1, double x2, double y2)
Definition: Line.cpp:29
bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Line.cpp:34
double m_y1
Definition: Line.h:32
double m_y2
Definition: Line.h:32
Line * clone() const
Definition: Line.h:26
An infinite vertical line.
Definition: Line.h:38
VerticalLine * clone() const
Definition: Line.h:41
double getXpos() const
Definition: Line.h:46
bool contains(double x, double y) const
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Line.cpp:70
double m_x
Definition: Line.h:49
VerticalLine(double x)
Definition: Line.cpp:68
Definition: Bin.h:20