Skip to content

Commit

Permalink
fix: removed buggy contains function
Browse files Browse the repository at this point in the history
  • Loading branch information
acgetchell committed Nov 9, 2024
1 parent 1df83f3 commit c71b046
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
19 changes: 1 addition & 18 deletions src/delaunay_core/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,23 +489,6 @@ where

facets
}

/// The function `contains_facet` checks if a given facet is contained in the cell.
///
/// # Arguments:
///
/// * `facet`: The facet to check.
///
/// # Returns:
///
/// Returns `true` if the given facet is contained in the cell, and `false` otherwise.
pub fn contains_facet(&self, facet: &Facet<T, U, V, D>) -> bool {
self.vertices.iter().all(|v| facet.vertices().contains(v))

// Alternative implementation using HashSet, requires Eq on T in Vertex<T, U, D>
// let vertex_set: HashSet<&Vertex<T, U, D>> = self.vertices.iter().collect();
// facet.vertices().iter().all(|v| vertex_set.contains(v))
}
}

/// Equality of cells is based on equality of sorted vector of vertices.
Expand Down Expand Up @@ -1101,7 +1084,7 @@ mod tests {

assert_eq!(facets.len(), 4);
for facet in facets.iter() {
assert!(cell.facets().contains(facet))
assert!(cell.facets().contains(facet));
}

// Human readable output for cargo test -- --nocapture
Expand Down
8 changes: 4 additions & 4 deletions src/delaunay_core/triangulation_data_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ where
/// # Returns:
///
/// A [Result] containing the updated [Tds] with the Delaunay triangulation, or an error message.
pub fn bowyer_watson(&mut self) -> Result<Self, anyhow::Error>
pub fn bowyer_watson(mut self) -> Result<Self, anyhow::Error>
where
OPoint<T, Const<D>>: From<[f64; D]>,
[f64; D]: Default + DeserializeOwned + Serialize + Sized,
Expand Down Expand Up @@ -282,7 +282,7 @@ where
if !bad_cells.iter().any(|&id| {
self.cells
.get(&id)
.map_or(false, |c| c.contains_facet(&facet))
.map_or(false, |c| c.facets().contains(&facet))
}) {
boundary_facets.push(facet);
}
Expand All @@ -306,7 +306,7 @@ where
self.cells
.retain(|_, cell| !cell.contains_vertex_of(&supercell));

Ok(self.clone())
Ok(self)
}

fn assign_neighbors(&mut self, _cells: Vec<Cell<T, U, V, D>>) -> Result<(), &'static str> {
Expand Down Expand Up @@ -460,7 +460,7 @@ mod tests {
Point::new([0.0, 1.0, 0.0]),
Point::new([0.0, 0.0, 1.0]),
];
let mut tds: Tds<f64, usize, usize, 3> = Tds::new(points);
let tds: Tds<f64, usize, usize, 3> = Tds::new(points);
let result = tds.bowyer_watson().unwrap_or_else(|err| {
panic!("Error creating triangulation: {:?}", err);
});
Expand Down

0 comments on commit c71b046

Please sign in to comment.