Struct bader::voxel_map::BlockingVoxelMap
source · pub struct BlockingVoxelMap {
pub grid: Grid,
/* private fields */
}
Expand description
A structure for building and processing the map between voxel and maxima.
Bader maxima are stored in the voxel_map whilst the contributing weights are
stored in the weight_map. The weight_map is only written to once by each
point and so once a value has been written it is safe to read by any thread.
To check it has been written to weight_get
monitors the state of corresponding
voxel_map value. Writing to the map is acheived by acquiring the lock, noting
the length of the weight_map, pushing the weight vector for voxel p to the
weight_map, droping the write lock and then storing the index of the inserted
vector using weight_store
.
Examples
use bader::voxel_map::BlockingVoxelMap;
for p in 0..1isize {
let voxel_map = BlockingVoxelMap::new(
[2, 5, 2],
[[2.0, 0.0, 0.0], [0.0, 5.0, 0.0], [0.0, 0.0, 2.0]],
[0.0, 0.0, 0.0],
);
let i = {
let mut weight = voxel_map.lock();
(*weight).push(Vec::with_capacity(0).into());
weight.len() - 1
};
voxel_map.weight_store(p, i)
}
Fields§
§grid: Grid
Implementations§
source§impl BlockingVoxelMap
impl BlockingVoxelMap
sourcepub fn new(
grid: [usize; 3],
lattice: [[f64; 3]; 3],
voxel_origin: [f64; 3]
) -> Self
pub fn new( grid: [usize; 3], lattice: [[f64; 3]; 3], voxel_origin: [f64; 3] ) -> Self
Initialises a BlockingVoxelMap
and the Grid
that will faciliate movemoment around the
map.
sourcepub fn weight_get(&self, i: isize) -> &[f64]
pub fn weight_get(&self, i: isize) -> &[f64]
Retrieves the state of the voxel, p. This will lock until p has been stored
in the VoxelMap and then return either a Voxel::Maxima
or Voxel::Weight
.
Calling this on a voxel, p, that is below the vacuum_tolerance will deadlock
as a voxel is considered stored once voxel_map[p] > -1.
sourcepub fn maxima_get(&self, p: isize) -> isize
pub fn maxima_get(&self, p: isize) -> isize
Atomic loading of voxel, p, from voxel_map blocks if maxima == -1
sourcepub fn maxima_check(&self, p: isize) -> Option<isize>
pub fn maxima_check(&self, p: isize) -> Option<isize>
Check if a maxima is stored
sourcepub fn maxima_store(&self, p: isize, maxima: isize)
pub fn maxima_store(&self, p: isize, maxima: isize)
Stores the maxima of voxel, p, in the voxel_map.
sourcepub fn weight_store(&self, p: isize, i: usize)
pub fn weight_store(&self, p: isize, i: usize)
Stores the index of p’s weight contributions in weight_map into the weight_index.