From c42cb8f3cf65eeef3d75f3e6bc137eb15e2f207c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Sep 2022 17:31:05 +0200 Subject: [PATCH] Test `Sweep` impl of `(HalfEdge, Color)` --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index e24b99f66..26c062fc3 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -165,3 +165,42 @@ impl Sweep for (HalfEdge, Color) { Face::new(surface, cycle).with_color(color) } } + +#[cfg(test)] +mod tests { + use fj_interop::mesh::Color; + use pretty_assertions::assert_eq; + + use crate::{ + algorithms::{reverse::Reverse, sweep::Sweep}, + objects::{Cycle, Face, HalfEdge, Surface}, + }; + + #[test] + fn sweep() { + let half_edge = HalfEdge::build(Surface::xy_plane()) + .line_segment_from_points([[0., 0.], [1., 0.]]); + + let face = (half_edge, Color::default()).sweep([0., 0., 1.]); + + let expected_face = { + let surface = Surface::xz_plane(); + let builder = HalfEdge::build(surface); + + let bottom = builder.line_segment_from_points([[0., 0.], [1., 0.]]); + let top = builder + .line_segment_from_points([[0., 1.], [1., 1.]]) + .reverse(); + let left = builder + .line_segment_from_points([[0., 0.], [0., 1.]]) + .reverse(); + let right = builder.line_segment_from_points([[1., 0.], [1., 1.]]); + + let cycle = Cycle::new(surface, [bottom, right, top, left]); + + Face::new(surface, cycle) + }; + + assert_eq!(face, expected_face); + } +}