contrek 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Cursor.cpp +12 -11
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Part.cpp +8 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Part.h +1 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Partitionable.cpp +10 -4
- data/lib/contrek/finder/concurrent/cursor.rb +1 -1
- data/lib/contrek/finder/concurrent/part.rb +10 -3
- data/lib/contrek/finder/concurrent/partitionable.rb +4 -0
- data/lib/contrek/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0df584b1fe92f70cb27f479a6d7705545f662b8758a4843bf966fe92d90c4c9d
|
|
4
|
+
data.tar.gz: 2dfe6f8b0cc96298858f5055158ba439644d24a9921166c572e91cd5df17780b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d97742b1bc4f3688a8d083d25873da8db709b69c42c8068d02cfe6fe3569acac159f3d1a37c31128a7809b0e9851ba5e9da15c801f18c514189e53f4bc39440a
|
|
7
|
+
data.tar.gz: ee34393dc9713f62de0560b5d6538e7e9ffd6ff38358429f14f7ab7efb3cde201f2461d4ec209ed906a0a0e1e6aa0eb013040dddf290856400f632131e4c3622
|
data/Gemfile.lock
CHANGED
|
@@ -86,9 +86,8 @@ void Cursor::traverse_outer(Part* act_part,
|
|
|
86
86
|
auto& q_set = new_position->end_point()->queues();
|
|
87
87
|
auto it = std::find_if(q_set.begin(), q_set.end(), [&](Queueable<Point>* q) {
|
|
88
88
|
Part* p = static_cast<Part*>(q);
|
|
89
|
-
return p->versus() == -versus && p->polyline()->tile != act_part->polyline()->tile;
|
|
89
|
+
return (p->mirror || act_part->mirror || p->versus() == -versus) && p->polyline()->tile != act_part->polyline()->tile;
|
|
90
90
|
});
|
|
91
|
-
|
|
92
91
|
Part* part = nullptr;
|
|
93
92
|
if (it != q_set.end()) {
|
|
94
93
|
part = static_cast<Part*>(*it);
|
|
@@ -97,24 +96,26 @@ void Cursor::traverse_outer(Part* act_part,
|
|
|
97
96
|
const auto n = all_parts.size();
|
|
98
97
|
Part *last_last_part = n >= 2 ? all_parts[n - 2] : nullptr;
|
|
99
98
|
if (last_last_part != part) {
|
|
99
|
+
bool all_seam = false;
|
|
100
100
|
if (n >= 2) {
|
|
101
|
-
|
|
101
|
+
all_seam = true;
|
|
102
102
|
for (std::size_t i = all_parts.size() - 2; i < all_parts.size(); ++i) {
|
|
103
103
|
if (all_parts[i]->type != Part::SEAM) {
|
|
104
104
|
all_seam = false;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
if (all_seam) break;
|
|
109
108
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
109
|
+
if (!all_seam) {
|
|
110
|
+
if (shapes_sequence_lookup.insert(part->polyline()->shape).second) {
|
|
111
|
+
shapes_sequence.push_back(part->polyline()->shape);
|
|
112
|
+
}
|
|
113
|
+
part->next_position(new_position);
|
|
114
|
+
part->dead_end = true;
|
|
115
|
+
act_part = part;
|
|
116
|
+
jumped_to_new_part = true;
|
|
117
|
+
break;
|
|
112
118
|
}
|
|
113
|
-
part->next_position(new_position);
|
|
114
|
-
part->dead_end = true;
|
|
115
|
-
act_part = part;
|
|
116
|
-
jumped_to_new_part = true;
|
|
117
|
-
break;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
if (!jumped_to_new_part) {
|
|
@@ -65,7 +65,13 @@ void Part::orient()
|
|
|
65
65
|
{ if (this->size <= 1 || (this->size == 2 && this->inverts)) {
|
|
66
66
|
this->versus_ = 0;
|
|
67
67
|
} else {
|
|
68
|
-
|
|
68
|
+
int diff = this->tail->payload->y - this->head->payload->y;
|
|
69
|
+
if (diff == 0) {
|
|
70
|
+
this->mirror = true;
|
|
71
|
+
this->versus_ = 0;
|
|
72
|
+
} else {
|
|
73
|
+
this->versus_ = diff > 0 ? 1 : -1;
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
|
|
@@ -78,6 +84,7 @@ std::string Part::inspect() {
|
|
|
78
84
|
std::stringstream ss;
|
|
79
85
|
ss << "part " << part_index
|
|
80
86
|
<< " (versus=" << this->versus_
|
|
87
|
+
<< " mirror=" << this->mirror
|
|
81
88
|
<< " inv=" << this->inverts
|
|
82
89
|
<< " trm=" << this->trasmuted
|
|
83
90
|
<< " touched=" << this->touched_
|
|
@@ -87,10 +87,16 @@ void Partitionable::trasmute_parts()
|
|
|
87
87
|
}
|
|
88
88
|
return false;
|
|
89
89
|
});
|
|
90
|
-
if (count == inside->size
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
if (count == inside->size) {
|
|
91
|
+
if (count < inside_compare->size) {
|
|
92
|
+
inside->type = Part::EXCLUSIVE;
|
|
93
|
+
inside->trasmuted = true;
|
|
94
|
+
break;
|
|
95
|
+
} else if ( count == inside_compare->size &&
|
|
96
|
+
inside->next == nullptr &&
|
|
97
|
+
inside_compare->prev == nullptr) {
|
|
98
|
+
inside->mirror = true;
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
}
|
|
@@ -115,7 +115,7 @@ module Contrek
|
|
|
115
115
|
new_position.end_point.tracked_outer = true
|
|
116
116
|
versus = act_part.versus
|
|
117
117
|
part = new_position.end_point.queues.find do |p|
|
|
118
|
-
p.versus == -versus && p.polyline.tile != act_part.polyline.tile
|
|
118
|
+
(p.mirror || act_part.mirror || p.versus == -versus) && p.polyline.tile != act_part.polyline.tile
|
|
119
119
|
end
|
|
120
120
|
if part
|
|
121
121
|
if all_parts[-2] != part
|
|
@@ -8,7 +8,7 @@ module Contrek
|
|
|
8
8
|
ADDED = 2
|
|
9
9
|
|
|
10
10
|
attr_reader :polyline, :touched
|
|
11
|
-
attr_accessor :next, :circular_next, :prev, :type, :dead_end, :inverts, :trasmuted, :versus
|
|
11
|
+
attr_accessor :next, :circular_next, :prev, :type, :dead_end, :inverts, :trasmuted, :versus, :mirror
|
|
12
12
|
def initialize(type, polyline)
|
|
13
13
|
@type = type
|
|
14
14
|
@polyline = polyline
|
|
@@ -20,6 +20,7 @@ module Contrek
|
|
|
20
20
|
@inverts = false
|
|
21
21
|
@trasmuted = false
|
|
22
22
|
@versus = 0
|
|
23
|
+
@mirror = false
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def is?(type)
|
|
@@ -56,7 +57,7 @@ module Contrek
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def inspect
|
|
59
|
-
"part #{polyline.parts.index(self)} (versus=#{@versus} inv=#{@inverts} trm=#{@trasmuted} touched=#{@touched} dead_end =#{@dead_end}, #{size}x) of #{polyline.
|
|
60
|
+
"part #{polyline.parts.index(self)} (mir=#{@mirror} versus=#{@versus} inv=#{@inverts} trm=#{@trasmuted} touched=#{@touched} dead_end =#{@dead_end}, #{size}x) of #{polyline.named} (#{name}) (#{to_a.map { |e| "[#{e[:x]},#{e[:y]}]" }.join})"
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
def innerable?
|
|
@@ -67,7 +68,13 @@ module Contrek
|
|
|
67
68
|
@versus = if size <= 1 || (size == 2 && @inverts)
|
|
68
69
|
0
|
|
69
70
|
else
|
|
70
|
-
|
|
71
|
+
diff = tail.payload[:y] - head.payload[:y]
|
|
72
|
+
if diff == 0
|
|
73
|
+
@mirror = true
|
|
74
|
+
0
|
|
75
|
+
else
|
|
76
|
+
diff.positive? ? 1 : -1
|
|
77
|
+
end
|
|
71
78
|
end
|
|
72
79
|
end
|
|
73
80
|
|
data/lib/contrek/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: contrek
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emanuele Cesaroni
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|