From 67a51d18676269ed0a7bb187c09180a48f11f507 Mon Sep 17 00:00:00 2001 From: imrn99 <95699343+imrn99@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:32:26 +0100 Subject: [PATCH] add sews module in dim3 --- honeycomb-core/src/cmap/dim3/mod.rs | 5 +- honeycomb-core/src/cmap/dim3/sews/mod.rs | 66 ++++++++++++++++++++++ honeycomb-core/src/cmap/dim3/sews/one.rs | 39 +++++++++++++ honeycomb-core/src/cmap/dim3/sews/three.rs | 39 +++++++++++++ honeycomb-core/src/cmap/dim3/sews/two.rs | 43 ++++++++++++++ 5 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 honeycomb-core/src/cmap/dim3/sews/mod.rs create mode 100644 honeycomb-core/src/cmap/dim3/sews/one.rs create mode 100644 honeycomb-core/src/cmap/dim3/sews/three.rs create mode 100644 honeycomb-core/src/cmap/dim3/sews/two.rs diff --git a/honeycomb-core/src/cmap/dim3/mod.rs b/honeycomb-core/src/cmap/dim3/mod.rs index b10dc559..ff89c4fd 100644 --- a/honeycomb-core/src/cmap/dim3/mod.rs +++ b/honeycomb-core/src/cmap/dim3/mod.rs @@ -9,13 +9,12 @@ pub mod basic_ops; pub mod embed; pub mod links; pub mod orbits; -// pub mod sews; +pub mod sews; pub mod structure; +pub mod utils; // pub mod io; -pub mod utils; - /// Number of beta functions defined for [`CMap3`]. const CMAP3_BETA: usize = 4; diff --git a/honeycomb-core/src/cmap/dim3/sews/mod.rs b/honeycomb-core/src/cmap/dim3/sews/mod.rs new file mode 100644 index 00000000..6e7eb3e5 --- /dev/null +++ b/honeycomb-core/src/cmap/dim3/sews/mod.rs @@ -0,0 +1,66 @@ +mod one; +mod three; +mod two; + +use stm::Transaction; + +use crate::{ + cmap::{CMap3, CMapResult, DartIdType}, + prelude::CoordsFloat, +}; + +/// Sew operations +impl CMap3 { + pub fn sew( + &self, + trans: &mut Transaction, + ld: DartIdType, + rd: DartIdType, + ) -> CMapResult<()> { + // these assertions + match on a const are optimized away + assert!(I < 4); + assert_ne!(I, 0); + match I { + 1 => self.one_sew(trans, ld, rd), + 2 => self.two_sew(trans, ld, rd), + 3 => self.three_sew(trans, ld, rd), + _ => unreachable!(), + } + } + + pub fn unsew(&self, trans: &mut Transaction, ld: DartIdType) -> CMapResult<()> { + // these assertions + match on a const are optimized away + assert!(I < 4); + assert_ne!(I, 0); + match I { + 1 => self.one_unsew(trans, ld), + 2 => self.one_unsew(trans, ld), + 3 => self.one_unsew(trans, ld), + _ => unreachable!(), + } + } + + pub fn force_sew(&self, ld: DartIdType, rd: DartIdType) { + // these assertions + match on a const are optimized away + assert!(I < 4); + assert_ne!(I, 0); + match I { + 1 => self.force_one_sew(ld, rd), + 2 => self.force_two_sew(ld, rd), + 3 => self.force_three_sew(ld, rd), + _ => unreachable!(), + } + } + + pub fn force_unsew(&self, ld: DartIdType) { + // these assertions + match on a const are optimized away + assert!(I < 4); + assert_ne!(I, 0); + match I { + 1 => self.force_one_unsew(ld), + 2 => self.force_two_unsew(ld), + 3 => self.force_three_unsew(ld), + _ => unreachable!(), + } + } +} diff --git a/honeycomb-core/src/cmap/dim3/sews/one.rs b/honeycomb-core/src/cmap/dim3/sews/one.rs new file mode 100644 index 00000000..b0eae8ee --- /dev/null +++ b/honeycomb-core/src/cmap/dim3/sews/one.rs @@ -0,0 +1,39 @@ +//! 1D sew implementations + +use stm::{atomically, Transaction}; + +use crate::{ + cmap::{CMap3, CMapResult, DartIdType, NULL_DART_ID}, + prelude::CoordsFloat, +}; + +/// 1-sews +impl CMap3 { + /// 1-sew transactional operation. + pub(crate) fn one_sew( + &self, + trans: &mut Transaction, + ld: DartIdType, + rd: DartIdType, + ) -> CMapResult<()> { + todo!() + } + + /// 1-sew operation. + pub(crate) fn force_one_sew(&self, ld: DartIdType, rd: DartIdType) { + todo!() + } +} + +/// 1-unsews +impl CMap3 { + /// 1-unsew transactional operation. + pub(crate) fn one_unsew(&self, trans: &mut Transaction, ld: DartIdType) -> CMapResult<()> { + todo!() + } + + /// 1-unsew operation. + pub(crate) fn force_one_unsew(&self, ld: DartIdType) { + todo!() + } +} diff --git a/honeycomb-core/src/cmap/dim3/sews/three.rs b/honeycomb-core/src/cmap/dim3/sews/three.rs new file mode 100644 index 00000000..4421aba0 --- /dev/null +++ b/honeycomb-core/src/cmap/dim3/sews/three.rs @@ -0,0 +1,39 @@ +//! 3D sew implementations + +use stm::{atomically, Transaction}; + +use crate::{ + cmap::{CMap3, CMapResult, DartIdType, NULL_DART_ID}, + prelude::CoordsFloat, +}; + +/// 3-sews +impl CMap3 { + /// 3-sew operation. + pub(crate) fn three_sew( + &self, + trans: &mut Transaction, + ld: DartIdType, + rd: DartIdType, + ) -> CMapResult<()> { + todo!() + } + + /// 3-sew operation. + pub(crate) fn force_three_sew(&self, ld: DartIdType, rd: DartIdType) { + todo!() + } +} + +/// 3-unsews +impl CMap3 { + /// 3-unsew operation. + pub(crate) fn three_unsew(&self, trans: &mut Transaction, ld: DartIdType) -> CMapResult<()> { + todo!() + } + + /// 3-unsew operation. + pub(crate) fn force_three_unsew(&self, ld: DartIdType) { + todo!() + } +} diff --git a/honeycomb-core/src/cmap/dim3/sews/two.rs b/honeycomb-core/src/cmap/dim3/sews/two.rs new file mode 100644 index 00000000..81893d55 --- /dev/null +++ b/honeycomb-core/src/cmap/dim3/sews/two.rs @@ -0,0 +1,43 @@ +//! 2D sew implementations + +use stm::{atomically, Transaction}; + +use crate::{ + cmap::{CMap3, CMapResult, DartIdType}, + prelude::CoordsFloat, +}; + +/// 2-sews +impl CMap3 { + /// 2-sew transactional operation. + pub(crate) fn two_sew( + &self, + trans: &mut Transaction, + lhs_dart_id: DartIdType, + rhs_dart_id: DartIdType, + ) -> CMapResult<()> { + todo!() + } + + /// 2-sew operation. + pub(crate) fn force_two_sew(&self, lhs_dart_id: DartIdType, rhs_dart_id: DartIdType) { + todo!() + } +} + +/// 2-unsews +impl CMap3 { + /// 2-unsew transactional operation. + pub(crate) fn two_unsew( + &self, + trans: &mut Transaction, + lhs_dart_id: DartIdType, + ) -> CMapResult<()> { + todo!() + } + + /// 2-unsew operation. + pub(crate) fn force_two_unsew(&self, lhs_dart_id: DartIdType) { + todo!() + } +}