pub struct PlanarMask { /* private fields */ }Expand description
A dense row-major boolean mask aligned with a field’s cell grid.
Implementations§
Source§impl PlanarMask
impl PlanarMask
Sourcepub fn empty(width: usize, height: usize) -> Result<Self, LayeredFieldError>
pub fn empty(width: usize, height: usize) -> Result<Self, LayeredFieldError>
Construct an all-false mask.
Sourcepub fn from_field(field: &LayeredField, channel: FieldChannel) -> Self
pub fn from_field(field: &LayeredField, channel: FieldChannel) -> Self
Derive a mask from one channel of a field.
Sourcepub const fn dimensions(&self) -> (usize, usize)
pub const fn dimensions(&self) -> (usize, usize)
Mask dimensions.
Sourcepub fn get(&self, x: usize, y: usize) -> Option<bool>
pub fn get(&self, x: usize, y: usize) -> Option<bool>
Read a cell, or None when outside the mask.
Sourcepub fn set(
&mut self,
x: usize,
y: usize,
value: bool,
) -> Result<(), LayeredFieldError>
pub fn set( &mut self, x: usize, y: usize, value: bool, ) -> Result<(), LayeredFieldError>
Write a cell.
Sourcepub fn intersect(&self, other: &Self) -> Result<Self, LayeredFieldError>
pub fn intersect(&self, other: &Self) -> Result<Self, LayeredFieldError>
Set-intersection with an identically sized mask.
Sourcepub fn dilate(
&self,
config: &FieldConfig,
radius: Scalar,
) -> Result<Self, LayeredFieldError>
pub fn dilate( &self, config: &FieldConfig, radius: Scalar, ) -> Result<Self, LayeredFieldError>
Metric dilation by radius in local units.
The radius is converted to a cell count by ceiling division on the configured cell size, so the result never under-covers the requested distance. A zero radius is the identity.
Sourcepub fn erode(
&self,
config: &FieldConfig,
radius: Scalar,
) -> Result<Self, LayeredFieldError>
pub fn erode( &self, config: &FieldConfig, radius: Scalar, ) -> Result<Self, LayeredFieldError>
Metric erosion by radius in local units.
Sourcepub fn connected_components(&self) -> ComponentLabels
pub fn connected_components(&self) -> ComponentLabels
Label 4-connected components of set cells.
Labels are assigned in row-major discovery order, so the labelling is stable across runs.
Trait Implementations§
Source§impl Clone for PlanarMask
impl Clone for PlanarMask
Source§fn clone(&self) -> PlanarMask
fn clone(&self) -> PlanarMask
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PlanarMask
impl Debug for PlanarMask
Source§impl PartialEq for PlanarMask
impl PartialEq for PlanarMask
impl Eq for PlanarMask
impl StructuralPartialEq for PlanarMask
Auto Trait Implementations§
impl Freeze for PlanarMask
impl RefUnwindSafe for PlanarMask
impl Send for PlanarMask
impl Sync for PlanarMask
impl Unpin for PlanarMask
impl UnwindSafe for PlanarMask
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