Skip to content

Commit

Permalink
fix tests & some impls
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 committed Jan 9, 2025
1 parent 0236822 commit c76901f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 8 additions & 4 deletions honeycomb-core/src/cmap/dim3/basic_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ impl<T: CoordsFloat> CMap3<T> {
);
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)); // ?
}
}

Expand Down Expand Up @@ -284,7 +286,9 @@ impl<T: CoordsFloat> CMap3<T> {
);
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)?); // ?
}
}

Expand All @@ -299,7 +303,7 @@ impl<T: CoordsFloat> CMap3<T> {
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) {
Expand Down Expand Up @@ -337,7 +341,7 @@ impl<T: CoordsFloat> CMap3<T> {
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) {
Expand Down Expand Up @@ -373,7 +377,7 @@ impl<T: CoordsFloat> CMap3<T> {
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));
Expand Down Expand Up @@ -419,7 +423,7 @@ impl<T: CoordsFloat> CMap3<T> {
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) = (
Expand Down
13 changes: 12 additions & 1 deletion honeycomb-core/src/cmap/dim3/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit c76901f

Please sign in to comment.