OpenPose  1.0.0rc2
OpenPose: A Real-Time Multi-Person Key-Point Detection And Multi-Threading C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rectangle.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_CORE_RECTANGLE_HPP
2 #define OPENPOSE_CORE_RECTANGLE_HPP
3 
4 #include <string>
7 
8 namespace op
9 {
10  template<typename T>
11  struct Rectangle
12  {
13  T x;
14  T y;
15  T width;
16  T height;
17 
18  Rectangle(const T x = 0, const T y = 0, const T width = 0, const T height = 0);
19 
28  Rectangle<T>(const Rectangle<T>& rectangle);
29 
36  Rectangle<T>& operator=(const Rectangle<T>& rectangle);
37 
43  Rectangle<T>(Rectangle<T>&& rectangle);
44 
51  Rectangle<T>& operator=(Rectangle<T>&& rectangle);
52 
53  Point<T> center() const;
54 
55  inline Point<T> topLeft() const
56  {
57  return Point<T>{x, y};
58  }
59 
60  Point<T> bottomRight() const;
61 
62  inline T area() const
63  {
64  return width * height;
65  }
66 
67  void recenter(const T newWidth, const T newHeight);
68 
74  std::string toString() const;
75 
76  // ------------------------------ Basic Operators ------------------------------ //
77  Rectangle<T>& operator*=(const T value);
78 
79  Rectangle<T> operator*(const T value) const;
80 
81  Rectangle<T>& operator/=(const T value);
82 
83  Rectangle<T> operator/(const T value) const;
84  };
85 
86  // Static methods
87  template<typename T>
88  Rectangle<T> recenter(const Rectangle<T>& rectangle, const T newWidth, const T newHeight);
89 
90  OVERLOAD_C_OUT(Rectangle)
91 }
92 
93 #endif // OPENPOSE_CORE_RECTANGLE_HPP
Point< T > center() const
Rectangle< T > & operator=(const Rectangle< T > &rectangle)
Rectangle(const T x=0, const T y=0, const T width=0, const T height=0)
T y
Definition: rectangle.hpp:14
void recenter(const T newWidth, const T newHeight)
Definition: point.hpp:10
#define OVERLOAD_C_OUT(className)
Definition: macros.hpp:61
Rectangle< T > operator/(const T value) const
Rectangle< T > & operator/=(const T value)
std::string toString() const
Point< T > bottomRight() const
Rectangle< T > operator*(const T value) const
T height
Definition: rectangle.hpp:16
Point< T > topLeft() const
Definition: rectangle.hpp:55
T width
Definition: rectangle.hpp:15
T x
Definition: rectangle.hpp:13
Rectangle< T > & operator*=(const T value)
Definition: rectangle.hpp:11
Rectangle< T > recenter(const Rectangle< T > &rectangle, const T newWidth, const T newHeight)
T area() const
Definition: rectangle.hpp:62
std::string string
Definition: cl2.hpp:574