pub struct Section {
pub outer: Polygon,
pub holes: Vec<Polygon>,
}Expand description
A section can consist of an outer polygon and zero or more hole polygons.
Fields§
§outer: PolygonOuter boundary (must be CCW for positive area)
holes: Vec<Polygon>Hole boundaries (each must be CW so that their signed area is negative)
Implementations§
Source§impl Section
impl Section
Sourcepub fn new(outer: Polygon, holes: Vec<Polygon>) -> Self
pub fn new(outer: Polygon, holes: Vec<Polygon>) -> Self
Create a new section from an outer polygon and optional holes.
The outer boundary is normalised to counter-clockwise orientation and each hole to clockwise orientation.
Sourcepub fn centroid(&self) -> Point
pub fn centroid(&self) -> Point
Centroid of the section using the composite area formula.
§Panics
Panics if the net section area (outer minus holes) is zero or
near-zero. Use try_centroid for a fallible
version that returns None instead of panicking.
Sourcepub fn try_centroid(&self) -> Option<Point>
pub fn try_centroid(&self) -> Option<Point>
Fallible centroid: returns None if the net section area is zero or
near-zero (degenerate section where outer area equals total hole area).
Sourcepub fn bounds(&self) -> (f64, f64, f64, f64)
pub fn bounds(&self) -> (f64, f64, f64, f64)
Bounding box of the section: (min_x, max_x, min_y, max_y)
Sourcepub fn contains_point(&self, point: Point) -> bool
pub fn contains_point(&self, point: Point) -> bool
Check if a point is inside the section (including holes).
Sourcepub fn frame_properties(&self, nu: f64) -> (f64, f64, f64, f64, f64, f64)
pub fn frame_properties(&self, nu: f64) -> (f64, f64, f64, f64, f64, f64)
Frame properties for beam/frame analysis (matches Python’s calculate_frame_properties).
Returns tuple: (area, ixx, iyy, ixy, j, phi)
area: cross-sectional aream²ixx: second moment of area about x-axism⁴iyy: second moment of area about y-axism⁴ixy: product of inertiam⁴j: St. Venant torsion constantm⁴phi: angle from centroidal x-axis to major principal axis (11), CCW positive, radians.phi = ½ atan2(2·Ixy, Ixx − Iyy).
Sourcepub fn frame_properties_with_material(
&self,
material: &Material,
) -> Result<TransformedFrameProperties, MaterialError>
pub fn frame_properties_with_material( &self, material: &Material, ) -> Result<TransformedFrameProperties, MaterialError>
Frame properties with transformed-section analysis for a homogeneous material.
Returns effective stiffnesses E·A, E·I, G·J and the mass per unit
length. The geometric properties are identical to
frame_properties_full because a
single-material section has modular ratio n = 1 everywhere.
§Errors
MaterialError::InvalidMaterial when the material fails validation.
For multi-material (genuinely composite) sections use
CompositeSection::transformed_properties,
which applies per-group modular ratios.
Source§impl Section
impl Section
Sourcepub fn frame_properties_full(&self, nu: f64) -> FrameProperties
pub fn frame_properties_full(&self, nu: f64) -> FrameProperties
Full frame properties including shear centre and warping constant.
Mirrors Python Section.calculate_frame_properties() (without the FEA
shear areas, see mesh module for those).
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate hole topology.
Checks (all relative to the section’s oriented polygons):
- All hole vertices lie inside the outer polygon (boundary-touching is
accepted, matching
Polygon::contains_pointon-edge semantics). - No hole edge interacts with the outer boundary (crosses, touches, or overlaps). Boundary-touching by a hole edge is rejected even though a hole vertex on the boundary is accepted in step 1.
- No two holes overlap (area overlap) or nest (one contains another).
- Holes are oriented CW (negative signed area).
Returns Ok(()) if valid, or Err(description) on failure.
Sourcepub fn new_validated(
outer: Polygon,
holes: Vec<Polygon>,
) -> Result<Self, String>
pub fn new_validated( outer: Polygon, holes: Vec<Polygon>, ) -> Result<Self, String>
Create a section with full topology validation.
Validates (see Section::validate):
- All hole vertices lie inside the outer boundary (boundary-touching accepted)
- No two holes overlap or nest (no hole-within-hole)
- No hole edge interacts with the outer boundary (crosses, touches, or overlaps); edge-level boundary-touching is rejected
- Orientation is normalised to outer CCW / holes CW
Returns Err with a descriptive message if validation fails.
Trait Implementations§
Source§impl From<JsonSection> for Section
Convert JsonSection back to Section.
impl From<JsonSection> for Section
Convert JsonSection back to Section.