pub struct CrossSection { /* private fields */ }Implementations§
Source§impl CrossSection
impl CrossSection
pub fn new(polygons: Polygons) -> Self
Sourcepub fn from_polygons_fill(polygons: Polygons) -> Self
pub fn from_polygons_fill(polygons: Polygons) -> Self
Create a CrossSection from polygons, normalizing via Clipper2 Union. Mirrors C++ CrossSection(Polygons, FillRule) constructor which runs the polygons through C2::Union to merge overlapping regions.
Sourcepub fn from_rect(rect: &Rect) -> Self
pub fn from_rect(rect: &Rect) -> Self
Create a CrossSection from a Rect (axis-aligned rectangle). Matches C++ CrossSection(Rect) constructor.
pub fn square(size: f64) -> Self
Sourcepub fn square_vec2(size: Vec2, center: bool) -> Self
pub fn square_vec2(size: Vec2, center: bool) -> Self
Create a rectangle of size (w, h), optionally centered at origin. Matches C++ CrossSection::Square(vec2, center).
pub fn circle(radius: f64, segments: i32) -> Self
pub fn to_polygons(&self) -> Polygons
pub fn translate(&self, v: Vec2) -> Self
pub fn area(&self) -> f64
pub fn bounds(&self) -> Rect
pub fn union(&self, other: &Self) -> Self
pub fn intersection(&self, other: &Self) -> Self
pub fn difference(&self, other: &Self) -> Self
pub fn scale(&self, v: Vec2) -> Self
pub fn rotate(&self, degrees: f64) -> Self
Sourcepub fn mirror(&self, axis: Vec2) -> Self
pub fn mirror(&self, axis: Vec2) -> Self
Mirror through a line perpendicular to the given axis vector.
Matches C++ CrossSection::Mirror(ax) which uses I - 2*n*n^T.
pub fn is_empty(&self) -> bool
pub fn num_vert(&self) -> usize
pub fn num_contour(&self) -> usize
Sourcepub fn decompose(&self) -> Vec<Self>
pub fn decompose(&self) -> Vec<Self>
Decompose into connected components. Each component maintains its contours (outer boundary + holes).
Sourcepub fn simplify(&self, epsilon: f64) -> Self
pub fn simplify(&self, epsilon: f64) -> Self
Simplify contours by removing near-collinear vertices. Mirrors C++ CrossSection::Simplify(epsilon=1e-6): normalizes via union, filters tiny polygons, then applies SimplifyPaths with epsilon.
pub fn offset(&self, delta: f64) -> Self
Sourcepub fn offset_with_params(
&self,
delta: f64,
join_type: i32,
miter_limit: f64,
circular_segments: i32,
) -> Self
pub fn offset_with_params( &self, delta: f64, join_type: i32, miter_limit: f64, circular_segments: i32, ) -> Self
Offset with explicit join type and segment count. join_type: 0=Square, 1=Round, 2=Miter
pub fn minkowski_sum(&self, other: &Self) -> Self
Sourcepub fn from_polygon_with_fill_rule(polygon: Vec<Vec2>, fill_rule: i32) -> Self
pub fn from_polygon_with_fill_rule(polygon: Vec<Vec2>, fill_rule: i32) -> Self
Create CrossSection from a simple polygon with a specified fill rule. fill_rule: 0=EvenOdd, 1=NonZero, 2=Positive, 3=Negative
Sourcepub fn warp<F: FnMut(&mut Vec2)>(&self, f: F) -> Self
pub fn warp<F: FnMut(&mut Vec2)>(&self, f: F) -> Self
Apply a function to every vertex in-place.
Sourcepub fn batch_boolean(sections: &[Self], op: OpType) -> Self
pub fn batch_boolean(sections: &[Self], op: OpType) -> Self
Batch boolean operation on a slice of CrossSections. OpType::Add = union, Subtract = difference, Intersect = intersection.
Sourcepub fn hull_cross_sections(sections: &[Self]) -> Self
pub fn hull_cross_sections(sections: &[Self]) -> Self
Compute convex hull of all vertices in a slice of CrossSections.
Sourcepub fn hull_points(points: &[Vec2]) -> Self
pub fn hull_points(points: &[Vec2]) -> Self
Compute convex hull of a set of 2D points (Andrew’s monotone chain).
Trait Implementations§
Source§impl Clone for CrossSection
impl Clone for CrossSection
Source§fn clone(&self) -> CrossSection
fn clone(&self) -> CrossSection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more