Skip to main content

CompoundGeometry

Struct CompoundGeometry 

Source
pub struct CompoundGeometry {
    pub geometries: Vec<Geometry>,
}
Expand description

A collection of independent regions, e.g. two parallel rectangles, an angle bolted to a plate, or a built-up girder.

Mirrors sectionproperties.pre.geometry.CompoundGeometry.

§Invariant

Regions are assumed to be material-disjoint: no part of one region’s material may overlap another region’s material. Properties (area, inertia, …) are computed by simple summation, which is only correct under this assumption.

Use CompoundGeometry::validate to check the invariant, and CompoundGeometry::dissolved_outer_only to merge overlapping inputs into a valid compound.

Fields§

§geometries: Vec<Geometry>

The individual regions that make up the compound section.

Implementations§

Source§

impl CompoundGeometry

Source

pub fn new(geometries: Vec<Geometry>) -> Self

Create a compound geometry from its constituent regions.

§Invariant

The caller guarantees that region materials are disjoint. Overlapping inputs silently double-count area/inertia in property computations. Use CompoundGeometry::validate to check, or CompoundGeometry::dissolved_outer_only to merge overlapping inputs.

Source

pub fn new_validated(geometries: Vec<Geometry>) -> Result<Self, CompoundError>

Validating constructor: returns an error if any two regions have overlapping material or a hole escapes its outer boundary.

Source

pub fn dissolved(geometries: Vec<Geometry>) -> Self

👎Deprecated since 0.1.0:

Use dissolved_outer_only() for explicit naming; holes are dropped

Merge overlapping inputs into a valid (material-disjoint) compound by dissolving overlaps with the boolean union. Holes are dropped during dissolution (the merged outline is exact; re-derive holes afterwards if required). This is a union of outer boundaries only.

Prefer Self::dissolved_outer_only for explicit naming.

Source

pub fn dissolved_outer_only(geometries: Vec<Geometry>) -> Self

Merge overlapping inputs into a valid (material-disjoint) compound by dissolving overlaps with the boolean union. Holes are dropped – only outer boundaries are united. This is a union of outer boundaries only; holes must be re-derived afterwards if required.

Source

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

Check the material-disjoint invariant.

  • every hole must lie fully inside its own outer boundary,
  • no two regions may claim the same material point (verified with deterministic edge–edge and containment checks).
Source

pub fn from_sections(sections: &[Section]) -> Self

Build a compound geometry from a slice of Section.

Source

pub fn boolean(&self, other: &Self, op: BoolOp) -> Result<Self, BooleanError>

Boolean operation across compound geometries.

Mirrors CompoundGeometry.combine(other, operation):

  • Union: all regions of both compounds unioned pairwise into one accumulated set (dissolves internal overlaps).
  • Intersection: every region pair intersected, keeping non-empty results.
  • Difference: each region of self reduced by every region of other in sequence.
Source

pub fn union(&self, other: &Self) -> Result<Self, BooleanError>

Boolean union with other.

Source

pub fn intersection(&self, other: &Self) -> Result<Self, BooleanError>

Boolean intersection with other.

Source

pub fn subtract(&self, other: &Self) -> Result<Self, BooleanError>

Boolean difference: this compound minus other.

Source

pub fn area(&self) -> f64

Total net area across all regions.

Source

pub fn centroid(&self) -> Point

Centroid of the compound section via the composite area formula.

Source

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

Bounding box of the compound geometry: (min_x, max_x, min_y, max_y).

Source

pub fn perimeter(&self) -> f64

Total perimeter across all regions (outer + holes).

Source

pub fn polygons(&self) -> Vec<Polygon>

Return all polygons (outer first, then holes) across every region, with any transforms already applied.

Trait Implementations§

Source§

impl Clone for CompoundGeometry

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 CompoundGeometry

Source§

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

Formats the value using the given formatter. Read more
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.

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.