|
| 1 | +use glam::dvec3; |
| 2 | +use opencascade::{ |
| 3 | + primitives::{IntoShape, Shape}, |
| 4 | + workplane::Workplane, |
| 5 | +}; |
| 6 | + |
| 7 | +pub fn shape() -> Shape { |
| 8 | + let brick_width = 47.3; |
| 9 | + let brick_height = 29.2; |
| 10 | + let bracket_depth = 100.0; |
| 11 | + let thickness = 3.0; |
| 12 | + let wing_width = 20.0; |
| 13 | + let hole_radius = 1.35; |
| 14 | + let use_four_holes = false; |
| 15 | + |
| 16 | + let port_cutout = Workplane::xz() |
| 17 | + .sketch() |
| 18 | + .line_dy(brick_height) |
| 19 | + .line_dx(brick_width) |
| 20 | + .line_dy(-brick_height) |
| 21 | + .line_dx(wing_width + thickness) |
| 22 | + .line_dy(thickness) |
| 23 | + .line_dx(-wing_width) |
| 24 | + .line_dy(brick_height) |
| 25 | + .line_dx(-(brick_width + thickness * 2.0)) |
| 26 | + .line_dy(-brick_height) |
| 27 | + .line_dx(-wing_width) |
| 28 | + .line_dy(-thickness) |
| 29 | + .close() |
| 30 | + .to_face(); |
| 31 | + |
| 32 | + let mut bracket = port_cutout.extrude(dvec3(0.0, bracket_depth, 0.0)).into_shape(); |
| 33 | + |
| 34 | + let drill_x_left = -thickness - (wing_width / 2.0); |
| 35 | + let drill_x_right = brick_width + thickness + (wing_width / 2.0); |
| 36 | + let drill_z = thickness; |
| 37 | + |
| 38 | + let drill_positions = if use_four_holes { |
| 39 | + vec![ |
| 40 | + dvec3(drill_x_left, bracket_depth / 4.0, drill_z), |
| 41 | + dvec3(drill_x_left, (bracket_depth * 3.0) / 4.0, drill_z), |
| 42 | + dvec3(drill_x_right, bracket_depth / 4.0, drill_z), |
| 43 | + dvec3(drill_x_right, (bracket_depth * 3.0) / 4.0, drill_z), |
| 44 | + ] |
| 45 | + } else { |
| 46 | + vec![ |
| 47 | + dvec3(drill_x_left, bracket_depth / 2.0, drill_z), |
| 48 | + dvec3(drill_x_right, bracket_depth / 2.0, drill_z), |
| 49 | + ] |
| 50 | + }; |
| 51 | + |
| 52 | + for drill_pos in drill_positions { |
| 53 | + bracket = bracket.drill_hole(drill_pos, dvec3(0.0, 0.0, -1.0), hole_radius); |
| 54 | + } |
| 55 | + |
| 56 | + bracket |
| 57 | +} |
0 commit comments