Prepare to support curved sweeps

This commit is contained in:
Hanno Braun 2025-04-30 11:58:36 +02:00
parent 84d4ca3e23
commit 34918962d4
2 changed files with 10 additions and 6 deletions

View File

@ -1,8 +1,9 @@
use fj_interop::{Tolerance, TriMesh};
use fj_math::Vector;
use fj_viewer::Viewer;
use crate::{
geometry::{Sketch, SweptCurve, ToTriMesh},
geometry::{Line, Sketch, SweptCurve, ToTriMesh},
handle::Handle,
operations::sweep::SweepExt,
topology::surface::Surface,
@ -43,7 +44,9 @@ pub fn model(viewer: &Viewer) -> TriMesh {
viewer.display(top.to_tri_mesh(tolerance));
let solid = top.sweep([0., 0., -2.]);
let solid = top.sweep(Line {
direction: Vector::from([0., 0., -2.]),
});
viewer.display(solid.to_tri_mesh(tolerance));
solid.to_tri_mesh(tolerance)

View File

@ -1,6 +1,5 @@
use fj_math::Vector;
use crate::{
geometry::Line,
handle::Handle,
topology::{face::Face, solid::Solid},
};
@ -19,11 +18,13 @@ pub trait SweepExt {
///
/// It should be seen as more of a placeholder for a real implementation of
/// this operation.
fn sweep(self, path: impl Into<Vector<3>>) -> Solid;
fn sweep(self, path: Line) -> Solid;
}
impl SweepExt for Handle<Face> {
fn sweep(self, path: impl Into<Vector<3>>) -> Solid {
fn sweep(self, path: Line) -> Solid {
let path = path.direction;
let bottom = self;
let top = Handle::new(bottom.flip().translate(path));