Struct Array3d

Source
pub struct Array3d<T> {
    pub shape: V3i,
    pub data: Vec<T>,
}

Fields§

§shape: V3i§data: Vec<T>

Implementations§

Source§

impl<T: Clone> Array3d<T>

Source

pub fn from_fn<F: Fn(V3i) -> T>(s: V3i, f: F) -> Array3d<T>

Source

pub fn from_fn_doubled<F: Fn(V3i) -> (T, T)>( sz: V3i, axis: i32, f: F, ) -> Array3d<T>

production from a function with expansion, todo - make this more general e.g.‘production in blocks’ the motivation is to share state across the production of a block of adjacent cells

Source

pub fn fill_val(size: V3i, val: T) -> Array3d<T>

Source

pub fn len(&self) -> usize

Source

pub fn linear_index(&self, pos: V3i) -> usize

Source

pub fn size(&self) -> V3i

Source

pub fn map_xyz<B: Clone, F: Fn(V3i, &T) -> B>(&self, f: F) -> Array3d<B>

produce a new array3d by applying a function to every element

Source

pub fn map_strided_region<B: Clone, F: Fn(V3i, &T) -> B>( &self, range: Range<V3i>, stride: V3i, f: F, ) -> Array3d<B>

Source

pub fn for_each<F: Fn(V3i, &mut T)>(&mut self, f: F)

internal iteration with inplace mutation

Source

pub fn map_xy<F, B>(&self, a_func: F) -> Array2d<B>
where F: Fn(&Self, i32, i32) -> B, B: Clone,

Source

pub fn map_xz<F, B>(&self, a_func: F) -> Array2d<B>
where F: Fn(&Self, i32, i32) -> B, B: Clone,

Source

pub fn map_yz<F, B>(&self, a_func: F) -> Array2d<B>
where F: Fn(&Self, i32, i32) -> B, B: Clone,

Source

pub fn reshape(&mut self, s: V3i)

Source

pub fn fold_z<B, F>(&self, init_val: B, f: F) -> Array2d<B>
where B: Clone, F: Fn(V3i, B, &T) -> B,

Source

pub fn fold_x<B: Clone, F: Fn(V3i, B, &T) -> B>( &self, input: B, f: F, ) -> Array2d<B>

produce a 2d array by folding along the X axis

Source

pub fn fold_xyz<A, B, C, FOLDX, FOLDY, FOLDZ>( &self, (input_x, fx): (A, FOLDX), (input_y, fy): (B, FOLDY), (input_z, fz): (C, FOLDZ), ) -> A
where A: Clone, B: Clone, C: Clone, FOLDZ: Fn(V3i, C, &T) -> C, FOLDY: Fn(i32, i32, B, &C) -> B, FOLDX: Fn(i32, A, &B) -> A,

fold values along x,y,z in turn without intermediate storage

Source

pub fn fold_zyx<A, B, C, FOLDX, FOLDY, FOLDZ>( &self, (input_x, fx): (A, FOLDX), (input_y, fy): (B, FOLDY), (input_z, fz): (C, FOLDZ), ) -> C
where A: Clone, B: Clone, C: Clone, FOLDZ: Fn(i32, C, &B) -> C, FOLDY: Fn(i32, i32, B, &A) -> B, FOLDX: Fn(V3i, A, &T) -> A,

fold values along z,y,x in turn without intermediate storage

Source

pub fn fold<B, F>(&self, input: B, f: F) -> B
where F: Fn(V3i, B, &T) -> B, B: Clone,

fold the whole array to produce a single value

Source

pub fn fold_tiles<B, F>(&self, tilesize: V3i, input: B, f: &F) -> Array3d<B>
where F: Fn(V3i, B, &T) -> B, B: Clone,

produce tiles by applying a function to every subtile output size is divided by tilesize must be exact multiple.

Source

pub fn fold_region<B, F>(&self, r: Range<V3i>, input: B, f: &F) -> B
where F: Fn(V3i, B, &T) -> B, B: Clone,

subroutine for ‘fold tiles’, see context closure is borrowed for multiple invocation by caller

Source

pub fn get_indexed(&self, pos: V3i) -> (V3i, &T)

Source

pub fn region_all(&self) -> Range<V3i>

Source

pub fn map_region_strided<F, B>( &self, region: Range<V3i>, stride: V3i, f: F, ) -> Array3d<B>
where F: Fn(V3i, &T) -> B, B: Clone,

Source

pub fn map_strided<F, B>(&self, stride: V3i, f: F) -> Array3d<B>
where F: Fn(V3i, &T) -> B, B: Clone,

Source

pub fn map_region<F, B>(&self, region: Range<V3i>, f: F) -> Array3d<B>
where F: Fn(V3i, &T) -> B, B: Clone,

Source

pub fn convolute_neighbours<F, B>(&self, f: F) -> Array3d<B>
where F: Fn(&T, Vec3<Neighbours<&T>>) -> B, B: Clone,

X form of convolution
XOX passing each cell and it’s X immiediate neighbours on each axis

Source

pub fn index_wrap(&self, pos: V3i) -> &T

Source

pub fn get_wrap(&self, pos: V3i) -> &T

Source

pub fn get_ofs_wrap(&self, pos: V3i, dx: i32, dy: i32, dz: i32) -> &T

Source

pub fn convolute_neighbours_wrap<F, B>(&self, f: F) -> Array3d<B>
where F: Fn(&T, Vec3<Neighbours<&T>>) -> B, B: Clone,

Source

pub fn convolute_2x2x2_wrap<F, B>(&self, f: F) -> Array3d<B>
where F: Fn(V3i, [[[&T; 2]; 2]; 2]) -> B, B: Clone,

special case of convolution for 2x2 cells, e.g. for marching cubes

Source

pub fn fold_half<F, B>(&self, fold_fn: F) -> Array3d<B>
where F: Fn(V3i, [[[&T; 2]; 2]; 2]) -> B, B: Clone,

take 2x2x2 blocks, fold to produce new values

Trait Implementations§

Source§

impl<T: Clone> Index<Vec3<i32>> for Array3d<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, pos: V3i) -> &T

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

impl<T: Clone> IndexMut<Vec3<i32>> for Array3d<T>

Source§

fn index_mut(&mut self, pos: V3i) -> &mut T

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

Auto Trait Implementations§

§

impl<T> Freeze for Array3d<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Array3d<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<A, B> PairWith<B> for A

Source§

fn pair_with<'a, 'b>(&'a self, b: &'b B) -> (&'a A, &'b B)

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.