mirror of https://github.com/hannobraun/Fornjot
Simplify `PartialHalfEdge::with_back_vertex`
This commit is contained in:
parent
162aba8caa
commit
e2ddd014b1
|
@ -208,61 +208,56 @@ mod tests {
|
|||
let face =
|
||||
(half_edge, Color::default()).sweep([0., 0., 1.], &objects)?;
|
||||
|
||||
let expected_face = {
|
||||
let surface = objects.surfaces.xz_plane();
|
||||
let expected_face =
|
||||
{
|
||||
let surface = objects.surfaces.xz_plane();
|
||||
|
||||
let bottom = HalfEdge::partial()
|
||||
.update_as_line_segment_from_points(
|
||||
surface.clone(),
|
||||
[[0., 0.], [1., 0.]],
|
||||
)
|
||||
.build(&objects)?;
|
||||
let side_up = HalfEdge::partial()
|
||||
.with_surface(Some(surface.clone()))
|
||||
.with_back_vertex(Some(
|
||||
Vertex::partial().with_surface_form(
|
||||
let bottom = HalfEdge::partial()
|
||||
.update_as_line_segment_from_points(
|
||||
surface.clone(),
|
||||
[[0., 0.], [1., 0.]],
|
||||
)
|
||||
.build(&objects)?;
|
||||
let side_up = HalfEdge::partial()
|
||||
.with_surface(Some(surface.clone()))
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
bottom.front().surface_form().clone(),
|
||||
),
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
SurfaceVertex::partial().with_position(Some([1., 1.])),
|
||||
))
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?;
|
||||
let top = HalfEdge::partial()
|
||||
.with_surface(Some(surface.clone()))
|
||||
.with_back_vertex(Some(Vertex::partial().with_surface_form(
|
||||
SurfaceVertex::partial().with_position(Some([0., 1.])),
|
||||
)))
|
||||
.with_front_vertex(
|
||||
Vertex::partial().with_surface_form(
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
SurfaceVertex::partial().with_position(Some([1., 1.])),
|
||||
))
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?;
|
||||
let top = HalfEdge::partial()
|
||||
.with_surface(Some(surface.clone()))
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
SurfaceVertex::partial().with_position(Some([0., 1.])),
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
side_up.front().surface_form().clone(),
|
||||
),
|
||||
)
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.reverse(&objects)?;
|
||||
let side_down = HalfEdge::partial()
|
||||
.with_surface(Some(surface))
|
||||
.with_back_vertex(Some(
|
||||
Vertex::partial().with_surface_form(
|
||||
bottom.back().surface_form().clone(),
|
||||
),
|
||||
))
|
||||
.with_front_vertex(
|
||||
Vertex::partial()
|
||||
.with_surface_form(top.front().surface_form().clone()),
|
||||
)
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.reverse(&objects)?;
|
||||
))
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.reverse(&objects)?;
|
||||
let side_down =
|
||||
HalfEdge::partial()
|
||||
.with_surface(Some(surface))
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
bottom.back().surface_form().clone(),
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
top.front().surface_form().clone(),
|
||||
))
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.reverse(&objects)?;
|
||||
|
||||
let cycle = objects
|
||||
.cycles
|
||||
.insert(Cycle::new([bottom, side_up, top, side_down]))?;
|
||||
let cycle = objects
|
||||
.cycles
|
||||
.insert(Cycle::new([bottom, side_up, top, side_down]))?;
|
||||
|
||||
Face::builder(&objects).with_exterior(cycle).build()
|
||||
};
|
||||
Face::builder(&objects).with_exterior(cycle).build()
|
||||
};
|
||||
|
||||
assert_eq!(face, expected_face);
|
||||
Ok(())
|
||||
|
|
|
@ -118,7 +118,7 @@ impl PartialCycle {
|
|||
partial.with_surface_form(previous_vertex)
|
||||
});
|
||||
|
||||
half_edge.with_back_vertex(Some(back))
|
||||
half_edge.with_back_vertex(back)
|
||||
})
|
||||
.into_full(objects)?;
|
||||
|
||||
|
|
|
@ -82,12 +82,11 @@ impl PartialHalfEdge {
|
|||
/// Update the partial half-edge with the given back vertex
|
||||
pub fn with_back_vertex(
|
||||
mut self,
|
||||
vertex: Option<impl Into<MaybePartial<Vertex>>>,
|
||||
vertex: impl Into<MaybePartial<Vertex>>,
|
||||
) -> Self {
|
||||
if let Some(vertex) = vertex {
|
||||
let [from, _] = &mut self.vertices;
|
||||
*from = vertex.into();
|
||||
}
|
||||
let [from, _] = &mut self.vertices;
|
||||
*from = vertex.into();
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue