Skip to content

Commit

Permalink
Test Sweep impl of (HalfEdge, Color)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Sep 12, 2022
1 parent 7184d77 commit c42cb8f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit c42cb8f

Please sign in to comment.