Class: Laser::Cutter::Aggregator
- Inherits:
-
Object
- Object
- Laser::Cutter::Aggregator
- Defined in:
- lib/laser/cutter/aggregator.rb
Overview
Merges the lines of one face into the outline to cut.
Each edge draws its own notch path and its own corner boxes, so where two of them meet the same stretch is drawn twice, once from each side. That stretch runs through the material and must not be cut. So every collinear group of lines is combined as a symmetric difference: a point is cut when an odd number of lines cover it. Two identical lines cancel, two overlapping lines keep only the parts they do not share, and lines that touch or overlap end to end join into one.
Lines are grouped by axis and offset, sorted, and swept once, so a face of n lines takes n log n. Lines on neither axis pass through untouched.
Constant Summary collapse
- TOLERANCE =
Coordinates this close together count as the same.
Math.sqrt(Geometry::Tuple::PRECISION)
Instance Attribute Summary collapse
-
#lines ⇒ Array<Geometry::Line>
readonly
The outline, sorted.
Instance Method Summary collapse
-
#initialize(lines = []) ⇒ Aggregator
constructor
A new instance of Aggregator.
Constructor Details
#initialize(lines = []) ⇒ Aggregator
Returns a new instance of Aggregator.
25 26 27 |
# File 'lib/laser/cutter/aggregator.rb', line 25 def initialize(lines = []) @lines = (sweep(lines, 0) + sweep(lines, 1) + skewed(lines)).sort end |
Instance Attribute Details
#lines ⇒ Array<Geometry::Line> (readonly)
Returns the outline, sorted.
22 23 24 |
# File 'lib/laser/cutter/aggregator.rb', line 22 def lines @lines end |