acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
lines.h
1#pragma once
2
3
4#include "point_array.h"
5#include "contains.h"
6
7
8template < prototype_number NUMBER >
9class lines_base :
10 public point_array_base < NUMBER >
11{
12public:
13
14 using BASE_ARRAY = point_array_base < NUMBER >;
15 //using POLYGON_BASE_TYPE = point_array_base < POINT_TYPE >;
16 //using POINT_BASE_TYPE = POINT_TYPE;
17 using UNIT_TYPE = NUMBER;
18 //using SIZE_TYPE = typename POINT_TYPE::SIZE_TYPE;
19 //using RECTANGLE_TYPE = typename POINT_TYPE::RECTANGLE_TYPE;
20 //using RECTANGLE_BASE_TYPE = typename RECTANGLE_TYPE::RECTANGLE_BASE_TYPE;
21
22
23 lines_base();
24 lines_base(const lines_base& lines);
25 lines_base(lines_base&& lines);
26 ~lines_base();
27
28
29 bool contains(const ::point_type <NUMBER > & point, ::f32 epsilon = 0.001f)
30 {
31
32 if (this->is_empty())
33 {
34
35 return false;
36
37 }
38
39 if (this->count() == 1)
40 {
41
42 return is_equal(this->first(), point, epsilon);
43
44 }
45
46 if (segment_contains(this->first(), this->last(), point, epsilon))
47 {
48
49 return true;
50
51 }
52
53 auto upper_bound = this->get_upper_bound();
54
55 for (::collection::index i = 0; i < upper_bound; i++)
56 {
57
58 if (segment_contains(this->element_at(i), this->element_at(i+1), point, epsilon))
59 {
60
61 return true;
62
63 }
64
65 }
66
67 return false;
68
69 }
70
71
72 lines_base & operator = (const lines_base & lines)
73 {
74
75 point_array_base < NUMBER >::operator =(lines);
76
77 return * this;
78
79 }
80
81};
82
83
84template < prototype_number NUMBER >
85lines_base < NUMBER >::lines_base()
86{
87
88}
89
90
91template < prototype_number NUMBER >
92inline lines_base < NUMBER >::lines_base(const lines_base& lines) :
93 point_array_base < NUMBER >(lines)
94{
95
96}
97
98
99template < prototype_number NUMBER >
100inline lines_base < NUMBER >::lines_base(lines_base&& lines) :
101 point_array_base < NUMBER >(::transfer(lines))
102{
103
104
105}
106
107
108template < prototype_number NUMBER >
109lines_base < NUMBER >::~lines_base()
110
111{
112
113}
114
115
116
Definition lines.h:11
Definition point_array.h:25