Geometry

Trait Geometry 

Source
pub trait Geometry:
    Clone
    + Send
    + Sync {
    type Scalar: RealField + Copy;

    // Required methods
    fn id(&self) -> &GeometryId;
    fn quantity(&self) -> usize;
    fn measure(&self) -> Self::Scalar;
    fn aabb_vec(&self) -> (Vec<Self::Scalar>, Vec<Self::Scalar>);
    fn centroid(&self) -> Vec<Self::Scalar>;
    fn validate(&self) -> Result<()>;
    fn rotation_constraint(&self) -> &RotationConstraint<Self::Scalar>;

    // Provided methods
    fn aabb(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2]) { ... }
    fn allow_mirror(&self) -> bool { ... }
    fn priority(&self) -> i32 { ... }
}
Expand description

Trait for geometric shapes that can be nested or packed.

Required Associated Types§

Source

type Scalar: RealField + Copy

The coordinate type (f32 or f64).

Required Methods§

Source

fn id(&self) -> &GeometryId

Returns the unique identifier for this geometry.

Source

fn quantity(&self) -> usize

Returns the quantity of this geometry to place.

Source

fn measure(&self) -> Self::Scalar

Returns the area (2D) or volume (3D) of this geometry.

Source

fn aabb_vec(&self) -> (Vec<Self::Scalar>, Vec<Self::Scalar>)

Returns the axis-aligned bounding box as Vec (for generic dimension support).

Source

fn centroid(&self) -> Vec<Self::Scalar>

Returns the centroid (center of mass) of this geometry.

Source

fn validate(&self) -> Result<()>

Validates the geometry and returns an error if invalid.

Source

fn rotation_constraint(&self) -> &RotationConstraint<Self::Scalar>

Returns the allowed rotations for this geometry.

Provided Methods§

Source

fn aabb(&self) -> ([Self::Scalar; 2], [Self::Scalar; 2])

Returns the axis-aligned bounding box as (min, max) corners.

Source

fn allow_mirror(&self) -> bool

Returns whether mirroring/flipping is allowed.

Source

fn priority(&self) -> i32

Returns optional priority for placement order (higher = placed first).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§