axiolid-model 0.3.2

Format-neutral geometry item tree. The currency between a format reader and a kernel.
Documentation
//! Surface relationships that compose curve and surface nodes.

use axiolid_core::{Scalar, Vec3};

use crate::NodeId;

/// Relationship between surface nodes.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum SurfaceRelation {
    /// Surface bounded by oriented curve nodes.
    CurveBounded {
        basis: NodeId,
        boundaries: Vec<NodeId>,
        implicit_outer: bool,
    },
    /// Rectangular parameter-space trim.
    RectangularTrimmed {
        basis: NodeId,
        u: (Scalar, Scalar),
        v: (Scalar, Scalar),
        u_sense: bool,
        v_sense: bool,
    },
    /// Constant-distance offset surface.
    Offset {
        basis: NodeId,
        distance: Scalar,
        self_intersect: Option<bool>,
    },
    /// Surface generated by translating a curve.
    LinearExtrusion {
        swept_curve: NodeId,
        direction: Vec3,
    },
    /// Surface generated by revolving a curve around an axis.
    Revolution {
        swept_curve: NodeId,
        axis_origin: axiolid_core::Point3,
        axis_direction: Vec3,
    },
}

impl SurfaceRelation {
    pub(crate) fn references(&self, out: &mut Vec<NodeId>) {
        match self {
            Self::CurveBounded {
                basis, boundaries, ..
            } => {
                out.push(*basis);
                out.extend(boundaries.iter().copied());
            }
            Self::RectangularTrimmed { basis, .. } | Self::Offset { basis, .. } => out.push(*basis),
            Self::LinearExtrusion { swept_curve, .. } | Self::Revolution { swept_curve, .. } => {
                out.push(*swept_curve)
            }
        }
    }
}