Skip to content

Commit

Permalink
Merge pull request #628 from gabsi26/correct_face_orientation
Browse files Browse the repository at this point in the history
Correct face orientation fixes #506
  • Loading branch information
hannobraun authored May 24, 2022
2 parents 40b049f + b9384ab commit d2dd108
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions crates/fj-kernel/src/algorithms/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ pub fn sweep_shape(
let translation = Transform::translation(path);

let (mut bottom, source_to_bottom) = source.clone_shape();
bottom
.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;

let (mut top, source_to_top) = source.clone_shape();

if path.dot(&Vector::from([0., 0., 1.])) >= fj_math::Scalar::from_f64(0.) {
bottom
.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;
} else {
top.update()
.update_all(|surface: &mut Surface| *surface = surface.reverse())
.validate()?;
}
transform_shape(&mut top, &translation);

let mut target = Shape::new();
Expand Down Expand Up @@ -118,11 +124,22 @@ pub fn sweep_shape(
let top_edge =
source_to_top.edges().get(&edge_source).unwrap().clone();

let surface =
let surface = if path.dot(&Vector::from([0., 0., 1.]))
>= fj_math::Scalar::from_f64(0.)
{
target.insert(Surface::SweptCurve(SweptCurve {
curve: bottom_edge.get().curve(),
path,
}))?;
}))?
} else {
target.insert(
Surface::SweptCurve(SweptCurve {
curve: bottom_edge.get().curve(),
path,
})
.reverse(), ////////////////////////////////////
)?
};

let cycle = target.merge(Cycle::new(vec![
bottom_edge,
Expand Down

0 comments on commit d2dd108

Please sign in to comment.