Skip to content

Commit eecc821

Browse files
committed
Separating the implementation
xgeometry.h implementation -> xio2d_impl.h
1 parent 4fc1578 commit eecc821

File tree

2 files changed

+136
-109
lines changed

2 files changed

+136
-109
lines changed

N3888_RefImpl/src/xgeometry.h

Lines changed: 21 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,16 @@ namespace std::experimental::io2d {
99
float _Width = 0.0F;
1010
float _Height = 0.0F;
1111
public:
12-
constexpr bounding_box() noexcept { }
13-
constexpr bounding_box(float x, float y, float width, float height) noexcept
14-
: _X(x)
15-
, _Y(y)
16-
, _Width(width)
17-
, _Height(height) {
18-
}
19-
constexpr bounding_box(const point_2d& tl, const point_2d& br) noexcept
20-
: _X(tl.x)
21-
, _Y(tl.y)
22-
, _Width(::std::max(0.0F, br.x - tl.x))
23-
, _Height(::std::max(0.0F, br.y - tl.y)) {
24-
}
12+
constexpr bounding_box() noexcept;
13+
constexpr bounding_box(float x, float y, float width, float height) noexcept;
14+
constexpr bounding_box(const point_2d& tl, const point_2d& br) noexcept;
2515

26-
constexpr void x(float value) noexcept {
27-
_X = value;
28-
}
29-
constexpr void y(float value) noexcept {
30-
_Y = value;
31-
}
32-
constexpr void width(float value) noexcept {
33-
_Width = value;
34-
}
35-
constexpr void height(float value) noexcept {
36-
_Height = value;
37-
}
38-
constexpr void top_left(const point_2d& value) noexcept {
39-
_X = value.x;
40-
_Y = value.y;
41-
}
42-
constexpr void bottom_right(const point_2d& value) noexcept {
43-
_Width = max(0.0F, value.x - _X);
44-
_Height = max(0.0F, value.y - _Y);
45-
}
16+
constexpr void x(float value) noexcept;
17+
constexpr void y(float value) noexcept;
18+
constexpr void width(float value) noexcept;
19+
constexpr void height(float value) noexcept;
20+
constexpr void top_left(const point_2d& value) noexcept;
21+
constexpr void bottom_right(const point_2d& value) noexcept;
4622

4723
constexpr float x() const noexcept;
4824
constexpr float y() const noexcept;
@@ -58,89 +34,26 @@ namespace std::experimental::io2d {
5834
friend constexpr bool operator==(const bounding_box& lhs, const bounding_box& rhs) noexcept;
5935
};
6036

61-
inline constexpr float bounding_box::x() const noexcept {
62-
return _X;
63-
}
64-
65-
inline constexpr float bounding_box::y() const noexcept {
66-
return _Y;
67-
}
68-
69-
inline constexpr float bounding_box::width() const noexcept {
70-
return _Width;
71-
}
72-
73-
inline constexpr float bounding_box::height() const noexcept {
74-
return _Height;
75-
}
76-
77-
inline constexpr float bounding_box::left() const noexcept {
78-
return _X;
79-
}
80-
81-
inline constexpr float bounding_box::right() const noexcept {
82-
return _X + _Width;
83-
}
84-
85-
inline constexpr float bounding_box::top() const noexcept {
86-
return _Y;
87-
}
88-
89-
inline constexpr float bounding_box::bottom() const noexcept {
90-
return _Y + _Height;
91-
}
92-
93-
inline constexpr point_2d bounding_box::top_left() const noexcept {
94-
return{ _X, _Y };
95-
}
96-
97-
inline constexpr point_2d bounding_box::bottom_right() const noexcept {
98-
return{ _X + _Width, _Y + _Height };
99-
}
100-
101-
class circle {
37+
constexpr bool operator==(const bounding_box& lhs, const bounding_box& rhs) noexcept;
38+
constexpr bool operator!=(const bounding_box& lhs, const bounding_box& rhs) noexcept;
39+
40+
class circle {
10241
point_2d _Center;
10342
float _Radius;
10443
public:
105-
constexpr circle() noexcept
106-
: _Center()
107-
, _Radius() {}
108-
constexpr circle(const point_2d& ctr, float r) noexcept
109-
: _Center(ctr)
110-
, _Radius(r) {}
44+
constexpr circle() noexcept;
45+
constexpr circle(const point_2d& ctr, float r) noexcept;
11146

112-
constexpr void center(const point_2d& ctr) noexcept {
113-
_Center = ctr;
114-
}
115-
constexpr void radius(float r) noexcept {
116-
_Radius = r;
117-
}
47+
constexpr void center(const point_2d& ctr) noexcept;
48+
constexpr void radius(float r) noexcept;
11849

119-
constexpr point_2d center() const noexcept {
120-
return _Center;
121-
}
122-
constexpr float radius() const noexcept {
123-
return _Radius;
124-
}
50+
constexpr point_2d center() const noexcept;
51+
constexpr float radius() const noexcept;
12552

126-
constexpr bool operator==(const circle& rhs) noexcept {
127-
return _Center == rhs._Center && _Radius == rhs._Radius;
128-
}
129-
constexpr bool operator!=(const circle& rhs) noexcept {
130-
return !((*this) == rhs);
131-
}
53+
constexpr bool operator==(const circle& rhs) noexcept;
54+
constexpr bool operator!=(const circle& rhs) noexcept;
13255
};
13356

134-
class bounding_box;
135-
constexpr bool operator==(const bounding_box& lhs, const bounding_box& rhs)
136-
noexcept {
137-
return lhs._X == rhs._X && lhs._Y == rhs._Y && lhs._Width == rhs._Width && lhs._Height == rhs._Height;
138-
}
139-
constexpr bool operator!=(const bounding_box& lhs, const bounding_box& rhs)
140-
noexcept {
141-
return !(lhs == rhs);
142-
}
143-
class circle;
14457
constexpr bool operator==(const circle& lhs, const circle& rhs) noexcept;
14558
constexpr bool operator!=(const circle& lhs, const circle& rhs) noexcept;
14659

N3888_RefImpl/src/xio2d_impl.h

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,121 @@ namespace std::experimental::io2d {
498498
return cpt + pt * lmtx;
499499
}
500500

501-
// Paths
501+
// Geometry
502+
503+
inline constexpr bounding_box::bounding_box() noexcept { }
504+
inline constexpr bounding_box::bounding_box(float x, float y, float width, float height) noexcept
505+
: _X(x)
506+
, _Y(y)
507+
, _Width(width)
508+
, _Height(height) {
509+
}
510+
inline constexpr bounding_box::bounding_box(const point_2d& tl, const point_2d& br) noexcept
511+
: _X(tl.x)
512+
, _Y(tl.y)
513+
, _Width(::std::max(0.0F, br.x - tl.x))
514+
, _Height(::std::max(0.0F, br.y - tl.y)) {
515+
}
516+
517+
inline constexpr void bounding_box::x(float value) noexcept {
518+
_X = value;
519+
}
520+
inline constexpr void bounding_box::y(float value) noexcept {
521+
_Y = value;
522+
}
523+
inline constexpr void bounding_box::width(float value) noexcept {
524+
_Width = value;
525+
}
526+
inline constexpr void bounding_box::height(float value) noexcept {
527+
_Height = value;
528+
}
529+
inline constexpr void bounding_box::top_left(const point_2d& value) noexcept {
530+
_X = value.x;
531+
_Y = value.y;
532+
}
533+
inline constexpr void bounding_box::bottom_right(const point_2d& value) noexcept {
534+
_Width = max(0.0F, value.x - _X);
535+
_Height = max(0.0F, value.y - _Y);
536+
}
537+
538+
inline constexpr float bounding_box::x() const noexcept {
539+
return _X;
540+
}
541+
542+
inline constexpr float bounding_box::y() const noexcept {
543+
return _Y;
544+
}
545+
546+
inline constexpr float bounding_box::width() const noexcept {
547+
return _Width;
548+
}
549+
550+
inline constexpr float bounding_box::height() const noexcept {
551+
return _Height;
552+
}
553+
554+
inline constexpr float bounding_box::left() const noexcept {
555+
return _X;
556+
}
557+
558+
inline constexpr float bounding_box::right() const noexcept {
559+
return _X + _Width;
560+
}
561+
562+
inline constexpr float bounding_box::top() const noexcept {
563+
return _Y;
564+
}
565+
566+
inline constexpr float bounding_box::bottom() const noexcept {
567+
return _Y + _Height;
568+
}
569+
570+
inline constexpr point_2d bounding_box::top_left() const noexcept {
571+
return{ _X, _Y };
572+
}
573+
574+
inline constexpr point_2d bounding_box::bottom_right() const noexcept {
575+
return{ _X + _Width, _Y + _Height };
576+
}
577+
578+
inline constexpr bool operator==(const bounding_box& lhs, const bounding_box& rhs)
579+
noexcept {
580+
return lhs._X == rhs._X && lhs._Y == rhs._Y && lhs._Width == rhs._Width && lhs._Height == rhs._Height;
581+
}
582+
inline constexpr bool operator!=(const bounding_box& lhs, const bounding_box& rhs)
583+
noexcept {
584+
return !(lhs == rhs);
585+
}
586+
587+
inline constexpr circle::circle() noexcept
588+
: _Center()
589+
, _Radius() {}
590+
inline constexpr circle::circle(const point_2d& ctr, float r) noexcept
591+
: _Center(ctr)
592+
, _Radius(r) {}
593+
594+
inline constexpr void circle::center(const point_2d& ctr) noexcept {
595+
_Center = ctr;
596+
}
597+
inline constexpr void circle::radius(float r) noexcept {
598+
_Radius = r;
599+
}
600+
601+
inline constexpr point_2d circle::center() const noexcept {
602+
return _Center;
603+
}
604+
inline constexpr float circle::radius() const noexcept {
605+
return _Radius;
606+
}
607+
608+
inline constexpr bool circle::operator==(const circle& rhs) noexcept {
609+
return _Center == rhs._Center && _Radius == rhs._Radius;
610+
}
611+
inline constexpr bool circle::operator!=(const circle& rhs) noexcept {
612+
return !((*this) == rhs);
613+
}
614+
615+
// Paths
502616

503617
enum class _Path_data_abs_new_path {};
504618
constexpr static _Path_data_abs_new_path _Path_data_abs_new_path_val = {};

0 commit comments

Comments
 (0)