Skip to main content

Region2

Struct Region2 

Source
pub struct Region2 { /* private fields */ }
Expand description

An owned planar region with explicit material and hole contour bins.

The bins are signed by role, not by trusting contour orientation. A point’s depth is the number of containing material contours minus the number of containing hole contours. Positive depth is inside; zero or negative depth is outside. This intentionally supports nested islands by putting the inner island contour back in the material bin.

Implementations§

Source§

impl Region2

Source

pub fn project_to_finite_region( &self, options: &FiniteProjectionOptions, ) -> CurveResult<FiniteRegionProjection2>

Projects this region to finite material/hole rings for IO and display.

Region roles are preserved, but the returned rings are boundary products only. Exact point classification and area should continue to use Region2::classify_point and Region2::filled_area.

Source

pub fn project_to_finite_profiles( &self, options: &FiniteProjectionOptions, policy: &CurvePolicy, ) -> CurveResult<Classification<Vec<FiniteRegionProfile2>>>

Projects exact material/hole ownership profiles to finite rings.

Ownership is classified before projection with Region2::contour_profiles, so this method does not recover holes from sampled centroids or winding heuristics. The returned rings are still finite API-boundary products; exact topology remains in the region. This follows Yap’s exact-object/API-boundary split and the boundary-first point-in-polygon structure surveyed by Hormann and Agathos, both cited on Region2::contour_profiles.

Source§

impl Region2

Source

pub fn prepare_point_classifier( &self, policy: &CurvePolicy, ) -> PreparedRegionView2<'_>

Builds a prepared borrowed view for repeated point classification.

Source

pub fn prepare_topology_queries( &self, policy: &CurvePolicy, ) -> PreparedRegionView2<'_>

Builds a prepared borrowed view for repeated point and event queries.

Source§

impl Region2

Source

pub const fn empty() -> Self

Constructs an empty region.

Source

pub const fn new( material_contours: Vec<Contour2>, hole_contours: Vec<Contour2>, ) -> Self

Constructs a region from explicit material and hole contour bins.

Source

pub const fn from_material_contours(material_contours: Vec<Contour2>) -> Self

Constructs a region from material contours only.

Source

pub fn material_contours(&self) -> &[Contour2]

Returns material contours.

Source

pub fn hole_contours(&self) -> &[Contour2]

Returns hole contours.

Source

pub fn is_empty(&self) -> bool

Returns true when the region has no contours.

Source

pub fn as_view(&self) -> RegionView2<'_>

Returns a borrowed view over this region.

Source

pub fn classify_point( &self, point: &Point2, policy: &CurvePolicy, ) -> Classification<RegionPointLocation>

Classifies a point against this region.

Source

pub fn signed_depth( &self, point: &Point2, policy: &CurvePolicy, ) -> Classification<i32>

Returns signed containment depth for non-boundary points.

Source

pub fn filled_area( &self, policy: &CurvePolicy, ) -> CurveResult<Classification<Option<Real>>>

Returns the exact filled area implied by the region’s material/hole roles.

Unlike Contour2::signed_area, this ignores contour orientation: material bins add the absolute contour area and hole bins subtract it. This keeps the region role model explicit and avoids treating winding as hidden topology state. The area is accumulated from exact Green’s-theorem contour facts and branches only after the sign of each contour contribution is certified, following Yap, “Towards Exact Geometric Computation,” Computational Geometry 7(1-2), 1997 (https://doi.org/10.1016/0925-7721(95)00040-2).

Returns Decided(None) when a contour contains a segment whose exact area contribution is not implemented by the current object model.

Source

pub fn contour_profiles( &self, policy: &CurvePolicy, ) -> Classification<Vec<RegionContourProfile<'_>>>

Groups material contours with the hole contours they contain.

Ownership is decided with exact contour point classification before any finite export projection exists. This follows the boundary-first point-in-polygon structure surveyed by Hormann and Agathos, “The Point in Polygon Problem for Arbitrary Polygons,” Computational Geometry 20(3), 2001 (https://doi.org/10.1016/S0925-7721(01)00012-8), and the exact-object/API-boundary split advocated by Yap, “Towards Exact Geometric Computation,” Computational Geometry 7(1-2), 1997 (https://doi.org/10.1016/0925-7721(95)00040-2).

Source

pub fn intersect_region( &self, other: &Self, policy: &CurvePolicy, ) -> CurveResult<RegionIntersectionSet>

Collects normalized topology events against another region.

Source§

impl Region2

Source

pub fn boolean_boundary_loops( &self, other: &Self, op: BooleanOp, policy: &CurvePolicy, ) -> CurveResult<Classification<BooleanBoundaryLoopSet>>

Computes closed boolean boundary loops against another owned region.

This is a convenience wrapper over RegionView2::boolean_boundary_loops.

Source

pub fn boolean_boundary_contours( &self, other: &Self, op: BooleanOp, fill_rule: FillRule, policy: &CurvePolicy, ) -> CurveResult<Classification<Vec<Contour2>>>

Computes checked boolean boundary contours against another owned region.

The returned contours are closed result boundaries. They are not yet assigned to material or hole bins; that role assignment belongs to the later nesting pass.

Source

pub fn boolean_region( &self, other: &Self, op: BooleanOp, fill_rule: FillRule, policy: &CurvePolicy, ) -> CurveResult<Classification<Self>>

Computes a role-assigned boolean region against another owned region.

The result is available only when the current boundary pipeline can produce closed contours and the nesting pass can classify those contours without boundary ambiguity.

Source§

impl Region2

Source

pub fn from_boundary_contours( contours: Vec<Contour2>, policy: &CurvePolicy, ) -> CurveResult<Classification<Self>>

Builds a region by nesting closed boundary contours into material/hole bins.

Contours at even containment depth become material. Contours at odd depth become holes. This matches the even-odd nesting interpretation commonly used after boolean traversal has produced disjoint closed output loops.

Source§

impl Region2

Source

pub fn transform_similarity(&self, transform: &Similarity2) -> CurveResult<Self>

Applies a certified planar similarity transform to every material and hole contour.

Trait Implementations§

Source§

impl Clone for Region2

Source§

fn clone(&self) -> Region2

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Region2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Region2

Source§

fn default() -> Region2

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Region2

Source§

fn eq(&self, other: &Region2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Region2

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.