Skip to content

Commit

Permalink
add sews module in dim3
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Jan 2, 2025
1 parent f010274 commit 67a51d1
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 3 deletions.
5 changes: 2 additions & 3 deletions honeycomb-core/src/cmap/dim3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
66 changes: 66 additions & 0 deletions honeycomb-core/src/cmap/dim3/sews/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
mod one;
mod three;
mod two;

use stm::Transaction;

use crate::{
cmap::{CMap3, CMapResult, DartIdType},
prelude::CoordsFloat,
};

/// Sew operations
impl<T: CoordsFloat> CMap3<T> {
pub fn sew<const I: u8>(
&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<const I: u8>(&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<const I: u8>(&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<const I: u8>(&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!(),
}
}
}
39 changes: 39 additions & 0 deletions honeycomb-core/src/cmap/dim3/sews/one.rs
Original file line number Diff line number Diff line change
@@ -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<T: CoordsFloat> CMap3<T> {
/// 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<T: CoordsFloat> CMap3<T> {
/// 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!()
}
}
39 changes: 39 additions & 0 deletions honeycomb-core/src/cmap/dim3/sews/three.rs
Original file line number Diff line number Diff line change
@@ -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<T: CoordsFloat> CMap3<T> {
/// 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<T: CoordsFloat> CMap3<T> {
/// 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!()
}
}
43 changes: 43 additions & 0 deletions honeycomb-core/src/cmap/dim3/sews/two.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! 2D sew implementations
use stm::{atomically, Transaction};

use crate::{
cmap::{CMap3, CMapResult, DartIdType},
prelude::CoordsFloat,
};

/// 2-sews
impl<T: CoordsFloat> CMap3<T> {
/// 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<T: CoordsFloat> CMap3<T> {
/// 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!()
}
}

0 comments on commit 67a51d1

Please sign in to comment.