From c76901f8bbd0e81f9272b88d2ab764c5d033aa31 Mon Sep 17 00:00:00 2001 From: imrn99 <95699343+imrn99@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:59:17 +0100 Subject: [PATCH] fix tests & some impls --- honeycomb-core/src/cmap/dim3/basic_ops.rs | 12 ++++++++---- honeycomb-core/src/cmap/dim3/tests.rs | 13 ++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/honeycomb-core/src/cmap/dim3/basic_ops.rs b/honeycomb-core/src/cmap/dim3/basic_ops.rs index 628856c4..64aefcc5 100644 --- a/honeycomb-core/src/cmap/dim3/basic_ops.rs +++ b/honeycomb-core/src/cmap/dim3/basic_ops.rs @@ -247,7 +247,9 @@ impl CMap3 { ); queue.push_back(self.beta::<1>(b3)); queue.push_back(self.beta::<3>(b2)); + queue.push_back(self.beta::<1>(b2)); queue.push_back(self.beta::<3>(b0)); // ? + queue.push_back(self.beta::<2>(b0)); // ? } } @@ -284,7 +286,9 @@ impl CMap3 { ); queue.push_back(self.beta_transac::<1>(trans, b3)?); queue.push_back(self.beta_transac::<3>(trans, b2)?); + queue.push_back(self.beta_transac::<1>(trans, b2)?); queue.push_back(self.beta_transac::<3>(trans, b0)?); // ? + queue.push_back(self.beta_transac::<2>(trans, b0)?); // ? } } @@ -299,7 +303,7 @@ impl CMap3 { let mut marked = HashSet::new(); marked.insert(NULL_DART_ID); let (mut lb, mut rb) = (dart_id, self.beta::<3>(dart_id)); - let mut min = lb.min(rb); + let mut min = if rb == NULL_DART_ID { lb } else { lb.min(rb) }; let mut alt = true; while marked.insert(lb) || marked.insert(rb) { @@ -337,7 +341,7 @@ impl CMap3 { let mut marked = HashSet::new(); marked.insert(NULL_DART_ID); let (mut lb, mut rb) = (dart_id, self.beta_transac::<3>(trans, dart_id)?); - let mut min = lb.min(rb); + let mut min = if rb == NULL_DART_ID { lb } else { lb.min(rb) }; let mut alt = true; while marked.insert(lb) || marked.insert(rb) { @@ -373,7 +377,7 @@ impl CMap3 { marked.insert(NULL_DART_ID); let b3_dart_id = self.beta::<3>(dart_id); let (mut lb, mut rb) = (dart_id, b3_dart_id); - let mut min = lb.min(rb); + let mut min = if rb == NULL_DART_ID { lb } else { lb.min(rb) }; while marked.insert(lb) || marked.insert(rb) { (lb, rb) = (self.beta::<1>(lb), self.beta::<0>(rb)); @@ -419,7 +423,7 @@ impl CMap3 { marked.insert(NULL_DART_ID); let b3_dart_id = self.beta_transac::<3>(trans, dart_id)?; let (mut lb, mut rb) = (dart_id, b3_dart_id); - let mut min = lb.min(rb); + let mut min = if rb == NULL_DART_ID { lb } else { lb.min(rb) }; while marked.insert(lb) || marked.insert(rb) { (lb, rb) = ( diff --git a/honeycomb-core/src/cmap/dim3/tests.rs b/honeycomb-core/src/cmap/dim3/tests.rs index b11b8bd2..0498be5f 100644 --- a/honeycomb-core/src/cmap/dim3/tests.rs +++ b/honeycomb-core/src/cmap/dim3/tests.rs @@ -71,6 +71,13 @@ fn example_test() { map.force_link::<1>(22, 23); map.force_link::<1>(23, 24); map.force_link::<1>(24, 22); + // link triangles to get the tet + map.force_link::<2>(13, 16); + map.force_link::<2>(14, 19); + map.force_link::<2>(15, 22); + map.force_link::<2>(17, 24); + map.force_link::<2>(18, 20); + map.force_link::<2>(21, 23); map.force_write_vertex(13, (2.5, 1.5, 0.0)); map.force_write_vertex(14, (1.5, 2.0, 0.0)); @@ -112,7 +119,7 @@ fn example_test() { assert_eq!(faces.next(), Some(22)); assert_eq!(faces.next(), None); // there should be 9 edges total; quad base pyramid (8) + the base split diagonal (1) - assert_eq!(map.iter_edges().count(), 8); + assert_eq!(map.iter_edges().count(), 9); } // Adjust shared vertices (D) @@ -160,6 +167,9 @@ fn example_test() { map.remove_free_dart(10); map.remove_free_dart(11); map.remove_free_dart(12); + map.remove_free_dart(16); + map.remove_free_dart(17); + map.remove_free_dart(18); { let mut volumes = map.iter_volumes(); @@ -169,6 +179,7 @@ fn example_test() { assert_eq!(faces.next(), Some(1)); // base assert_eq!(faces.next(), Some(4)); // y- assert_eq!(faces.next(), Some(7)); // x- + assert_eq!(faces.next(), Some(13)); // base assert_eq!(faces.next(), Some(19)); // y+ assert_eq!(faces.next(), Some(22)); // x+ assert_eq!(faces.next(), None);