IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Point2dData.h
1 // Point2dData.h:
3 // --------------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_POINT2DDATA_H__
16 #define __IPSDKGEOMETRY_POINT2DDATA_H__
17 
18 #include <IPSDKUtil/BaseTypes.h>
19 
20 namespace ipsdk {
21 namespace geom {
22 
25 
26 template <typename T>
27 struct Point2dData
28 {
29 public:
32  Point2dData() {}
33  Point2dData(const T x, const T y) :
34  _x(x), _y(y) {}
35  Point2dData(const Point2dData& pt) :
36  _x(pt._x), _y(pt._y) {}
37  ~Point2dData() {}
39 
40 // methods
41 public:
43  inline void setCoords(const T x, const T y);
44 
48  inline Point2dData& operator+=(const Point2dData& pt);
49  inline Point2dData operator+(const Point2dData& pt) const;
50  inline Point2dData& operator+=(const T value);
51  inline Point2dData operator+(const T value) const;
52  inline Point2dData& operator-=(const Point2dData& pt);
53  inline Point2dData operator-(const Point2dData& pt) const;
54  inline Point2dData& operator-=(const T value);
55  inline Point2dData operator-(const T value) const;
56  inline Point2dData& operator*=(const Point2dData& pt);
57  inline Point2dData operator*(const Point2dData& pt) const;
58  inline Point2dData& operator*=(const ipReal64 value);
59  inline Point2dData operator*(const ipReal64 value) const;
60  inline Point2dData& operator/=(const Point2dData& pt);
61  inline Point2dData operator/(const Point2dData& pt) const;
62  inline Point2dData& operator/=(const ipReal64 value);
63  inline Point2dData operator/(const ipReal64 value) const;
65 
66 // attributes
67 public:
69  T _x;
70 
72  T _y;
73 };
74 
77 
78 template <typename T>
79 inline void
80 Point2dData<T>::setCoords(const T x, const T y)
81 {
82  _x = x;
83  _y = y;
84 }
85 
86 template <typename T>
87 inline Point2dData<T>&
89 {
90  _x += pt._x;
91  _y += pt._y;
92 
93  return *this;
94 }
95 
96 template <typename T>
97 inline Point2dData<T>
99 {
100  Point2dData<T> ptRes(*this);
101  ptRes += pt;
102 
103  return ptRes;
104 }
105 
106 template <typename T>
107 inline Point2dData<T>&
109 {
110  _x += value;
111  _y += value;
112 
113  return *this;
114 }
115 
116 template <typename T>
117 inline Point2dData<T>
118 Point2dData<T>::operator+(const T value) const
119 {
120  Point2dData<T> ptRes(*this);
121  ptRes += value;
122 
123  return ptRes;
124 }
125 
126 template <typename T>
127 inline Point2dData<T>&
129 {
130  _x -= pt._x;
131  _y -= pt._y;
132 
133  return *this;
134 }
135 
136 template <typename T>
137 inline Point2dData<T>
139 {
140  Point2dData<T> ptRes(*this);
141  ptRes -= pt;
142 
143  return ptRes;
144 }
145 
146 template <typename T>
147 inline Point2dData<T>&
149 {
150  _x -= value;
151  _y -= value;
152 
153  return *this;
154 }
155 
156 template <typename T>
157 inline Point2dData<T>
158 Point2dData<T>::operator-(const T value) const
159 {
160  Point2dData<T> ptRes(*this);
161  ptRes -= value;
162 
163  return ptRes;
164 }
165 
166 template <typename T>
167 inline Point2dData<T>&
169 {
170  _x *= pt._x;
171  _y *= pt._y;
172 
173  return *this;
174 }
175 
176 template <typename T>
177 inline Point2dData<T>
179 {
180  Point2dData<T> ptRes(*this);
181  ptRes *= pt;
182 
183  return ptRes;
184 }
185 
186 template <typename T>
187 inline Point2dData<T>&
189 {
190  _x = static_cast<T>(_x * value);
191  _y = static_cast<T>(_y * value);
192 
193  return *this;
194 }
195 
196 template <typename T>
197 inline Point2dData<T>
199 {
200  Point2dData<T> ptRes(*this);
201  ptRes *= value;
202 
203  return ptRes;
204 }
205 
206 template <typename T>
207 inline Point2dData<T>&
209 {
210  _x /= pt._x;
211  _y /= pt._y;
212 
213  return *this;
214 }
215 
216 template <typename T>
217 inline Point2dData<T>
219 {
220  Point2dData<T> ptRes(*this);
221  ptRes += pt;
222 
223  return ptRes;
224 }
225 
226 template <typename T>
227 inline Point2dData<T>&
229 {
230  _x = static_cast<T>(_x / value);
231  _y = static_cast<T>(_y / value);
232 
233  return *this;
234 }
235 
236 template <typename T>
237 inline Point2dData<T>
239 {
240  Point2dData<T> ptRes(*this);
241  ptRes /= value;
242 
243  return ptRes;
244 }
245 
248 
249 } // end of namespace geom
250 } // end of namespace ipsdk
251 
252 #endif // __IPSDKGEOMETRY_POINT2DDATA_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
T _x
x coordinate of point
Definition: Point2dData.h:69
Point2dData & operator-=(const Point2dData &pt)
arithmetic operators on point
Definition: Point2dData.h:128
Point2dData & operator+=(const Point2dData &pt)
arithmetic operators on point
Definition: Point2dData.h:88
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Point2dData operator/(const Point2dData &pt) const
arithmetic operators on point
Definition: Point2dData.h:218
Point2dData operator+(const Point2dData &pt) const
arithmetic operators on point
Definition: Point2dData.h:98
Point2dData operator*(const Point2dData &pt) const
arithmetic operators on point
Definition: Point2dData.h:178
Point2dData & operator*=(const Point2dData &pt)
arithmetic operators on point
Definition: Point2dData.h:168
Base types for multiplatform compatibility.
Point2dData & operator/=(const Point2dData &pt)
arithmetic operators on point
Definition: Point2dData.h:208
T _y
y coordinate of point
Definition: Point2dData.h:72
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
void setCoords(const T x, const T y)
set coordinates associated to point 2d
Definition: Point2dData.h:80
Point2dData operator-(const Point2dData &pt) const
arithmetic operators on point
Definition: Point2dData.h:138