honeycomb_core/cmap/dim3/sews/
one.rs1use crate::{
4 attributes::UnknownAttributeStorage,
5 cmap::{CMap3, DartIdType, NULL_DART_ID, NULL_VERTEX_ID, SewError},
6 geometry::CoordsFloat,
7 stm::{Transaction, TransactionClosureResult, try_or_coerce},
8};
9
10#[doc(hidden)]
11impl<T: CoordsFloat> CMap3<T> {
13 pub(crate) fn one_sew(
15 &self,
16 trans: &mut Transaction,
17 ld: DartIdType,
18 rd: DartIdType,
19 ) -> TransactionClosureResult<(), SewError> {
20 let b3ld = self.beta_transac::<3>(trans, ld)?;
24 let b2ld = self.beta_transac::<2>(trans, ld)?;
25 let vid_l_old = if b3ld != NULL_DART_ID {
26 self.vertex_id_transac(trans, b3ld)?
27 } else if b2ld != NULL_DART_ID {
28 self.vertex_id_transac(trans, b2ld)?
29 } else {
30 NULL_VERTEX_ID
31 };
32 let vid_r_old = self.vertex_id_transac(trans, rd)?;
33
34 try_or_coerce!(self.one_link(trans, ld, rd), SewError);
35
36 if vid_l_old != NULL_VERTEX_ID {
37 let new_vid = vid_r_old.min(vid_l_old); try_or_coerce!(
39 self.vertices.merge(trans, new_vid, vid_l_old, vid_r_old),
40 SewError
41 );
42 try_or_coerce!(
43 self.attributes
44 .merge_vertex_attributes(trans, new_vid, vid_l_old, vid_r_old),
45 SewError
46 );
47 }
48 Ok(())
49 }
50
51 pub(crate) fn one_unsew(
53 &self,
54 trans: &mut Transaction,
55 ld: DartIdType,
56 ) -> TransactionClosureResult<(), SewError> {
57 let rd = self.beta_transac::<1>(trans, ld)?;
58 let vid_old = self.vertex_id_transac(trans, rd)?;
59
60 try_or_coerce!(self.one_unlink(trans, ld), SewError);
61 let b2ld = self.beta_transac::<2>(trans, ld)?;
62 let b3ld = self.beta_transac::<3>(trans, ld)?;
63
64 let vid_l_new = self.vertex_id_transac(
65 trans,
66 if b2ld != NULL_DART_ID {
67 b2ld
68 } else if b3ld != NULL_DART_ID {
69 b3ld
70 } else {
71 return Ok(());
73 },
74 )?;
75 let vid_r_new = self.vertex_id_transac(trans, rd)?;
76 if vid_l_new != vid_r_new {
78 try_or_coerce!(
79 self.vertices.split(trans, vid_l_new, vid_r_new, vid_old),
80 SewError
81 );
82 try_or_coerce!(
83 self.attributes
84 .split_vertex_attributes(trans, vid_l_new, vid_r_new, vid_old),
85 SewError
86 );
87 }
88 Ok(())
89 }
90}