pub struct Region {
pub loops: Vec<Loop>,
}Expand description
A planar region: oriented loops under the positive-winding rule.
Fields§
§loops: Vec<Loop>Implementations§
Source§impl Region
impl Region
Sourcepub fn new(loops: Vec<Loop>, tol: &Tolerance) -> Result<Self, PlanarError>
pub fn new(loops: Vec<Loop>, tol: &Tolerance) -> Result<Self, PlanarError>
A region from already oriented loops (outer CCW, holes CW), validated.
Sourcepub fn from_unoriented(
loops: Vec<Loop>,
tol: &Tolerance,
) -> Result<Self, PlanarError>
pub fn from_unoriented( loops: Vec<Loop>, tol: &Tolerance, ) -> Result<Self, PlanarError>
A region from loops of unknown orientation, assuming they do not cross: each loop is oriented by its nesting depth (even depth outer, odd hole).
pub fn empty() -> Self
pub fn is_empty(&self) -> bool
pub fn area(&self) -> f64
pub fn bounds(&self) -> (Point2, Point2)
Sourcepub fn canonical_segments(&self, tol: &Tolerance) -> Vec<Segment>
pub fn canonical_segments(&self, tol: &Tolerance) -> Vec<Segment>
Every segment of every loop in canonical form.
pub fn contains(&self, p: Point2, tol: &Tolerance) -> bool
Sourcepub fn nearest_boundary(&self, p: Point2) -> Option<(Point2, f64)>
pub fn nearest_boundary(&self, p: Point2) -> Option<(Point2, f64)>
Nearest boundary point to p and the distance to it.
Sourcepub fn signed_distance(&self, p: Point2, tol: &Tolerance) -> f64
pub fn signed_distance(&self, p: Point2, tol: &Tolerance) -> f64
Signed distance: positive inside, negative outside, zero on the boundary.
Sourcepub fn shells(&self, tol: &Tolerance) -> Vec<Shell>
pub fn shells(&self, tol: &Tolerance) -> Vec<Shell>
Group loops into outer loops with their holes. Loops are assumed not to cross (true for every operation output). An island inside a hole is its own shell.
Sourcepub fn offset(
&self,
distance: f64,
tol: &Tolerance,
) -> Result<Region, PlanarError>
pub fn offset( &self, distance: f64, tol: &Tolerance, ) -> Result<Region, PlanarError>
Offset by distance: positive grows the region, negative shrinks it.
pub fn union( &self, other: &Region, tol: &Tolerance, ) -> Result<Region, PlanarError>
pub fn difference( &self, other: &Region, tol: &Tolerance, ) -> Result<Region, PlanarError>
pub fn intersection( &self, other: &Region, tol: &Tolerance, ) -> Result<Region, PlanarError>
Sourcepub fn to_polylines(&self, tol: f64) -> Vec<Vec<Point2>>
pub fn to_polylines(&self, tol: f64) -> Vec<Vec<Point2>>
Chord loops at tol, for consumers that take polylines
(e.g. crate::model::Containment::boundary).