OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Point2D.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10#include "OTCore/Serializable.h"
11
12namespace ot {
13
14 class Point2D;
15 class Point2DF;
16 class Point2DD;
17
21 public:
22 Point2D() : m_x(0), m_y(0) {};
23 Point2D(int _x, int _y) : m_x(_x), m_y(_y) {};
24 Point2D(const Point2D& _other) : m_x(_other.m_x), m_y(_other.m_y) {};
25 virtual ~Point2D() {};
26
27 Point2D& operator = (const Point2D& _other) { m_x = _other.m_x; m_y = _other.m_y; return *this; };
28 bool operator == (const Point2D& _other) const { return m_x == _other.m_x && m_y == _other.m_y; };
29 bool operator != (const Point2D& _other) const { return m_x != _other.m_x || m_y != _other.m_y; };
30
31 Point2D operator + (const Point2D& _other) const { return Point2D(m_x + _other.m_x, m_y + _other.m_y); };
32 Point2D& operator += (const Point2D& _other) { m_x += _other.m_x; m_y += _other.m_y; return *this; };
33 Point2D operator - (const Point2D& _other) const { return Point2D(m_x - _other.m_x, m_y -_other.m_y); };
34 Point2D& operator -= (const Point2D& _other) { m_x -= _other.m_x; m_y -= _other.m_y; return *this; };
35
39 virtual void addToJsonObject(JsonValue& _object, JsonAllocator& _allocator) const override;
40
44 virtual void setFromJsonObject(const ConstJsonObject& _object) override;
45
47 int x(void) const { return m_x; };
48
50 int y(void) const { return m_y; };
51
54 void setX(int _x) { m_x = _x; };
55
58 void setY(int _y) { m_y = _y; };
59
63 void set(int _x, int _y) { m_x = _x; m_y = _y; };
64
65 Point2DF toPoint2DF(void) const;
66
67 Point2DD toPoint2DD(void) const;
68
69 private:
70 int m_x;
71 int m_y;
72 };
73
74 // ###########################################################################################################################################################################################################################################################################################################################
75
76 // ###########################################################################################################################################################################################################################################################################################################################
77
78 // ###########################################################################################################################################################################################################################################################################################################################
79
83 public:
84 Point2DF() : m_x(0.f), m_y(0.f) {};
85 Point2DF(float _x, float _y) : m_x(_x), m_y(_y) {};
86 Point2DF(const Point2DF& _other) : m_x(_other.m_x), m_y(_other.m_y) {};
87 virtual ~Point2DF() {};
88
89 Point2DF& operator = (const Point2DF& _other) { m_x = _other.m_x; m_y = _other.m_y; return *this; };
90 bool operator == (const Point2DF& _other) const { return m_x == _other.m_x && m_y == _other.m_y; };
91 bool operator != (const Point2DF& _other) const { return m_x != _other.m_x || m_y != _other.m_y; };
92
93 Point2DF operator + (const Point2DF& _other) const { return Point2DF(m_x + _other.m_x, m_y + _other.m_y); };
94 Point2DF& operator += (const Point2DF& _other) { m_x += _other.m_x; m_y += _other.m_y; return *this; };
95 Point2DF operator - (const Point2DF& _other) const { return Point2DF(m_x - _other.m_x, m_y - _other.m_y); };
96 Point2DF& operator -= (const Point2DF& _other) { m_x -= _other.m_x; m_y -= _other.m_y; return *this; };
97
101 virtual void addToJsonObject(JsonValue& _object, JsonAllocator& _allocator) const override;
102
106 virtual void setFromJsonObject(const ConstJsonObject& _object) override;
107
109 float x(void) const { return m_x; };
110
112 float y(void) const { return m_y; };
113
116 void setX(float _x) { m_x = _x; };
117
120 void setY(float _y) { m_y = _y; };
121
125 void set(float _x, float _y) { m_x = _x; m_y = _y; };
126
127 Point2D toPoint2D(void) const;
128
129 Point2DD toPoint2DD(void) const;
130
131 private:
132 float m_x;
133 float m_y;
134 };
135
136 // ###########################################################################################################################################################################################################################################################################################################################
137
138 // ###########################################################################################################################################################################################################################################################################################################################
139
140 // ###########################################################################################################################################################################################################################################################################################################################
141
145 public:
146 Point2DD() : m_x(0.), m_y(0.) {};
147 Point2DD(double _x, double _y) : m_x(_x), m_y(_y) {};
148 Point2DD(const Point2DD& _other) : m_x(_other.m_x), m_y(_other.m_y) {};
149 virtual ~Point2DD() {};
150
151 Point2DD& operator = (const Point2DD& _other) { m_x = _other.m_x; m_y = _other.m_y; return *this; };
152 bool operator == (const Point2DD& _other) const { return m_x == _other.m_x && m_y == _other.m_y; };
153 bool operator != (const Point2DD& _other) const { return m_x != _other.m_x || m_y != _other.m_y; };
154
155 Point2DD operator + (const Point2DD& _other) const { return Point2DD(m_x + _other.m_x, m_y + _other.m_y); };
156 Point2DD& operator += (const Point2DD& _other) { m_x += _other.m_x; m_y += _other.m_y; return *this; };
157 Point2DD operator - (const Point2DD& _other) const { return Point2DD(m_x - _other.m_x, m_y - _other.m_y); };
158 Point2DD& operator -= (const Point2DD& _other) { m_x -= _other.m_x; m_y -= _other.m_y; return *this; };
159
163 virtual void addToJsonObject(JsonValue& _object, JsonAllocator& _allocator) const override;
164
168 virtual void setFromJsonObject(const ConstJsonObject& _object) override;
169
171 double x(void) const { return m_x; };
172
174 double y(void) const { return m_y; };
175
178 void setX(double _x) { m_x = _x; };
179
182 void setY(double _y) { m_y = _y; };
183
187 void set(double _x, double _y) { m_x = _x; m_y = _y; };
188
189 Point2D toPoint2D(void) const;
190
191 Point2DF toPoint2DF(void) const;
192
193 private:
194 double m_x;
195 double m_y;
196 };
197
198}
#define OT_CORE_API_EXPORT
Dll import.
Definition CoreAPIExport.h:8
bool operator==(const FaceSelection &left, const FaceSelection &right)
Definition Model.cpp:55
2D Point with double values
Definition Point2D.h:144
double y(void) const
Returns the current Y value.
Definition Point2D.h:174
void setX(double _x)
Set the X value.
Definition Point2D.h:178
void set(double _x, double _y)
Set the X and Y value.
Definition Point2D.h:187
virtual ~Point2DD()
Definition Point2D.h:149
Point2DD()
Definition Point2D.h:146
Point2DD(const Point2DD &_other)
Definition Point2D.h:148
Point2DD(double _x, double _y)
Definition Point2D.h:147
double x(void) const
Returns the current X value.
Definition Point2D.h:171
void setY(double _y)
Set the Y value.
Definition Point2D.h:182
2D Point with float values
Definition Point2D.h:82
void setX(float _x)
Set the X value.
Definition Point2D.h:116
Point2DF()
Definition Point2D.h:84
Point2DF(float _x, float _y)
Definition Point2D.h:85
float x(void) const
Returns the current X value.
Definition Point2D.h:109
virtual ~Point2DF()
Definition Point2D.h:87
void set(float _x, float _y)
Set the X and Y value.
Definition Point2D.h:125
void setY(float _y)
Set the Y value.
Definition Point2D.h:120
float y(void) const
Returns the current Y value.
Definition Point2D.h:112
Point2DF(const Point2DF &_other)
Definition Point2D.h:86
2D Point with integer values
Definition Point2D.h:20
void set(int _x, int _y)
Set the X and Y value.
Definition Point2D.h:63
int x(void) const
Returns the current X value.
Definition Point2D.h:47
Point2D()
Definition Point2D.h:22
virtual ~Point2D()
Definition Point2D.h:25
Point2D(const Point2D &_other)
Definition Point2D.h:24
void setX(int _x)
Set the X value.
Definition Point2D.h:54
void setY(int _y)
Set the Y value.
Definition Point2D.h:58
int y(void) const
Returns the current Y value.
Definition Point2D.h:50
Point2D(int _x, int _y)
Definition Point2D.h:23
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30