[−][src]Module building_blocks_storage::transform_map
A lattice map that applies a transformation to another lattice map.
As an example use case, say you have a large lattice map that can store various types of voxels, and each type of voxel has some associated data. If that data is even moderately sized, it could take up a lot of space by storing copies at every point of the lattice.
Instead, you can store that data in a "palette" array, and store indices into that array as your voxel data.
use building_blocks_core::prelude::*; use building_blocks_storage::prelude::*; struct BigData([u8; 9001]); let extent = Extent3::from_min_and_shape(PointN([0; 3]), PointN([16; 3])); let mut index_map = Array3::fill(extent, 0u8); *index_map.get_mut(&PointN([0, 0, 1])) = 1; let palette = vec![BigData([1; 9001]), BigData([2; 9001])]; let lookup = |i: u8| palette[i as usize].0[0]; let big_data_map = TransformMap::new(&index_map, &lookup); assert_eq!(big_data_map.get(&PointN([0, 0, 0])), palette[0].0[0]); assert_eq!(big_data_map.get(&PointN([0, 0, 1])), palette[1].0[0]);
TransformMap
also gives us an efficient way of applying transforms to array data during a
copy:
let src = Array3::fill(extent, 0); let mut dst = ChunkMap3::new(PointN([4; 3]), 0, (), FastLz4 { level: 10 }); let tfm = TransformMap::new(&src, &|value: i32| value + 1); copy_extent(&extent, &tfm, &mut dst);
Structs
TransformChunkCopySrcIter | |
TransformMap | A lattice map that delegates look-ups to a different lattice map, then transforms the result
using some |
Type Definitions
TransformChunkCopySrc |