Class: StraightSkeleton::Collapse

Inherits:
Object
  • Object
show all
Includes:
InteriorNode
Defined in:
lib/nswtopo/geometry/straight_skeleton/collapse.rb

Instance Attribute Summary

Attributes included from Node

#neighbours, #normals, #original, #point, #travel

Instance Method Summary collapse

Methods included from InteriorNode

#<=>, #insert!

Methods included from Node

#active?, #index, #next, #prev, #project, #reflex?, #terminal?

Constructor Details

#initialize(nodes, point, travel, sources) ⇒ Collapse

Returns a new instance of Collapse.



5
6
7
# File 'lib/nswtopo/geometry/straight_skeleton/collapse.rb', line 5

def initialize(nodes, point, travel, sources)
  @original, @nodes, @point, @travel, @sources = self, nodes, point, travel, sources
end

Instance Method Details

#replace!(&block) ⇒ Object



13
14
15
16
17
# File 'lib/nswtopo/geometry/straight_skeleton/collapse.rb', line 13

def replace!(&block)
  @neighbours = [@sources[0].prev, @sources[1].next]
  @neighbours.inject(&:==) ? block.call(prev) : insert! if @neighbours.any?
  @sources.each(&block)
end

#viable?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/nswtopo/geometry/straight_skeleton/collapse.rb', line 9

def viable?
  @sources.all?(&:active?)
end