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

source

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.

source

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.

source

pub fn maxima_get(&self, p: isize) -> isize

Atomic loading of voxel, p, from voxel_map blocks if maxima == -1

source

pub fn maxima_check(&self, p: isize) -> Option<isize>

Check if a maxima is stored

source

pub fn maxima_store(&self, p: isize, maxima: isize)

Stores the maxima of voxel, p, in the voxel_map.

source

pub fn weight_store(&self, p: isize, i: usize)

Stores the index of p’s weight contributions in weight_map into the weight_index.

source

pub fn lock(&self) -> Lock<'_>

Locks the structure for write access unlock occurs when the returned Lock is dropped.

source

pub fn into_inner(self) -> (Vec<isize>, Vec<Box<[f64]>>, Grid)

Extract the voxel map data.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.