Struct cell_map::CellMap [−][src]
pub struct CellMap<L, T> where
L: Layer, { /* fields omitted */ }
Expand description
Provides a many-layer 2D map of cellular data.
Implementations
Creates a new map from the given data.
If data is the wrong shape or has the wrong number of layers this function will return an error.
Returns the number of cells in each direction of the map.
Returns the bounds of this map
Returns the parameters used to build this map.
Gets the nalgebra::Affine2<f64>
transformation between the map frame and the parent
frame.
Returns whether or not the given index is inside the map.
Get a reference to the value at the given layer and index. Returns None
if the index is
outside the bounds of the map.
Get a reference to the value at the given layer and index, without checking the bounds of the map.
Safety
This function will panic if index
is outside the map.
Get a mutable reference to the value at the given layer and index. Returns None
if the
index is outside the bounds of the map.
Get a mutable reference to the value at the given layer and index, without checking the bounds of the map.
Safety
This function will panic if index
is outside the map.
Returns the position in the parent frame of the centre of the given cell index.
Returns None
if the given index
is not inside the map.
Returns the position in the parent frame of the centre of the given cell index, without
checking that the index
is inside the map.
Safety
This method won’t panic if index
is outside the map, but it’s result can’t be guaranteed
to be a position in the map.
Get the cell index of the given poisition.
Returns None
if the given position
is not inside the map.
Get the cell index of the given poisition, without checking that the position is inside the map.
Safety
This function will not panic if position
is outside the map, but use of the result to
index into the map is not guaranteed to be safe. It is possible for this function to return
a negative index value, which would indicate that the cell is outside the map.
pub fn iter(&self) -> CellMapIter<'_, L, T, Many<L>, Cells>ⓘNotable traits for CellMapIter<'m, L, T, Single<L>, S>
impl<'m, L, T, S> Iterator for CellMapIter<'m, L, T, Single<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::Output;impl<'m, L, T, S> Iterator for CellMapIter<'m, L, T, Many<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::Output;
pub fn iter(&self) -> CellMapIter<'_, L, T, Many<L>, Cells>ⓘNotable traits for CellMapIter<'m, L, T, Single<L>, S>
impl<'m, L, T, S> Iterator for CellMapIter<'m, L, T, Single<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::Output;impl<'m, L, T, S> Iterator for CellMapIter<'m, L, T, Many<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::Output;
Returns an iterator over each cell in all layers of the map.
pub fn iter_mut(&mut self) -> CellMapIterMut<'_, L, T, Many<L>, Cells>ⓘNotable traits for CellMapIterMut<'m, L, T, Single<L>, S>
impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Single<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::OutputMut;impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Many<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::OutputMut;impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Map<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = (S::Output, S::OutputMut);
pub fn iter_mut(&mut self) -> CellMapIterMut<'_, L, T, Many<L>, Cells>ⓘNotable traits for CellMapIterMut<'m, L, T, Single<L>, S>
impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Single<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::OutputMut;impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Many<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = S::OutputMut;impl<'m, L, T, S> Iterator for CellMapIterMut<'m, L, T, Map<L>, S> where
L: Layer,
S: Slicer<'m, L, T>, type Item = (S::Output, S::OutputMut);
Returns a mutable iterator over each cell in all layers of the map.
pub fn window_iter(
&self,
semi_width: Vector2<usize>
) -> Result<CellMapIter<'_, L, T, Many<L>, Windows>, Error>
pub fn window_iter(
&self,
semi_width: Vector2<usize>
) -> Result<CellMapIter<'_, L, T, Many<L>, Windows>, Error>
Returns an iterator over windows of cells in the map.
The semi_width
is half the size of the window in the x and y axes, not including
the central cell. E.g. to have a window which is in total 5x5, the semi_window_size
needs
to be Vector2::new(2, 2)
.
pub fn window_iter_mut(
&mut self,
semi_width: Vector2<usize>
) -> Result<CellMapIterMut<'_, L, T, Many<L>, Windows>, Error>
pub fn window_iter_mut(
&mut self,
semi_width: Vector2<usize>
) -> Result<CellMapIterMut<'_, L, T, Many<L>, Windows>, Error>
Returns a mutable iterator over windows of cells in the map.
The semi_width
is half the size of the window in the x and y axes, not including
the central cell. E.g. to have a window which is in total 5x5, the semi_window_size
needs
to be Vector2::new(2, 2)
.
Returns an iterator over cells along the line joining start_position
and
end_position
, which are expressed as positions in the map’s parent frame.
Returns a mutable iterator over cells along the line joining start_position
and
end_position
, which are expressed as positions in the map’s parent frame.
Builds a new CellMapFile
from the given map, which can be serialised or deserialised
using serde.
Creates a new CellMap
from the given params, filling each cell with elem
.
Creates a new CellMap
from the given params, filling each cell with T::default()
.
Resizes the map into the new bounds, filling any newly added cells with T::default()
.
Any cells that are in the map currently, which would be outside the new map, are removed.
Merge other
into self, resizing self
so that other
will be fully included in the map.
Both maps should belong to the same parent frame, and other.cell_size <= self.cell_size
.
For other
s that have larger cells than self
you should implement your own merge functon
based on this one that could for example use 2D linear interpolation.
func
is responsible for actually merging data in both self
and other
into a single
new value in self
. The first argument is the value of the cell in self
, while the
second argument will be the values from cells in other
whose centres lie within the cell
in self
.
Trait Implementations
impl<'de, L, T> Deserialize<'de> for CellMap<L, T> where
L: Layer,
T: Clone + Serialize + DeserializeOwned,
L: Serialize + DeserializeOwned,
impl<'de, L, T> Deserialize<'de> for CellMap<L, T> where
L: Layer,
T: Clone + Serialize + DeserializeOwned,
L: Serialize + DeserializeOwned,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<L, T> Serialize for CellMap<L, T> where
L: Layer,
T: Clone + Serialize + DeserializeOwned,
L: Serialize + DeserializeOwned,
impl<L, T> Serialize for CellMap<L, T> where
L: Layer,
T: Clone + Serialize + DeserializeOwned,
L: Serialize + DeserializeOwned,
Auto Trait Implementations
impl<L, T> RefUnwindSafe for CellMap<L, T> where
L: RefUnwindSafe,
T: RefUnwindSafe,
impl<L, T> UnwindSafe for CellMap<L, T> where
L: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.