1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use super::InnerAtom;
use crate::Layer;
use geo::Coordinate;
use std::fmt;
#[derive(Debug, Clone)]
pub struct ScrewHole {
center: Coordinate<f64>,
drill_radius: f64,
annular_ring_radius: f64,
}
impl ScrewHole {
pub fn with_diameter(dia: f64) -> Self {
Self {
drill_radius: dia / 2.0,
annular_ring_radius: (dia / 2.0) + 1.25,
..Self::default()
}
}
}
impl Default for ScrewHole {
fn default() -> Self {
Self {
center: [0., 0.].into(),
drill_radius: 1.55,
annular_ring_radius: 2.75,
}
}
}
impl fmt::Display for ScrewHole {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"drill(center = {:?}, {}/{})",
self.center, self.drill_radius, self.annular_ring_radius
)
}
}
impl super::InnerFeature for ScrewHole {
fn name(&self) -> &'static str {
"screw_hole"
}
fn translate(&mut self, v: Coordinate<f64>) {
self.center = self.center + v;
}
fn atoms(&self) -> Vec<InnerAtom> {
vec![
InnerAtom::Circle {
center: self.center,
radius: self.annular_ring_radius,
layer: Layer::BackCopper,
},
InnerAtom::Circle {
center: self.center,
radius: self.annular_ring_radius,
layer: Layer::BackMask,
},
InnerAtom::Circle {
center: self.center,
radius: self.annular_ring_radius,
layer: Layer::FrontCopper,
},
InnerAtom::Circle {
center: self.center,
radius: self.annular_ring_radius,
layer: Layer::FrontMask,
},
InnerAtom::Drill {
center: self.center,
radius: self.drill_radius,
plated: true,
},
]
}
}