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