Class: Contrek::Concurrent::Cursor
- Inherits:
-
Object
- Object
- Contrek::Concurrent::Cursor
- Defined in:
- lib/contrek/finder/concurrent/cursor.rb
Instance Attribute Summary collapse
-
#orphan_inners ⇒ Object
readonly
Returns the value of attribute orphan_inners.
-
#shapes_sequence ⇒ Object
readonly
Returns the value of attribute shapes_sequence.
Instance Method Summary collapse
-
#initialize(cluster:, shape:) ⇒ Cursor
constructor
A new instance of Cursor.
- #inspect ⇒ Object
- #join_inners!(treemap) ⇒ Object
-
#join_outers! ⇒ Object
Given the initial polyline, draw its outer boundary, possibly extending into adjacent polylines, and then connect them.
Constructor Details
#initialize(cluster:, shape:) ⇒ Cursor
Returns a new instance of Cursor.
8 9 10 11 12 13 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 8 def initialize(cluster:, shape:) @shapes_sequence = [shape] @cluster = cluster @outer_polyline = shape.outer_polyline @orphan_inners = [] end |
Instance Attribute Details
#orphan_inners ⇒ Object (readonly)
Returns the value of attribute orphan_inners.
6 7 8 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 6 def orphan_inners @orphan_inners end |
#shapes_sequence ⇒ Object (readonly)
Returns the value of attribute shapes_sequence.
6 7 8 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 6 def shapes_sequence @shapes_sequence end |
Instance Method Details
#inspect ⇒ Object
15 16 17 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 15 def inspect self.class end |
#join_inners!(treemap) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 43 def join_inners!(treemap) return_inner_polylines = [] shape_index = 0 while shape_index < @shapes_sequence.size shape = @shapes_sequence[shape_index] polyline = shape.outer_polyline polyline.parts.each do |part| if part.innerable? all_parts = [] tracked_end_points = [] traverse_inner(part, all_parts, tracked_end_points) retme_sequence = Sequence.new all_parts.each do |part| part.touch! retme_sequence.append(part) end inner_polyline = InnerPolyline.new(sequence: retme_sequence) return_inner_polylines << inner_polyline mark_children(tracked_end_points, polyline, inner_polyline) if treemap end end shape_index += 1 end return_inner_polylines end |
#join_outers! ⇒ Object
Given the initial polyline, draw its outer boundary, possibly extending into adjacent polylines, and then connect them. At the end, @shapes_sequence contains the merged polylines. Returns a new resulting polyline.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/contrek/finder/concurrent/cursor.rb', line 22 def join_outers! seq_log = [] outer_joined_polyline = Sequence.new traverse_outer(@outer_polyline.parts.first, seq_log, @shapes_sequence, outer_joined_polyline) outer_joined_polyline.pop! if outer_joined_polyline.head.payload == outer_joined_polyline.tail.payload && @cluster.tiles.first.left? && @cluster.tiles.last.right? @shapes_sequence.each do |shape| shape.outer_polyline.turn_on(Polyline::TRACKED_OUTER) next if shape == @outer_polyline.shape @orphan_inners += shape.inner_polylines shape.clear_inner! end outer_joined_polyline end |