Class: Laser::Cutter::Sloped::Panels

Inherits:
Object
  • Object
show all
Defined in:
lib/laser/cutter/sloped/panels.rb

Overview

The panels of a sloped box, each drawn in its own frame and without kerf: two side walls, the bottom, the back, the tilted panel, and the top and front strips when the box has them.

Along every joint the two panels that meet take opposite middle notches, so they interlock. A side wall takes a hole everywhere; the back and the front strip take a tab on every edge; the bottom and the top strip take a tab into the side walls and a hole into the back and the front strip.

Constant Summary collapse

NAMES =

The names of the panels, in the order they are drawn.

%w[left right bottom back top tilted front].freeze

Instance Method Summary collapse

Constructor Details

#initialize(profile:, width:, notcher:, lid:) ⇒ Panels

Returns a new instance of Panels.

Parameters:

  • profile (Profile)
  • width (Numeric) —

    the inside width of the box

  • notcher (Notcher)
  • lid (Symbol) —

    :full or :plain, how the tilted panel joins the side walls



23
24
25
26
27
28
29
30
# File 'lib/laser/cutter/sloped/panels.rb', line 23

def initialize(profile:, width:, notcher:, lid:)
  @profile = profile
  @width = width.to_f
  @notcher = notcher
  @lid = lid
  @corners = Corners.new(profile: profile, width: width, notcher: notcher)
  freeze
end

Instance Method Details

#sizes ⇒ Hash{String => Array(Float, Float)}

The inside size of each panel, which is what a Placement flips it within.

Returns:

  • (Hash{String => Array(Float, Float)}) —

    width and length of each panel the box has, by name



42
43
44
45
46
47
# File 'lib/laser/cutter/sloped/panels.rb', line 42

def sizes
  side = [@profile.depth, @profile.height]
  { 'left' => side, 'right' => side, 'bottom' => [@width, @profile.depth], 'back' => [@width, @profile.height],
    'top' => strip(@profile.top_strip_length), 'tilted' => [@width, @profile.tilted_length],
    'front' => strip(@profile.front_strip_length) }.compact
end

#to_h ⇒ Hash{String => Geometry::Loop}

Returns the outline of each panel the box has, by name.

Returns:

  • (Hash{String => Geometry::Loop}) —

    the outline of each panel the box has, by name



33
34
35
36
37
# File 'lib/laser/cutter/sloped/panels.rb', line 33

def to_h
  side = SidePanel.new(profile: @profile, notcher: @notcher, lid: @lid).loop
  { 'left' => side, 'right' => side, 'bottom' => bottom, 'back' => back,
    'top' => top, 'tilted' => tilted, 'front' => front }.compact
end