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
impl CompoundGeometry
Sourcepub fn new(geometries: Vec<Geometry>) -> Self
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.
Sourcepub fn new_validated(geometries: Vec<Geometry>) -> Result<Self, CompoundError>
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.
Sourcepub fn dissolved(geometries: Vec<Geometry>) -> Self
👎Deprecated since 0.1.0: Use dissolved_outer_only() for explicit naming; holes are dropped
pub fn dissolved(geometries: Vec<Geometry>) -> Self
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.
Sourcepub fn dissolved_outer_only(geometries: Vec<Geometry>) -> Self
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.
Sourcepub fn validate(&self) -> Result<(), CompoundError>
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).
Sourcepub fn from_sections(sections: &[Section]) -> Self
pub fn from_sections(sections: &[Section]) -> Self
Build a compound geometry from a slice of Section.
Sourcepub fn boolean(&self, other: &Self, op: BoolOp) -> Result<Self, BooleanError>
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
selfreduced by every region ofotherin sequence.
Sourcepub fn union(&self, other: &Self) -> Result<Self, BooleanError>
pub fn union(&self, other: &Self) -> Result<Self, BooleanError>
Boolean union with other.
Sourcepub fn intersection(&self, other: &Self) -> Result<Self, BooleanError>
pub fn intersection(&self, other: &Self) -> Result<Self, BooleanError>
Boolean intersection with other.
Sourcepub fn subtract(&self, other: &Self) -> Result<Self, BooleanError>
pub fn subtract(&self, other: &Self) -> Result<Self, BooleanError>
Boolean difference: this compound minus other.
Sourcepub fn centroid(&self) -> Point
pub fn centroid(&self) -> Point
Centroid of the compound section via the composite area formula.