pub struct Geometry2D { /* private fields */ }Expand description
A 2D polygon geometry that can be nested.
Implementations§
Source§impl Geometry2D
impl Geometry2D
Sourcepub fn new(id: impl Into<GeometryId>) -> Self
pub fn new(id: impl Into<GeometryId>) -> Self
Creates a new 2D geometry with the given ID.
Sourcepub fn with_polygon(self, vertices: Vec<(f64, f64)>) -> Self
pub fn with_polygon(self, vertices: Vec<(f64, f64)>) -> Self
Sets the polygon from a list of (x, y) vertices.
Sourcepub fn with_quantity(self, n: usize) -> Self
pub fn with_quantity(self, n: usize) -> Self
Sets the quantity to place.
Sourcepub fn with_rotations_deg(self, angles: Vec<f64>) -> Self
pub fn with_rotations_deg(self, angles: Vec<f64>) -> Self
Sets the allowed rotation angles in degrees.
Sourcepub fn with_rotations(self, angles: Vec<f64>) -> Self
pub fn with_rotations(self, angles: Vec<f64>) -> Self
Sets the allowed rotation angles in radians.
Sourcepub fn with_rotation_constraint(
self,
constraint: RotationConstraint<f64>,
) -> Self
pub fn with_rotation_constraint( self, constraint: RotationConstraint<f64>, ) -> Self
Sets the rotation constraint.
Sourcepub fn with_priority(self, priority: i32) -> Self
pub fn with_priority(self, priority: i32) -> Self
Sets the placement priority.
Sourcepub fn rectangle(id: impl Into<GeometryId>, width: f64, height: f64) -> Self
pub fn rectangle(id: impl Into<GeometryId>, width: f64, height: f64) -> Self
Creates a rectangular geometry.
Sourcepub fn circle(id: impl Into<GeometryId>, radius: f64, n: usize) -> Self
pub fn circle(id: impl Into<GeometryId>, radius: f64, n: usize) -> Self
Creates a circle approximation with n vertices.
Sourcepub fn l_shape(
id: impl Into<GeometryId>,
width: f64,
height: f64,
notch_width: f64,
notch_height: f64,
) -> Self
pub fn l_shape( id: impl Into<GeometryId>, width: f64, height: f64, notch_width: f64, notch_height: f64, ) -> Self
Creates an L-shaped geometry.
Sourcepub fn allow_flip(&self) -> bool
pub fn allow_flip(&self) -> bool
Returns whether flipping is allowed.
Sourcepub fn to_geo_polygon(&self) -> GeoPolygon<f64>
pub fn to_geo_polygon(&self) -> GeoPolygon<f64>
Converts to a geo crate Polygon.
Source§impl Geometry2D
impl Geometry2D
Sourcepub fn aabb_at_rotation(&self, rotation: f64) -> ([f64; 2], [f64; 2])
pub fn aabb_at_rotation(&self, rotation: f64) -> ([f64; 2], [f64; 2])
Computes the AABB of the geometry at a given rotation angle (in radians).
Returns (min, max) as ([min_x, min_y], [max_x, max_y])
Sourcepub fn dimensions_at_rotation(&self, rotation: f64) -> (f64, f64)
pub fn dimensions_at_rotation(&self, rotation: f64) -> (f64, f64)
Returns the width and height of the AABB at a given rotation.
Trait Implementations§
Source§impl Clone for Geometry2D
impl Clone for Geometry2D
Source§fn clone(&self) -> Geometry2D
fn clone(&self) -> Geometry2D
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Geometry2D
impl Debug for Geometry2D
Source§impl Geometry for Geometry2D
impl Geometry for Geometry2D
Source§fn id(&self) -> &GeometryId
fn id(&self) -> &GeometryId
Returns the unique identifier for this geometry.
Source§fn aabb(&self) -> ([f64; 2], [f64; 2])
fn aabb(&self) -> ([f64; 2], [f64; 2])
Returns the axis-aligned bounding box as (min, max) corners.
Source§fn aabb_vec(&self) -> (Vec<f64>, Vec<f64>)
fn aabb_vec(&self) -> (Vec<f64>, Vec<f64>)
Returns the axis-aligned bounding box as Vec (for generic dimension support).
Source§fn rotation_constraint(&self) -> &RotationConstraint<f64>
fn rotation_constraint(&self) -> &RotationConstraint<f64>
Returns the allowed rotations for this geometry.
Source§fn allow_mirror(&self) -> bool
fn allow_mirror(&self) -> bool
Returns whether mirroring/flipping is allowed.
Source§impl Geometry2DExt for Geometry2D
impl Geometry2DExt for Geometry2D
Source§fn outer_ring(&self) -> &[(f64, f64)]
fn outer_ring(&self) -> &[(f64, f64)]
Returns the outer boundary as a sequence of points (polygon vertices).
Auto Trait Implementations§
impl Freeze for Geometry2D
impl RefUnwindSafe for Geometry2D
impl Send for Geometry2D
impl Sync for Geometry2D
impl Unpin for Geometry2D
impl UnwindSafe for Geometry2D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.