honeycomb_core/cmap/dim3/links/
three.rs1use crate::cmap::{CMap3, DartIdType, LinkError, NULL_DART_ID};
4use crate::geometry::CoordsFloat;
5use crate::stm::{Transaction, TransactionClosureResult, abort, atomically_with_err};
6
7impl<T: CoordsFloat> CMap3<T> {
9 pub(crate) fn three_link(
11 &self,
12 trans: &mut Transaction,
13 ld: DartIdType,
14 rd: DartIdType,
15 ) -> TransactionClosureResult<(), LinkError> {
16 self.betas.three_link_core(trans, ld, rd)?;
17 let (mut lside, mut rside) = (
18 self.beta_transac::<1>(trans, ld)?,
19 self.beta_transac::<0>(trans, rd)?,
20 );
21 while lside != ld && lside != NULL_DART_ID {
23 if rside == NULL_DART_ID {
24 abort(LinkError::AsymmetricalFaces(ld, rd))?;
26 }
27 self.betas.three_link_core(trans, lside, rside)?;
28 (lside, rside) = (
29 self.beta_transac::<1>(trans, lside)?,
30 self.beta_transac::<0>(trans, rside)?,
31 );
32 }
33 if lside == NULL_DART_ID {
37 if rside != NULL_DART_ID {
38 abort(LinkError::AsymmetricalFaces(ld, rd))?;
40 }
41 (lside, rside) = (
42 self.beta_transac::<0>(trans, ld)?,
43 self.beta_transac::<1>(trans, rd)?,
44 );
45 while lside != NULL_DART_ID {
46 if rside == NULL_DART_ID {
47 abort(LinkError::AsymmetricalFaces(ld, rd))?;
49 }
50 self.betas.three_link_core(trans, lside, rside)?;
51 (lside, rside) = (
52 self.beta_transac::<0>(trans, lside)?,
53 self.beta_transac::<1>(trans, rside)?,
54 );
55 }
56 }
57 Ok(())
63 }
64
65 pub(crate) fn force_three_link(&self, ld: DartIdType, rd: DartIdType) -> Result<(), LinkError> {
67 atomically_with_err(|trans| self.three_link(trans, ld, rd))
68 }
69}
70
71impl<T: CoordsFloat> CMap3<T> {
73 pub(crate) fn three_unlink(
75 &self,
76 trans: &mut Transaction,
77 ld: DartIdType,
78 ) -> TransactionClosureResult<(), LinkError> {
79 let rd = self.beta_transac::<3>(trans, ld)?;
80
81 self.betas.three_unlink_core(trans, ld)?;
82 let (mut lside, mut rside) = (
83 self.beta_transac::<1>(trans, ld)?,
84 self.beta_transac::<0>(trans, rd)?,
85 );
86 while lside != ld && lside != NULL_DART_ID {
88 if lside != self.beta_transac::<3>(trans, rside)? {
89 abort(LinkError::AsymmetricalFaces(ld, rd))?;
91 }
92 self.betas.three_unlink_core(trans, lside)?;
93 (lside, rside) = (
94 self.beta_transac::<1>(trans, lside)?,
95 self.beta_transac::<0>(trans, rside)?,
96 );
97 }
98 if lside == NULL_DART_ID {
102 if rside != NULL_DART_ID {
103 abort(LinkError::AsymmetricalFaces(ld, rd))?;
105 }
106 (lside, rside) = (
107 self.beta_transac::<0>(trans, ld)?,
108 self.beta_transac::<1>(trans, rd)?,
109 );
110 while lside != NULL_DART_ID {
111 if lside != self.beta_transac::<3>(trans, rside)? {
112 abort(LinkError::AsymmetricalFaces(ld, rd))?;
114 }
115 assert_eq!(lside, self.beta_transac::<3>(trans, rside)?); self.betas.three_unlink_core(trans, lside)?;
117 (lside, rside) = (
118 self.beta_transac::<0>(trans, lside)?,
119 self.beta_transac::<1>(trans, rside)?,
120 );
121 }
122 }
123 Ok(())
127 }
128
129 pub(crate) fn force_three_unlink(&self, ld: DartIdType) -> Result<(), LinkError> {
131 atomically_with_err(|trans| self.three_unlink(trans, ld))
132 }
133}