Remove redundant validation check

We already check that all half-edges are connected by identical surface
vertices. Checking the surface on top of that is redundant.
This commit is contained in:
Hanno Braun 2022-11-08 11:55:20 +01:00
parent 7671353c50
commit 2dd2c916eb
1 changed files with 8 additions and 14 deletions

View File

@ -24,20 +24,14 @@ impl Cycle {
pub fn new(half_edges: impl IntoIterator<Item = Handle<HalfEdge>>) -> Self { pub fn new(half_edges: impl IntoIterator<Item = Handle<HalfEdge>>) -> Self {
let half_edges = half_edges.into_iter().collect::<Vec<_>>(); let half_edges = half_edges.into_iter().collect::<Vec<_>>();
let surface = match half_edges.first() { // This is not a validation check, and thus not part of the validation
Some(half_edge) => half_edge.surface().clone(), // infrastructure. The property being checked here is inherent to the
None => panic!("Cycle must contain at least one half-edge"), // validity of a `Cycle`, as methods of `Cycle` might assume that there
}; // is at least one edge.
assert!(
// Verify, that the curves of all edges are defined in the correct !half_edges.is_empty(),
// surface. "Cycle must contain at least one half-edge"
for edge in &half_edges { );
assert_eq!(
surface.id(),
edge.curve().surface().id(),
"Edges in cycle not defined in same surface"
);
}
if half_edges.len() != 1 { if half_edges.len() != 1 {
// Verify that all edges connect. // Verify that all edges connect.