Class: StraightSkeleton::Collapse
- Inherits:
-
Object
- Object
- StraightSkeleton::Collapse
- 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
-
#initialize(nodes, point, travel, sources) ⇒ Collapse
constructor
A new instance of Collapse.
- #replace!(&block) ⇒ Object
- #viable? ⇒ Boolean
Methods included from InteriorNode
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
9 10 11 |
# File 'lib/nswtopo/geometry/straight_skeleton/collapse.rb', line 9 def viable? @sources.all?(&:active?) end |