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
//! Whole-solid queries the families ask (`quiddity._solid_properties`): a solid's box,
//! validity, volume and area.
//!
//! Python keeps one cache of these per run so nine families do not recompute them. Here the
//! per-face answers they are made of (each face's box and mass, a solid's validity) are cached
//! on [`Part`] itself, so asking again costs a sum over cached faces, and every family reads the
//! same values. [`super::body`] builds body keys from the same reads.
use crate::kernel::brep::Part;
use crate::kernel::geom::Bounds;
internal_entry! {
/// The solid's box (`SolidProperties.bounding_box`).
pub fn bounding_box(part: &Part, solid: usize) -> Bounds {
part.solid_bounds(solid)
}
}
internal_entry! {
/// Whether the kernel calls the solid valid (`SolidProperties.is_valid`).
pub fn is_valid(part: &Part, solid: usize) -> bool {
part.solid_is_valid(solid)
}
}
internal_entry! {
/// The solid's volume (`SolidProperties.volume`), or `None` when a face's mass cannot be
/// computed: an unknown volume is never reported as a number.
pub fn volume(part: &Part, solid: usize) -> Option<f64> {
part.solid_mass(solid).map(|(v, _)| v)
}
}
internal_entry! {
/// The solid's area (`SolidProperties.area`), or `None` as for [`volume`].
pub fn area(part: &Part, solid: usize) -> Option<f64> {
part.solid_mass(solid).map(|(_, a)| a)
}
}