IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
BoundingBox2d.h
1 // BoundingBox2d.h:
3 // ----------------
4 //
16 
17 #ifndef __IPSDKGEOMETRY_BOUNDINGBOX2D_H__
18 #define __IPSDKGEOMETRY_BOUNDINGBOX2D_H__
19 
20 // suppression warnings
21 // warning C4251: 'ipsdk::geom::BoundingBox2d<T>::_minCornerPt' : class 'ipsdk::geom::Point2dData<TIn>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::BoundingBox2d<T>'
22 #pragma warning (push)
23 #pragma warning (disable : 4251)
24 
25 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
26 #include <IPSDKGeometry/Entity/2d/Point/Point2d.h>
29 
30 namespace ipsdk {
31 namespace geom {
32 
35 
36 template <typename T>
38 {
39  // declare 2d geometry entity
41 
42 // predefined public types
43 public:
45  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Cartesian;
46 
48  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_BoundingBox;
49 
52 
53 public:
56  BoundingBox2d();
57  BoundingBox2d(const Point2dData<T>& minCornerPt, const Point2dData<T>& maxCornerPt);
58  BoundingBox2d(const Point2d<T>& minCornerPt, const Point2d<T>& maxCornerPt);
59  BoundingBox2d(const T xMin, const T yMin, const T xMax, const T yMax);
60  ~BoundingBox2d();
62 
63 // methods
64 public:
66  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
67 
69  inline eEntity2dType getEntity2dType() const;
70 
73  inline void setCoords(const Point2dData<T>& minCornerPt, const Point2dData<T>& maxCornerPt);
74  inline void setCoords(const Point2d<T>& minCornerPt, const Point2d<T>& maxCornerPt);
75  inline void setCoords(const T xMin, const T yMin, const T xMax, const T yMax);
76  inline void setXMin(const T xMin);
77  inline void setXMax(const T xMax);
78  inline void setYMin(const T yMin);
79  inline void setYMax(const T yMax);
80  inline void setMinCornerPt(const Point2dData<T>& minCornerPt);
81  inline void setMinCornerPt(const Point2d<T>& minCornerPt);
82  inline void setMaxCornerPt(const Point2dData<T>& maxCornerPt);
83  inline void setMaxCornerPt(const Point2d<T>& maxCornerPt);
84  inline T getXMin() const;
85  inline T getXMax() const;
86  inline T getYMin() const;
87  inline T getYMax() const;
88  inline T& getXMin();
89  inline T& getXMax();
90  inline T& getYMin();
91  inline T& getYMax();
92  inline const Point2dData<T>& getMinCornerPt() const;
93  inline const Point2dData<T>& getMaxCornerPt() const;
94  inline Point2dData<T>& getMinCornerPt();
95  inline Point2dData<T>& getMaxCornerPt();
97 
100  inline T sizeX() const;
101  inline T sizeY() const;
102  inline T getArea() const;
104 
107  inline ipReal64 centerX() const;
108  inline ipReal64 centerY() const;
109  inline Point2dData<ipReal64> center() const;
111 
112 // attributes
113 protected:
116 
119 };
120 
123 
124 template <typename T>
127 {
128  return g_coordinateSystem2dType;
129 }
130 
131 template <typename T>
132 inline eEntity2dType
134 {
135  return g_entity2dType;
136 }
137 
138 template <typename T>
139 inline void
140 BoundingBox2d<T>::setCoords(const Point2dData<T>& minCornerPt, const Point2dData<T>& maxCornerPt)
141 {
142  _minCornerPt = minCornerPt;
143  _maxCornerPt = maxCornerPt;
144 }
145 
146 template <typename T>
147 inline void
148 BoundingBox2d<T>::setCoords(const Point2d<T>& minCornerPt, const Point2d<T>& maxCornerPt)
149 {
150  _minCornerPt = minCornerPt.getCoords();
151  _maxCornerPt = maxCornerPt.getCoords();
152 }
153 
154 template <typename T>
155 inline void
156 BoundingBox2d<T>::setCoords(const T xMin, const T yMin, const T xMax, const T yMax)
157 {
158  _minCornerPt.setCoords(xMin, yMin);
159  _maxCornerPt.setCoords(xMax, yMax);
160 }
161 
162 template <typename T>
163 inline void
165 {
166  _minCornerPt._x = xMin;
167 }
168 
169 template <typename T>
170 inline void
172 {
173  _maxCornerPt._x = xMax;
174 }
175 
176 template <typename T>
177 inline void
179 {
180  _minCornerPt._y = yMin;
181 }
182 
183 template <typename T>
184 inline void
186 {
187  _maxCornerPt._y = yMax;
188 }
189 
190 template <typename T>
191 inline void
193 {
194  _minCornerPt = minCornerPt;
195 }
196 
197 template <typename T>
198 inline void
200 {
201  _minCornerPt = minCornerPt.getCoords();
202 }
203 
204 template <typename T>
205 inline void
207 {
208  _maxCornerPt = maxCornerPt;
209 }
210 
211 template <typename T>
212 inline void
214 {
215  _maxCornerPt = maxCornerPt.getCoords();
216 }
217 
218 template <typename T>
219 inline T
221 {
222  return _minCornerPt._x;
223 }
224 
225 template <typename T>
226 inline T
228 {
229  return _maxCornerPt._x;
230 }
231 
232 template <typename T>
233 inline T
235 {
236  return _minCornerPt._y;
237 }
238 
239 template <typename T>
240 inline T
242 {
243  return _maxCornerPt._y;
244 }
245 
246 template <typename T>
247 inline T&
249 {
250  return _minCornerPt._x;
251 }
252 
253 template <typename T>
254 inline T&
256 {
257  return _maxCornerPt._x;
258 }
259 
260 template <typename T>
261 inline T&
263 {
264  return _minCornerPt._y;
265 }
266 
267 template <typename T>
268 inline T&
270 {
271  return _maxCornerPt._y;
272 }
273 
274 template <typename T>
275 inline const Point2dData<T>&
277 {
278  return _minCornerPt;
279 }
280 
281 template <typename T>
282 inline const Point2dData<T>&
284 {
285  return _maxCornerPt;
286 }
287 
288 template <typename T>
289 inline Point2dData<T>&
291 {
292  return _minCornerPt;
293 }
294 
295 template <typename T>
296 inline Point2dData<T>&
298 {
299  return _maxCornerPt;
300 }
301 
302 template <typename T>
303 inline T
305 {
306  return _maxCornerPt._x - _minCornerPt._x;
307 }
308 
309 template <typename T>
310 inline T
312 {
313  return _maxCornerPt._y - _minCornerPt._y;
314 }
315 
316 template <typename T>
317 inline T
319 {
320  return this->sizeX() * this->sizeY();
321 }
322 
323 template <typename T>
324 inline ipReal64
326 {
327  return (_maxCornerPt._x + _minCornerPt._x) / 2.0;
328 }
329 
330 template <typename T>
331 inline ipReal64
333 {
334  return (_maxCornerPt._y + _minCornerPt._y) / 2.0;
335 }
336 
337 template <typename T>
340 {
341  return Point2dData<ipReal64>(centerX(), centerY());
342 }
343 
346 
347 } // end of namespace geom
348 } // end of namespace ipsdk
349 
350 #pragma warning (pop)
351 
352 #endif // __IPSDKGEOMETRY_BOUNDINGBOX2D_H__
Point2dData< T > _minCornerPt
minimum coordinates point associated to bounding box
Definition: BoundingBox2d.h:115
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Point class associated to cartesian 2d coordinates.
Definition: GeometryEntity2dTypes.h:28
const Point2dData< T > & getMaxCornerPt() const
access to bounding box coordinates
Definition: BoundingBox2d.h:283
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: BoundingBox2d.h:133
void setYMax(const T yMax)
access to bounding box coordinates
Definition: BoundingBox2d.h:185
const Point2dData< T > & getMinCornerPt() const
access to bounding box coordinates
Definition: BoundingBox2d.h:276
T getArea() const
compute bounding box dimensions
Definition: BoundingBox2d.h:318
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
T getXMin() const
access to bounding box coordinates
Definition: BoundingBox2d.h:220
T sizeY() const
compute bounding box dimensions
Definition: BoundingBox2d.h:311
ipReal64 centerX() const
compute bounding box center point
Definition: BoundingBox2d.h:325
void setYMin(const T yMin)
access to bounding box coordinates
Definition: BoundingBox2d.h:178
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
T getYMax() const
access to bounding box coordinates
Definition: BoundingBox2d.h:241
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
BoundingBox.
Definition: GeometryEntity2dTypes.h:44
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
Point2dData< T > PointType
point type associated to object
Definition: BoundingBox2d.h:51
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: BoundingBox2d.h:126
void setXMax(const T xMax)
access to bounding box coordinates
Definition: BoundingBox2d.h:171
void setCoords(const Point2dData< T > &minCornerPt, const Point2dData< T > &maxCornerPt)
access to bounding box coordinates
Definition: BoundingBox2d.h:140
Point2dData< ipReal64 > center() const
compute bounding box center point
Definition: BoundingBox2d.h:339
const Point2dData< T > & getCoords() const
access to point coordinates
Definition: Point2d.h:139
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
T sizeX() const
compute bounding box dimensions
Definition: BoundingBox2d.h:304
T getYMin() const
access to bounding box coordinates
Definition: BoundingBox2d.h:234
void setMinCornerPt(const Point2dData< T > &minCornerPt)
access to bounding box coordinates
Definition: BoundingBox2d.h:192
ipReal64 centerY() const
compute bounding box center point
Definition: BoundingBox2d.h:332
void setXMin(const T xMin)
access to bounding box coordinates
Definition: BoundingBox2d.h:164
Point2dData< T > _maxCornerPt
maximum coordinates point associated to bounding box
Definition: BoundingBox2d.h:118
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
T getXMax() const
access to bounding box coordinates
Definition: BoundingBox2d.h:227
Rectangular 2d bounding box class associated to cartesian 2d coordinates.
Definition: BoundingBox2d.h:37
Utility functions for bounding box 2d management.
void setMaxCornerPt(const Point2dData< T > &maxCornerPt)
access to bounding box coordinates
Definition: BoundingBox2d.h:206
Cartesian coordinate system.
Definition: GeometryEntity2dTypes.h:78
Basic operators used for bounding box 2d management.