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
//! Semantic annotations exchanged without kernel topology. Probes name
//! the controlled faces; the caller specifies their coordinate frame.
/// Semantic annotations of one body. Workbenches answer in world
/// coordinates; export receives probes in the body's own frame.
#[derive(Debug, Clone, Default, PartialEq)]
pub struct SemanticPmi {
pub tolerances: Vec<PmiTolerance>,
pub datums: Vec<PmiDatum>,
pub dimensions: Vec<PmiDimension>,
}
impl SemanticPmi {
pub fn is_empty(&self) -> bool {
self.tolerances.is_empty() && self.datums.is_empty() && self.dimensions.is_empty()
}
/// Move every face probe into another frame.
pub fn map_points(&mut self, point: impl Fn([f64; 3]) -> [f64; 3]) {
for at in self
.tolerances
.iter_mut()
.map(|t| &mut t.at)
.chain(self.datums.iter_mut().map(|d| &mut d.at))
.chain(self.dimensions.iter_mut().flat_map(|d| &mut d.features))
{
for p in at {
*p = point(*p);
}
}
}
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct PmiTolerance {
/// AP242 entity word without `_tolerance`, such as `flatness`.
pub kind: String,
pub name: String,
/// Zone width in millimetres.
pub magnitude: f64,
/// Datum labels in precedence order, primary first.
pub datums: Vec<String>,
/// Material and zone modifiers, using the AP242 words.
pub modifiers: Vec<String>,
/// Modifiers of each reference, in the same order as `datums`.
pub datum_modifiers: Vec<Vec<String>>,
pub at: Vec<[f64; 3]>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct PmiDatum {
pub label: String,
pub at: Vec<[f64; 3]>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct PmiDimension {
/// The dimensional characteristic, e.g. `diameter` or `linear distance`.
pub name: String,
/// True for radians; false for millimetres. Allowances use the same unit.
pub angular: bool,
pub nominal: f64,
pub plus: Option<f64>,
/// Signed lower allowance, normally negative.
pub minus: Option<f64>,
/// One probe group for a size, two ordered groups for a location.
pub features: Vec<Vec<[f64; 3]>>,
}