axiolid_profile/
contour.rs

1//! Arbitrary closed contours.
2
3use axiolid_core::Interval;
4use axiolid_curve::Curve2;
5
6/// One bounded oriented curve segment.
7#[derive(Debug, Clone, PartialEq)]
8pub struct ProfileSegment {
9    /// Exact supporting curve.
10    pub curve: Curve2,
11    /// Parameter interval on `curve`.
12    ///
13    /// Always a finite span: a contour edge is bounded, so an unbounded
14    /// support such as a line contributes only this interval, never itself.
15    pub domain: Interval,
16    /// Whether parameter direction follows contour orientation.
17    pub same_sense: bool,
18}
19
20/// One oriented closed contour assembled from bounded exact curve segments.
21#[derive(Debug, Clone, Default, PartialEq)]
22pub struct Contour {
23    /// Consecutive bounded segments; closure is validated separately.
24    pub segments: Vec<ProfileSegment>,
25}
26
27impl Contour {
28    /// Construct from oriented segments without silently repairing gaps.
29    pub fn new(segments: Vec<ProfileSegment>) -> Self {
30        Self { segments }
31    }
32
33    /// Number of exact segments.
34    pub fn len(&self) -> usize {
35        self.segments.len()
36    }
37
38    /// Whether this contour has no segments.
39    pub fn is_empty(&self) -> bool {
40        self.segments.is_empty()
41    }
42}
43
44/// Closed outer contour and zero or more closed holes.
45#[derive(Debug, Clone, Default, PartialEq)]
46pub struct ContourProfile {
47    /// Outer boundary.
48    pub outer: Contour,
49    /// Inner boundaries.
50    pub holes: Vec<Contour>,
51}