1
+ /* *
2
+ *
3
+ * @authors Andrei Novikov ([email protected] )
4
+ * @date 2014-2019
5
+ * @copyright GNU Public License
6
+ *
7
+ * GNU_PUBLIC_LICENSE
8
+ * pyclustering is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * pyclustering is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+ #include " cluster/clique_block.hpp"
24
+
25
+
26
+ namespace ccore {
27
+
28
+ namespace clst {
29
+
30
+
31
+ clique_spatial_block::clique_spatial_block (const point & p_max_corner, const point & p_min_corner) :
32
+ m_max_corner (p_max_corner),
33
+ m_min_corner (p_min_corner)
34
+ { }
35
+
36
+ bool clique_spatial_block::contains (const point & p_point) const {
37
+ for (std::size_t i = 0 ; i < p_point.size (); ++i) {
38
+ if ((p_point[i] < m_min_corner[i]) || (p_point[i] > m_max_corner[i])) {
39
+ return false ;
40
+ }
41
+ }
42
+
43
+ return true ;
44
+ }
45
+
46
+ const point & clique_spatial_block::get_max_corner (void ) const {
47
+ return m_max_corner;
48
+ }
49
+
50
+ const point & clique_spatial_block::get_min_corner (void ) const {
51
+ return m_min_corner;
52
+ }
53
+
54
+
55
+
56
+ clique_block::clique_block (const clique_block_location & p_location, const clique_spatial_block & p_block) :
57
+ m_logical_location (p_location),
58
+ m_spatial_location (p_block),
59
+ m_points (),
60
+ m_visited (false )
61
+ { }
62
+
63
+ const clique_block_location & clique_block::get_logical_location () const {
64
+ return m_logical_location;
65
+ }
66
+
67
+ const clique_spatial_block & clique_block::get_spatial_block (void ) const {
68
+ return m_spatial_location;
69
+ }
70
+
71
+ const clique_block::content & clique_block::get_points (void ) const {
72
+ return m_points;
73
+ }
74
+
75
+ bool clique_block::is_visited (void ) const {
76
+ return m_visited;
77
+ }
78
+
79
+ void clique_block::touch (void ) {
80
+ m_visited = true ;
81
+ }
82
+
83
+ void clique_block::capture_points (const dataset & p_data, const std::vector<bool > p_availability) {
84
+ for (std::size_t index_point = 0 ; index_point < p_data.size (); ++index_point) {
85
+ if (p_availability[index_point] && m_spatial_location.contains (p_data[index_point])) {
86
+ m_points.push_back (index_point);
87
+ }
88
+ }
89
+ }
90
+
91
+ void clique_block::get_location_neighbors (const std::size_t p_edge, std::vector<clique_block_location> p_neighbors) {
92
+ for (std::size_t index_dimension = 0 ; index_dimension < m_logical_location.size (); ++index_dimension) {
93
+ if (m_logical_location[index_dimension] + 1 < p_edge) {
94
+ clique_block_location position = m_logical_location;
95
+ ++position[index_dimension];
96
+ p_neighbors.push_back (position);
97
+ }
98
+
99
+ if (m_logical_location[index_dimension] - 1 >= 0 ) {
100
+ clique_block_location position = m_logical_location;
101
+ --position[index_dimension];
102
+ p_neighbors.push_back (position);
103
+ }
104
+ }
105
+ }
106
+
107
+ }
108
+
109
+ }
0 commit comments