Skip to main content

honeycomb_core/cmap/dim3/
utils.rs

1//! [`CMap3`] utilities implementations
2//!
3//! This module contains utility code for the [`CMap3`] structure.
4
5use crate::cmap::{CMap3, DartIdType};
6use crate::geometry::CoordsFloat;
7
8use super::CMAP3_BETA;
9
10/// **Utilities**
11impl<T: CoordsFloat> CMap3<T> {
12    /// Set the value of the specified beta function of a dart.
13    ///
14    /// # Arguments
15    ///
16    /// - `const I: u8` -- Beta function to edit.
17    /// - `dart_id: DartIdType` -- ID of the dart of interest.
18    /// - `val: DartIdType` -- New value of *β<sub>`I`</sub>(`dart_id`)*.
19    pub fn set_beta<const I: u8>(&self, dart_id: DartIdType, val: DartIdType) {
20        self.betas[(I, dart_id)].write_atomic(val);
21    }
22
23    /// Set the values of the beta functions of a dart.
24    ///
25    /// # Arguments
26    ///
27    /// - `dart_id: DartIdType` -- ID of the dart of interest.
28    /// - `betas: [DartIdType; 4]` -- New values of
29    ///   *[β<sub>0</sub>(dart), β<sub>1</sub>(dart), β<sub>2</sub>(dart), β<sub>3</sub>(dart)]*
30    ///
31    pub fn set_betas(&self, dart_id: DartIdType, [b0, b1, b2, b3]: [DartIdType; CMAP3_BETA]) {
32        // store separately to use non-mutable methods
33        self.betas[(0, dart_id)].write_atomic(b0);
34        self.betas[(1, dart_id)].write_atomic(b1);
35        self.betas[(2, dart_id)].write_atomic(b2);
36        self.betas[(3, dart_id)].write_atomic(b3);
37    }
38}