Skip to content

Commit d114250

Browse files
authored
Add a basic under-the-desk power brick bracket example (#229)
1 parent b637451 commit d114250

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

examples/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub mod keycap;
1515
pub mod letter_a;
1616
pub mod offset_2d;
1717
pub mod pentafoil;
18+
pub mod power_brick_bracket;
1819
pub mod rounded_chamfer;
1920
pub mod section;
2021
pub mod swept_face;
@@ -41,6 +42,7 @@ pub enum Example {
4142
LetterA,
4243
Offset2d,
4344
Pentafoil,
45+
PowerBrickBracket,
4446
RoundedChamfer,
4547
Section,
4648
SweptFace,
@@ -69,6 +71,7 @@ impl Example {
6971
Example::LetterA => letter_a::shape(),
7072
Example::Offset2d => offset_2d::shape(),
7173
Example::Pentafoil => pentafoil::shape(),
74+
Example::PowerBrickBracket => power_brick_bracket::shape(),
7275
Example::RoundedChamfer => rounded_chamfer::shape(),
7376
Example::Section => section::shape(),
7477
Example::SweptFace => swept_face::shape(),
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)