pub struct Array3d<T> {
pub shape: V3i,
pub data: Vec<T>,
}
Fields§
§shape: V3i
§data: Vec<T>
Implementations§
Source§impl<T: Clone> Array3d<T>
impl<T: Clone> Array3d<T>
pub fn from_fn<F: Fn(V3i) -> T>(s: V3i, f: F) -> Array3d<T>
Sourcepub fn from_fn_doubled<F: Fn(V3i) -> (T, T)>(
sz: V3i,
axis: i32,
f: F,
) -> Array3d<T>
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
pub fn fill_val(size: V3i, val: T) -> Array3d<T>
pub fn len(&self) -> usize
pub fn linear_index(&self, pos: V3i) -> usize
pub fn size(&self) -> V3i
Sourcepub fn map_xyz<B: Clone, F: Fn(V3i, &T) -> B>(&self, f: F) -> Array3d<B>
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
pub fn map_strided_region<B: Clone, F: Fn(V3i, &T) -> B>( &self, range: Range<V3i>, stride: V3i, f: F, ) -> Array3d<B>
pub fn map_xy<F, B>(&self, a_func: F) -> Array2d<B>
pub fn map_xz<F, B>(&self, a_func: F) -> Array2d<B>
pub fn map_yz<F, B>(&self, a_func: F) -> Array2d<B>
pub fn reshape(&mut self, s: V3i)
pub fn fold_z<B, F>(&self, init_val: B, f: F) -> Array2d<B>
Sourcepub fn fold_x<B: Clone, F: Fn(V3i, B, &T) -> B>(
&self,
input: B,
f: F,
) -> Array2d<B>
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
Sourcepub 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
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
fold values along x,y,z in turn without intermediate storage
Sourcepub 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
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
fold values along z,y,x in turn without intermediate storage
Sourcepub fn fold_tiles<B, F>(&self, tilesize: V3i, input: B, f: &F) -> Array3d<B>
pub fn fold_tiles<B, F>(&self, tilesize: V3i, input: B, f: &F) -> Array3d<B>
produce tiles by applying a function to every subtile output size is divided by tilesize must be exact multiple.
Sourcepub fn fold_region<B, F>(&self, r: Range<V3i>, input: B, f: &F) -> B
pub fn fold_region<B, F>(&self, r: Range<V3i>, input: B, f: &F) -> B
subroutine for ‘fold tiles’, see context closure is borrowed for multiple invocation by caller
pub fn get_indexed(&self, pos: V3i) -> (V3i, &T)
pub fn region_all(&self) -> Range<V3i>
pub fn map_region_strided<F, B>( &self, region: Range<V3i>, stride: V3i, f: F, ) -> Array3d<B>
pub fn map_strided<F, B>(&self, stride: V3i, f: F) -> Array3d<B>
pub fn map_region<F, B>(&self, region: Range<V3i>, f: F) -> Array3d<B>
Sourcepub fn convolute_neighbours<F, B>(&self, f: F) -> Array3d<B>
pub fn convolute_neighbours<F, B>(&self, f: F) -> Array3d<B>
X form of convolution
XOX passing each cell and it’s
X immiediate neighbours on each axis
pub fn index_wrap(&self, pos: V3i) -> &T
pub fn get_wrap(&self, pos: V3i) -> &T
pub fn get_ofs_wrap(&self, pos: V3i, dx: i32, dy: i32, dz: i32) -> &T
pub fn convolute_neighbours_wrap<F, B>(&self, f: F) -> Array3d<B>
Sourcepub fn convolute_2x2x2_wrap<F, B>(&self, f: F) -> Array3d<B>
pub fn convolute_2x2x2_wrap<F, B>(&self, f: F) -> Array3d<B>
special case of convolution for 2x2 cells, e.g. for marching cubes