# 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 size of the cells in the map.

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.

Moves this map relative to a new position and rotation relative to the parent frame.

Note: This doesn’t move the data relative to the map origin, the indexes into the map remain the same, but the position of each cell in the map will change.

Returns whether or not the given index is inside the map.

Returns whether or not the given parent-relative position 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.

Set the given layer and index in the map to the given value. Returns an Error if the index was outside the map.

Set the given layer and index in the map to the given value, without checking if index is 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.

Returns an iterator over each cell in all layers of the map.

Returns a mutable iterator over each cell in all layers of the map.

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).

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.

Writes the map to the given path as a JSON file.

Loads a map stored in JSON format at the given path.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Performs the conversion.

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

## Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)