Skip to main content

Section

Struct Section 

Source
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: Polygon

Outer 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

Source

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.

Source

pub fn area(&self) -> f64

Net area of the section (outer area minus hole areas).

Source

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.

Source

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).

Source

pub fn bounds(&self) -> (f64, f64, f64, f64)

Bounding box of the section: (min_x, max_x, min_y, max_y)

Source

pub fn width(&self) -> f64

Width of the section (max_x - min_x)

Source

pub fn height(&self) -> f64

Height of the section (max_y - min_y)

Source

pub fn contains_point(&self, point: Point) -> bool

Check if a point is inside the section (including holes).

Source

pub fn perimeter(&self) -> f64

Perimeter of the section (outer + holes).

Source

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 area m²
  • ixx: second moment of area about x-axis m⁴
  • iyy: second moment of area about y-axis m⁴
  • ixy: product of inertia m⁴
  • j: St. Venant torsion constant m⁴
  • phi: angle from centroidal x-axis to major principal axis (11), CCW positive, radians. phi = ½ atan2(2·Ixy, Ixx − Iyy).
Source

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

Source

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).

Source

pub fn validate(&self) -> Result<(), String>

Validate hole topology.

Checks (all relative to the section’s oriented polygons):

  1. All hole vertices lie inside the outer polygon (boundary-touching is accepted, matching Polygon::contains_point on-edge semantics).
  2. 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.
  3. No two holes overlap (area overlap) or nest (one contains another).
  4. Holes are oriented CW (negative signed area).

Returns Ok(()) if valid, or Err(description) on failure.

Source

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 Clone for Section

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Section

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<JsonSection> for Section

Convert JsonSection back to Section.

Source§

fn from(json: JsonSection) -> Self

Converts to this type from the input type.
Source§

impl From<Section> for CompoundGeometry

Convert a Section into a single-geometry compound.

Source§

fn from(section: Section) -> Self

Converts to this type from the input type.
Source§

impl ParametricSection for Section

Source§

fn build(&self) -> Section

Build the section geometry (outer boundary + holes).
Source§

fn designation(&self) -> String

Get the section name/designation.
Source§

fn build_composite(&self, material: Material) -> CompositeSection

Build the section as a composite section with material groups.
Source§

fn mass_per_length(&self, material: &Material) -> f64

Get approximate mass per unit length [kg/m].
Source§

impl ThinWalledCheck for Section

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.