Simplify `PartialHalfEdge::with_vertices`

This commit is contained in:
Hanno Braun 2022-11-05 21:49:12 +01:00
parent 421e03efda
commit 5ccea9e80e
5 changed files with 13 additions and 16 deletions

View File

@ -37,7 +37,7 @@ impl TransformObject for PartialHalfEdge {
Ok(Self::default()
.with_curve(curve)
.with_vertices(Some(vertices))
.with_vertices(vertices)
.with_global_form(global_form))
}
}

View File

@ -82,7 +82,7 @@ impl CycleBuilder for PartialCycle {
half_edges.push(
HalfEdge::partial()
.with_curve(curve)
.with_vertices(Some([from, to])),
.with_vertices([from, to]),
);
continue;

View File

@ -79,7 +79,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
.with_surface_form(surface_vertex.clone())
});
Ok(self.with_curve(curve).with_vertices(Some([back, front])))
Ok(self.with_curve(curve).with_vertices([back, front]))
}
fn update_as_line_segment_from_points(
@ -96,7 +96,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
});
self.with_surface(surface)
.with_vertices(Some(vertices))
.with_vertices(vertices)
.update_as_line_segment()
}
@ -179,7 +179,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
})
};
self.with_curve(curve).with_vertices(Some([back, front]))
self.with_curve(curve).with_vertices([back, front])
}
}

View File

@ -112,10 +112,10 @@ impl<'a> ShellBuilder<'a> {
.with_surface(Some(surface.clone()));
HalfEdge::partial()
.with_vertices(Some([
.with_vertices([
Vertex::partial().with_surface_form(from),
Vertex::partial().with_surface_form(to),
]))
])
.update_as_line_segment()
.build(self.objects)
.unwrap()
@ -149,10 +149,10 @@ impl<'a> ShellBuilder<'a> {
HalfEdge::partial()
.with_curve(curve)
.with_vertices(Some([
.with_vertices([
Vertex::partial().with_surface_form(from),
Vertex::partial().with_surface_form(to),
]))
])
.update_as_line_segment()
.build(self.objects)
.unwrap()
@ -175,7 +175,7 @@ impl<'a> ShellBuilder<'a> {
let to = Vertex::partial().with_surface_form(to);
HalfEdge::partial()
.with_vertices(Some([from, to]))
.with_vertices([from, to])
.update_as_line_segment()
.build(self.objects)
.unwrap()
@ -251,7 +251,7 @@ impl<'a> ShellBuilder<'a> {
edges.push(
HalfEdge::partial()
.with_vertices(Some(vertices))
.with_vertices(vertices)
.with_global_form(Some(edge.global_form().clone()))
.update_as_line_segment()
.build(self.objects)

View File

@ -98,12 +98,9 @@ impl PartialHalfEdge {
/// Update the partial half-edge with the given vertices
pub fn with_vertices(
mut self,
vertices: Option<[impl Into<MaybePartial<Vertex>>; 2]>,
vertices: [impl Into<MaybePartial<Vertex>>; 2],
) -> Self {
let vertices = vertices.map(|vertices| vertices.map(Into::into));
if let Some([back, front]) = vertices {
self.vertices = [back, front];
}
self.vertices = vertices.map(Into::into);
self
}