Module: JennCad::Features::Cuttable
- Included in:
- Primitives::Cube, Primitives::RoundedCube
- Defined in:
- lib/jenncad/features/cuttable.rb
Instance Method Summary collapse
Instance Method Details
#cut(args, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/jenncad/features/cuttable.rb', line 3 def cut(args, &block) if args[:x] l = args[:x].min * @opts[:y] / 2.0 r = args[:x].max * @opts[:y] / 2.0 prepare_cut(l, r, &block).flip_x elsif args[:y] l = args[:y].min * @opts[:y] / 2.0 r = args[:y].max * @opts[:y] / 2.0 prepare_cut(l, r, &block).flip_y elsif args[:z] raise "cut for Z is not implemented yet" end end |
#prepare_cut(l, r, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jenncad/features/cuttable.rb', line 17 def prepare_cut(l, r, &block) part = block.call if part.z.to_d > 0.0 part.opts[:margins][:z] = 0.2 if l == 0.0 part.mz(r+0.1) else part.mz(l+part.z.to_d-0.2) end else part.opts[:margins][:z] = 0.2 part.z = l.abs + r.abs + 0.2 part.mz(-0.1) end end |