axiolid_model/
surface_relation.rs

1//! Surface relationships that compose curve and surface nodes.
2
3use axiolid_core::{Scalar, Vec3};
4
5use crate::NodeId;
6
7/// Relationship between surface nodes.
8#[non_exhaustive]
9#[derive(Debug, Clone, PartialEq)]
10pub enum SurfaceRelation {
11    /// Surface bounded by oriented curve nodes.
12    CurveBounded {
13        basis: NodeId,
14        boundaries: Vec<NodeId>,
15        implicit_outer: bool,
16    },
17    /// Rectangular parameter-space trim.
18    RectangularTrimmed {
19        basis: NodeId,
20        u: (Scalar, Scalar),
21        v: (Scalar, Scalar),
22        u_sense: bool,
23        v_sense: bool,
24    },
25    /// Constant-distance offset surface.
26    Offset {
27        basis: NodeId,
28        distance: Scalar,
29        self_intersect: Option<bool>,
30    },
31    /// Surface generated by translating a curve.
32    LinearExtrusion {
33        swept_curve: NodeId,
34        direction: Vec3,
35    },
36    /// Surface generated by revolving a curve around an axis.
37    Revolution {
38        swept_curve: NodeId,
39        axis_origin: axiolid_core::Point3,
40        axis_direction: Vec3,
41    },
42}
43
44impl SurfaceRelation {
45    pub(crate) fn references(&self, out: &mut Vec<NodeId>) {
46        match self {
47            Self::CurveBounded {
48                basis, boundaries, ..
49            } => {
50                out.push(*basis);
51                out.extend(boundaries.iter().copied());
52            }
53            Self::RectangularTrimmed { basis, .. } | Self::Offset { basis, .. } => out.push(*basis),
54            Self::LinearExtrusion { swept_curve, .. } | Self::Revolution { swept_curve, .. } => {
55                out.push(*swept_curve)
56            }
57        }
58    }
59}