mirror of https://github.com/hannobraun/Fornjot
Refactor
This commit is contained in:
parent
d47e152651
commit
9a6c72caaf
|
@ -131,31 +131,30 @@ impl PartialCycle {
|
||||||
/// Update the partial cycle by closing it with a line segment
|
/// Update the partial cycle by closing it with a line segment
|
||||||
///
|
///
|
||||||
/// Builds a line segment from the last and first vertex, closing the cycle.
|
/// Builds a line segment from the last and first vertex, closing the cycle.
|
||||||
pub fn close_with_line_segment(mut self) -> Self {
|
pub fn close_with_line_segment(self) -> Self {
|
||||||
let first = self.half_edges().next();
|
let first = self.half_edges().next();
|
||||||
let last = self.half_edges().last();
|
let last = self.half_edges().last();
|
||||||
|
|
||||||
let vertices = [first, last]
|
let vertices = [first, last]
|
||||||
.map(|option| option.map(|half_edge| half_edge.vertices()));
|
.map(|option| option.map(|half_edge| half_edge.vertices()));
|
||||||
|
|
||||||
if let [Some([first, _]), Some([_, last])] = vertices {
|
let [Some([first, _]), Some([_, last])] = vertices else {
|
||||||
let vertices = [last, first].map(|vertex| {
|
return self;
|
||||||
vertex
|
};
|
||||||
.surface_form()
|
|
||||||
.position()
|
|
||||||
.expect("Need surface position to close cycle")
|
|
||||||
});
|
|
||||||
let surface = self.surface().expect("Need surface to close cycle");
|
|
||||||
|
|
||||||
self.half_edges.push(
|
let vertices = [last, first].map(|vertex| {
|
||||||
HalfEdge::partial()
|
vertex
|
||||||
.with_surface(Some(surface))
|
.surface_form()
|
||||||
.update_as_line_segment_from_points(vertices)
|
.position()
|
||||||
.into(),
|
.expect("Need surface position to close cycle")
|
||||||
);
|
});
|
||||||
}
|
let surface = self.surface().expect("Need surface to close cycle");
|
||||||
|
|
||||||
self
|
self.with_half_edges(Some(
|
||||||
|
HalfEdge::partial()
|
||||||
|
.with_surface(Some(surface))
|
||||||
|
.update_as_line_segment_from_points(vertices),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build a full [`Cycle`] from the partial cycle
|
/// Build a full [`Cycle`] from the partial cycle
|
||||||
|
|
Loading…
Reference in New Issue