honeycomb_core/cmap/dim2/
utils.rs

1//! [`CMap2`] utilities implementations
2
3use crate::cmap::{CMap2, DartIdType};
4use crate::geometry::CoordsFloat;
5use crate::stm::atomically;
6
7use super::CMAP2_BETA;
8
9/// **Utilities**
10impl<T: CoordsFloat> CMap2<T> {
11    /// Set the value of β<sub>`I`</sub>(`dart_id`) to `new_val`.
12    pub fn set_beta<const I: u8>(&self, dart_id: DartIdType, new_val: DartIdType) {
13        atomically(|trans| self.betas[(I, dart_id)].write(trans, new_val));
14    }
15
16    /// Set the values of the beta functions of a dart.
17    ///
18    /// # Arguments
19    ///
20    /// - `dart_id: DartIdentifier` -- ID of the dart of interest.
21    /// - `betas: [DartIdentifier; 3]` -- Value of the images as
22    ///   [ β<sub>`0`</sub>(`dart_id`), β<sub>`1`</sub>(`dart_id`), β<sub>`2`</sub>(`dart_id`) ]
23    pub fn set_betas(&self, dart_id: DartIdType, [b0, b1, b2]: [DartIdType; CMAP2_BETA]) {
24        // store separately to use non-mutable methods
25        atomically(|trans| {
26            self.betas[(0, dart_id)].write(trans, b0)?;
27            self.betas[(1, dart_id)].write(trans, b1)?;
28            self.betas[(2, dart_id)].write(trans, b2)?;
29            Ok(())
30        });
31    }
32}