Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BuildSurface::from_geometry #2393

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}