Skip to content

Commit

Permalink
Merge pull request #2393 from hannobraun/surface
Browse files Browse the repository at this point in the history
Add `BuildSurface::from_geometry`
  • Loading branch information
hannobraun authored Jun 21, 2024
2 parents 0d25b1e + b66c814 commit d1eccc7
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions crates/fj-core/src/operations/build/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@ use crate::{
///
/// [module-level documentation]: super
pub trait BuildSurface {
/// Build a surface from the provided geometry
fn from_geometry(
surface_geom: SurfaceGeom,
core: &mut Core,
) -> Handle<Surface> {
let surface = Surface::new().insert(core);

core.layers
.geometry
.define_surface(surface.clone(), surface_geom);

surface
}

/// Build a surface from the provided `u` and `v`
fn from_uv(
u: impl Into<GlobalPath>,
v: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface> {
Self::from_geometry(
SurfaceGeom {
u: u.into(),
v: v.into(),
},
core,
)
}

/// Build a plane from the provided points
fn plane_from_points(
points: [impl Into<Point<3>>; 3],
Expand All @@ -36,25 +65,6 @@ pub trait BuildSurface {

(surface, points_surface)
}

/// Build a plane from the provided `u` and `v`
fn from_uv(
u: impl Into<GlobalPath>,
v: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface> {
let surface = Surface::new().insert(core);

core.layers.geometry.define_surface(
surface.clone(),
SurfaceGeom {
u: u.into(),
v: v.into(),
},
);

surface
}
}

impl BuildSurface for Surface {}

0 comments on commit d1eccc7

Please sign in to comment.