dmprectangle.h
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**************************************************************************
* file: dmprectangle.h
* Author: qingxiongf
* Date: 2021-08-03 13:48:43
* Email: qingxiongf@chinadci.com
* copyright: 广州城市信息研究所有限公司
***************************************************************************/
#ifndef __dmprectangle_h__
#define __dmprectangle_h__
#include "dmap_core.h"
class CORE_EXPORT DmpRectangle
{
public:
DmpRectangle() = default;
//! Constructor
explicit DmpRectangle(double xmin, double ymin = 0, double xmax = 0, double ymax = 0)
: xmin_( xmin )
, ymin_( ymin )
, xmax_( xmax )
, ymax_( ymax )
{
normalize();
}
~DmpRectangle() = default;
bool isNull();
void set(double xmin, double ymin, double xmax, double ymax);
void normalize(); //规范化矩形,使其具有非负宽度/高度。
double xmax() const { return xmax_; }
double xmin() const { return xmin_; }
double ymax() const { return ymax_; }
double ymin() const { return ymin_; }
double width() const { return xmax_ - xmin_; }
double height() const { return ymax_ - ymin_; }
void setXmax(double xmax){xmax_ = xmax; }
void setYmax(double ymax){ymax_ = ymax; }
void setXmin(double xmin){xmin_ = xmin; }
void setYmin(double ymin){ymin_ = ymin; }
void merge(DmpRectangle &rectangle);
private:
double xmin_ = 0.0;
double ymin_ = 0.0;
double xmax_ = 0.0;
double ymax_ = 0.0;
};
#endif