Class: Contrek::Finder::PolygonFinder
- Inherits:
-
Object
- Object
- Contrek::Finder::PolygonFinder
- Defined in:
- lib/contrek/finder/polygon_finder.rb
Defined Under Namespace
Classes: NodeDescriptor
Instance Method Summary collapse
- #draw_polygons(png_image) ⇒ Object
- #draw_shapelines(png_image) ⇒ Object
- #end_x ⇒ Object
- #get_shapelines ⇒ Object
-
#initialize(bitmap, matcher, test_bitmap = nil, options = {}) ⇒ PolygonFinder
constructor
A new instance of PolygonFinder.
- #inspect ⇒ Object
-
#process_info ⇒ Object
infos.
- #sanitize_options ⇒ Object
- #start_x ⇒ Object
Constructor Details
#initialize(bitmap, matcher, test_bitmap = nil, options = {}) ⇒ PolygonFinder
Returns a new instance of PolygonFinder.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/contrek/finder/polygon_finder.rb', line 10 def initialize(bitmap, matcher, test_bitmap = nil, = {}) = {versus: :a}.merge() @source_bitmap = bitmap @matcher = matcher @test_bitmap = test_bitmap @node_cluster = NodeCluster.new(@source_bitmap.h, ) @reports = {} # 1 finds matching blocks @reports[:scan] = Benchmark.measure do scan end # 2 builds relational spatially tree map @reports[:build_tangs_sequence] = Benchmark.measure do @node_cluster.build_tangs_sequence end # 3 plotting @reports[:plot] = Benchmark.measure do @node_cluster.plot(@test_bitmap) end # 4 compress @reports[:compress] = Benchmark.measure do if .has_key?(:compress) @node_cluster.compress_coords end end end |
Instance Method Details
#draw_polygons(png_image) ⇒ Object
67 68 69 |
# File 'lib/contrek/finder/polygon_finder.rb', line 67 def draw_polygons(png_image) Contrek::Bitmaps::Painting.direct_draw_polygons(@node_cluster.polygons, png_image) end |
#draw_shapelines(png_image) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/contrek/finder/polygon_finder.rb', line 71 def draw_shapelines(png_image) slines = get_shapelines color = ChunkyPNG::Color("blue @ 1.0") slines.each do |sline| png_image.draw_line(sline[:start_x], sline[:y], sline[:end_x], sline[:y], color) end end |
#end_x ⇒ Object
87 88 89 |
# File 'lib/contrek/finder/polygon_finder.rb', line 87 def end_x @source_bitmap.w end |
#get_shapelines ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/contrek/finder/polygon_finder.rb', line 57 def get_shapelines shapes = [] @node_cluster.vert_nodes.each do |line| line.each do |node| shapes << {start_x: node.min_x, end_x: node.max_x, y: node.y} end end shapes end |
#inspect ⇒ Object
79 80 81 |
# File 'lib/contrek/finder/polygon_finder.rb', line 79 def inspect "" end |
#process_info ⇒ Object
infos
48 49 50 51 52 53 54 55 |
# File 'lib/contrek/finder/polygon_finder.rb', line 48 def process_info {named_sequence: @node_cluster.sequences.map { |list| list.map(&:name).join }.join("-"), groups: @node_cluster.sequences.size, groups_names: @node_cluster.root_nodes.map(&:name).join, polygons: @node_cluster.polygons, benchmarks: format_benchmarks, treemap: (@node_cluster.treemap if .has_key?(:treemap))} end |
#sanitize_options ⇒ Object
43 44 45 |
# File 'lib/contrek/finder/polygon_finder.rb', line 43 def [:versus] = :a unless [:versus] == :a || [:versus] == :o end |
#start_x ⇒ Object
83 84 85 |
# File 'lib/contrek/finder/polygon_finder.rb', line 83 def start_x 0 end |