BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
Rectangle.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Mask/Rectangle.h
6 //! @brief Defines class Rectangle.
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_RECTANGLE_H
16 #define BORNAGAIN_DEVICE_MASK_RECTANGLE_H
17 
18 #include "Device/Mask/IShape2D.h"
19 
20 //! A rectangle, for use in detector masks.
21 //!
22 //! Edges are along the coordinate axes.
23 //! @ingroup mask
24 
25 class Rectangle : public IShape2D {
26 public:
27  Rectangle(double xlow, double ylow, double xup, double yup, bool inverted = false);
28  Rectangle* clone() const override
29  {
30  return new Rectangle(m_xlow, m_ylow, m_xup, m_yup, m_inverted);
31  }
32 
33  void setInverted(bool inverted = true);
34 
35  bool contains(double x, double y) const override;
36  bool contains(const Bin1D& binx, const Bin1D& biny) const override;
37 
38  double getArea() const;
39 
40  double getXlow() const { return m_xlow; }
41  double getYlow() const { return m_ylow; }
42  double getXup() const { return m_xup; }
43  double getYup() const { return m_yup; }
44 
45 private:
46  double m_xlow, m_ylow, m_xup, m_yup;
47  bool m_inverted;
48 };
49 
50 #endif // BORNAGAIN_DEVICE_MASK_RECTANGLE_H
Defines basic class for all 2D shapes.
Definition: Bin.h:20
Basic class for all shapes in 2D.
Definition: IShape2D.h:26
A rectangle, for use in detector masks.
Definition: Rectangle.h:25
double m_xup
Definition: Rectangle.h:46
double m_ylow
Definition: Rectangle.h:46
bool m_inverted
Definition: Rectangle.h:47
void setInverted(bool inverted=true)
Definition: Rectangle.cpp:45
Rectangle(double xlow, double ylow, double xup, double yup, bool inverted=false)
Definition: Rectangle.cpp:23
double m_xlow
Definition: Rectangle.h:46
double getXlow() const
Definition: Rectangle.h:40
double getXup() const
Definition: Rectangle.h:42
double getArea() const
Definition: Rectangle.cpp:61
bool contains(double x, double y) const override
Returns true if point with given coordinates is inside or on border of the shape.
Definition: Rectangle.cpp:50
double getYlow() const
Definition: Rectangle.h:41
Rectangle * clone() const override
Definition: Rectangle.h:28
double getYup() const
Definition: Rectangle.h:43
double m_yup
Definition: Rectangle.h:46