Skip to content

Commit

Permalink
Make face sweeping code simpler and more flexible
Browse files Browse the repository at this point in the history
By always using the original face as the bottom, it should now be
relatively straight-forward to create shells whose faces are facing
inside. This is useful for creating cavities within a solid, for
example.
  • Loading branch information
hannobraun committed Nov 28, 2023
1 parent f56986b commit 1691928
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions crates/fj-core/src/operations/sweep/face.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use fj_math::{Scalar, Vector};
use fj_math::Vector;

use crate::{
algorithms::transform::TransformObject,
geometry::GlobalPath,
objects::{Face, Shell},
operations::{insert::Insert, reverse::Reverse},
operations::insert::Insert,
services::Services,
storage::Handle,
};
Expand Down Expand Up @@ -50,7 +49,7 @@ impl SweepFace for Handle<Face> {

let mut faces = Vec::new();

let bottom_face = bottom_face(self, path, services).insert(services);
let bottom_face = self.clone();
faces.push(bottom_face.clone());

let swept_region = bottom_face.region().sweep_region(
Expand Down Expand Up @@ -78,26 +77,3 @@ impl SweepFace for Handle<Face> {
Shell::new(faces)
}
}

fn bottom_face(face: &Face, path: Vector<3>, services: &mut Services) -> Face {
let is_negative_sweep = {
let u = match face.surface().geometry().u {
GlobalPath::Circle(_) => todo!(
"Sweeping from faces defined in rounded surfaces is not \
supported"
),
GlobalPath::Line(line) => line.direction(),
};
let v = face.surface().geometry().v;

let normal = u.cross(&v);

normal.dot(&path) < Scalar::ZERO
};

if is_negative_sweep {
face.clone()
} else {
face.reverse(services)
}
}

0 comments on commit 1691928

Please sign in to comment.