contrek 1.1.2 → 1.1.3
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/.gitignore +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/LICENSE-MIT.md +9 -0
- data/README.md +41 -1
- data/contrek.gemspec +0 -1
- data/ext/cpp_polygon_finder/PolygonFinder/CMakeLists.txt +14 -2
- data/ext/cpp_polygon_finder/PolygonFinder/LICENSE_AGPL.txt +661 -0
- data/ext/cpp_polygon_finder/PolygonFinder/examples/example.cpp +9 -7
- data/ext/cpp_polygon_finder/PolygonFinder/src/ContrekApi.h +9 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/bitmaps/FastPngBitmap.cpp +2 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/FinderUtils.cpp +13 -2
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/List.cpp +74 -82
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/List.h +12 -4
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/Lists.cpp +0 -10
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/Lists.h +0 -7
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/Node.cpp +39 -39
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/Node.h +10 -10
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/NodeCluster.cpp +24 -39
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/NodeCluster.h +5 -7
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/PolygonFinder.cpp +6 -4
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/PolygonFinder.h +4 -3
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Cursor.cpp +9 -3
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Finder.cpp +1 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Part.cpp +33 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Part.h +5 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Partitionable.cpp +8 -8
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Partitionable.h +2 -1
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Polyline.cpp +13 -0
- data/ext/cpp_polygon_finder/PolygonFinder/src/polygon/finder/concurrent/Polyline.h +2 -0
- data/ext/cpp_polygon_finder/extconf.rb +12 -2
- data/lib/contrek/bitmaps/painting.rb +1 -0
- data/lib/contrek/finder/concurrent/cursor.rb +5 -5
- data/lib/contrek/finder/concurrent/finder.rb +2 -1
- data/lib/contrek/finder/concurrent/part.rb +12 -3
- data/lib/contrek/finder/concurrent/partitionable.rb +7 -5
- data/lib/contrek/finder/node.rb +41 -29
- data/lib/contrek/finder/node_cluster.rb +18 -12
- data/lib/contrek/finder/polygon_finder.rb +4 -3
- data/lib/contrek/version.rb +1 -1
- metadata +8 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Contrek
|
|
2
2
|
module Finder
|
|
3
3
|
class NodeCluster
|
|
4
|
-
attr_reader :root_nodes, :sequences, :polygons, :lists, :treemap, :vert_nodes
|
|
4
|
+
attr_reader :root_nodes, :sequences, :polygons, :lists, :treemap, :vert_nodes, :options
|
|
5
5
|
VERSUS_INVERTER = {a: :o, o: :a}
|
|
6
6
|
|
|
7
7
|
def initialize(h, options)
|
|
@@ -44,7 +44,7 @@ module Contrek
|
|
|
44
44
|
def build_tangs_sequence
|
|
45
45
|
@vert_nodes.each do |line|
|
|
46
46
|
line.each do |node|
|
|
47
|
-
node.precalc_tangs_sequences
|
|
47
|
+
node.precalc_tangs_sequences(cluster: self)
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
end
|
|
@@ -103,9 +103,15 @@ module Contrek
|
|
|
103
103
|
# end
|
|
104
104
|
|
|
105
105
|
next_node = if (first.track & Contrek::Finder::Node::OMAX) != 0
|
|
106
|
-
|
|
106
|
+
if inner_v == :a
|
|
107
|
+
vert_nodes[first.y + Node::T_UP][first.upper_start]
|
|
108
|
+
else
|
|
109
|
+
vert_nodes[first.y + Node::T_DOWN][first.lower_start]
|
|
110
|
+
end
|
|
111
|
+
elsif inner_v == :a
|
|
112
|
+
vert_nodes[first.y + Node::T_DOWN][first.lower_end]
|
|
107
113
|
else
|
|
108
|
-
|
|
114
|
+
vert_nodes[first.y + Node::T_UP][first.upper_end]
|
|
109
115
|
end
|
|
110
116
|
|
|
111
117
|
if !next_node.nil?
|
|
@@ -258,7 +264,7 @@ module Contrek
|
|
|
258
264
|
plot_node(next_node, start_node, bounds, versus)
|
|
259
265
|
end
|
|
260
266
|
|
|
261
|
-
def add_node(node)
|
|
267
|
+
def add_node(node, offset)
|
|
262
268
|
@nodes += 1
|
|
263
269
|
node.abs_x_index = @vert_nodes[node.y].size
|
|
264
270
|
|
|
@@ -273,17 +279,17 @@ module Contrek
|
|
|
273
279
|
index = 0
|
|
274
280
|
loop do
|
|
275
281
|
up_node = up_nodes[index]
|
|
276
|
-
if up_node.max_x >= node.min_x
|
|
277
|
-
if up_node.min_x <= node.max_x
|
|
278
|
-
node.add_intersection(up_node)
|
|
279
|
-
up_node.add_intersection(node)
|
|
282
|
+
if (up_node.max_x + offset) >= node.min_x
|
|
283
|
+
if (up_node.min_x - offset) <= node.max_x
|
|
284
|
+
node.add_intersection(up_node, index)
|
|
285
|
+
up_node.add_intersection(node, node.abs_x_index)
|
|
280
286
|
end
|
|
281
287
|
return if (index += 1) == up_nodes_count
|
|
282
288
|
loop do
|
|
283
289
|
up_node = up_nodes[index]
|
|
284
|
-
if up_node.min_x <= node.max_x
|
|
285
|
-
node.add_intersection(up_node)
|
|
286
|
-
up_node.add_intersection(node)
|
|
290
|
+
if (up_node.min_x - offset) <= node.max_x
|
|
291
|
+
node.add_intersection(up_node, index)
|
|
292
|
+
up_node.add_intersection(node, node.abs_x_index)
|
|
287
293
|
else
|
|
288
294
|
return
|
|
289
295
|
end
|
|
@@ -91,6 +91,7 @@ module Contrek
|
|
|
91
91
|
|
|
92
92
|
# image scan
|
|
93
93
|
def scan
|
|
94
|
+
offset = (@node_cluster.options[:connectivity] == 8) ? 1 : 0
|
|
94
95
|
last_color = nil
|
|
95
96
|
matching = false
|
|
96
97
|
min_x = start_x
|
|
@@ -103,16 +104,16 @@ module Contrek
|
|
|
103
104
|
matching = true
|
|
104
105
|
if x == (end_x - 1)
|
|
105
106
|
max_x = x
|
|
106
|
-
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color)
|
|
107
|
+
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color, offset)
|
|
107
108
|
matching = false
|
|
108
109
|
end
|
|
109
110
|
elsif @matcher.unmatch?(color) && matching == true
|
|
110
111
|
max_x = x - 1
|
|
111
|
-
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color)
|
|
112
|
+
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color, offset)
|
|
112
113
|
matching = false
|
|
113
114
|
elsif x == (end_x - 1) && matching == true
|
|
114
115
|
max_x = x
|
|
115
|
-
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color)
|
|
116
|
+
Contrek::Finder::Node.new(@node_cluster, min_x, max_x, y, last_color, offset)
|
|
116
117
|
matching = false
|
|
117
118
|
end
|
|
118
119
|
end
|
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.1.
|
|
4
|
+
version: 1.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emanuele Cesaroni
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -135,12 +135,14 @@ files:
|
|
|
135
135
|
- CHANGELOG.md
|
|
136
136
|
- Gemfile
|
|
137
137
|
- Gemfile.lock
|
|
138
|
+
- LICENSE-MIT.md
|
|
138
139
|
- LICENSE.md
|
|
139
140
|
- README.md
|
|
140
141
|
- Rakefile
|
|
141
142
|
- contrek.gemspec
|
|
142
143
|
- contrek.png
|
|
143
144
|
- ext/cpp_polygon_finder/PolygonFinder/CMakeLists.txt
|
|
145
|
+
- ext/cpp_polygon_finder/PolygonFinder/LICENSE_AGPL.txt
|
|
144
146
|
- ext/cpp_polygon_finder/PolygonFinder/examples/example.cpp
|
|
145
147
|
- ext/cpp_polygon_finder/PolygonFinder/images/labyrinth.png
|
|
146
148
|
- ext/cpp_polygon_finder/PolygonFinder/images/sample_10240x10240.png
|
|
@@ -275,10 +277,9 @@ licenses:
|
|
|
275
277
|
- AGPL-3.0-only
|
|
276
278
|
metadata:
|
|
277
279
|
homepage_uri: https://github.com/runout77/contrek
|
|
278
|
-
source_code_uri: https://github.com/runout77/contrek
|
|
279
280
|
documentation_uri: https://github.com/runout77/contrek#readme
|
|
280
281
|
changelog_uri: https://github.com/runout77/contrek/blob/main/CHANGELOG.md
|
|
281
|
-
post_install_message:
|
|
282
|
+
post_install_message:
|
|
282
283
|
rdoc_options: []
|
|
283
284
|
require_paths:
|
|
284
285
|
- lib
|
|
@@ -293,8 +294,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
293
294
|
- !ruby/object:Gem::Version
|
|
294
295
|
version: '0'
|
|
295
296
|
requirements: []
|
|
296
|
-
rubygems_version: 3.
|
|
297
|
-
signing_key:
|
|
297
|
+
rubygems_version: 3.5.22
|
|
298
|
+
signing_key:
|
|
298
299
|
specification_version: 4
|
|
299
300
|
summary: Fast PNG contour tracing and shape detection for Ruby
|
|
300
301
|
test_files: []
|