pub struct MonoPoly<T: GeoNum> { /* private fields */ }
Expand description

Monotone polygon

A monotone polygon is a polygon that can be decomposed into two monotone chains (along the X-axis). This implies any vertical line intersects the polygon at most twice (or not at all). These polygons support point-in-polygon queries in O(log n) time; use the Intersects<Coord> trait to query.

This structure cannot be directly constructed. Use crate::algorithm::monotone_subdivision algorithm to obtain a Vec<MonoPoly>. Consider using MonotonicPolygons instead if you are not interested in the individual monotone polygons.

Implementations§

source§

impl<T: GeoNum> MonoPoly<T>

source

pub fn top(&self) -> &LineString<T>

Get a reference to the mono poly’s top chain.

source

pub fn bot(&self) -> &LineString<T>

Get a reference to the mono poly’s bottom chain.

source

pub fn into_ls_pair(self) -> (LineString<T>, LineString<T>)

Convert self to (top, bottom) pair of chains.

source

pub fn bounding_segment(&self, x: T) -> Option<(Line<T>, Line<T>)>

Get the pair of segments in the chain that intersects the line parallel to the Y-axis at the given x-coordinate. Ties are broken by picking the segment with lower index, i.e. the segment closer to the start of the chains.

source

pub fn into_polygon(self) -> Polygon<T>

Convert self into a Polygon.

Trait Implementations§

source§

impl<T: GeoNum> BoundingRect<T> for MonoPoly<T>

§

type Output = Rect<T>

source§

fn bounding_rect(&self) -> Self::Output

Return the bounding rectangle of a geometry Read more
source§

impl<T: Clone + GeoNum> Clone for MonoPoly<T>

source§

fn clone(&self) -> MonoPoly<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: GeoNum> CoordinatePosition for MonoPoly<T>

§

type Scalar = T

source§

fn calculate_coordinate_position( &self, coord: &Coord<Self::Scalar>, is_inside: &mut bool, boundary_count: &mut usize )

source§

fn coordinate_position(&self, coord: &Coord<Self::Scalar>) -> CoordPos

source§

impl<T: GeoNum> Debug for MonoPoly<T>

source§

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

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

impl<T: GeoNum> Intersects<Coord<T>> for MonoPoly<T>

source§

fn intersects(&self, other: &Coord<T>) -> bool

source§

impl<T: PartialEq + GeoNum> PartialEq for MonoPoly<T>

source§

fn eq(&self, other: &MonoPoly<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: GeoNum> StructuralPartialEq for MonoPoly<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for MonoPoly<T>
where T: RefUnwindSafe,

§

impl<T> Send for MonoPoly<T>
where T: Send,

§

impl<T> Sync for MonoPoly<T>
where T: Sync,

§

impl<T> Unpin for MonoPoly<T>
where T: Unpin,

§

impl<T> UnwindSafe for MonoPoly<T>
where T: UnwindSafe,

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> 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,

§

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>,

§

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>,

§

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.
source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool