pub struct Polygon {
pub hull: SmallVec<[Point; 8]>,
pub holes: Vec<SmallVec<[Point; 8]>>,
}Fields§
§hull: SmallVec<[Point; 8]>§holes: Vec<SmallVec<[Point; 8]>>Implementations§
Source§impl Polygon
impl Polygon
pub fn rect(b: Bbox) -> Self
Sourcepub fn from_hull(hull: impl IntoIterator<Item = Point>) -> Self
pub fn from_hull(hull: impl IntoIterator<Item = Point>) -> Self
Build a polygon from a hull. The hull is canonicalized: clockwise winding, starting from the lowest-y/lowest-x vertex. This matches KLayout’s canonical form so cross-tool round-trips preserve byte-equal vertex sequences.
Sourcepub fn from_hull_raw(hull: impl IntoIterator<Item = Point>) -> Self
pub fn from_hull_raw(hull: impl IntoIterator<Item = Point>) -> Self
Like from_hull but skips canonicalization. Use when you specifically
need to preserve a particular vertex order (extremely rare; mainly for
tests that probe normalization itself).
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Canonicalize in place: hull → lowest-y/lowest-x first, CW winding; holes → lowest-y/lowest-x first, CCW winding; hole list sorted by the first vertex of each hole so polygons that differ only in hole-construction order hash identically.
Sourcepub fn add_hole(&mut self, hole: impl IntoIterator<Item = Point>)
pub fn add_hole(&mut self, hole: impl IntoIterator<Item = Point>)
Append a hole, normalizing winding and re-sorting the hole list.
pub fn bbox(&self) -> Bbox
pub fn transform(&self, t: Trans) -> Polygon
Trait Implementations§
impl Eq for Polygon
impl StructuralPartialEq for Polygon
Auto Trait Implementations§
impl Freeze for Polygon
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnsafeUnpin for Polygon
impl UnwindSafe for Polygon
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