Skip to content

Commit

Permalink
Merge pull request #2327 from hannobraun/geometry
Browse files Browse the repository at this point in the history
Create curve geometry update API
  • Loading branch information
hannobraun authored Apr 29, 2024
2 parents af76177 + fae4dd4 commit 2ac0933
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
17 changes: 7 additions & 10 deletions crates/fj-core/src/operations/build/curve.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
geometry::{CurveGeom, SurfacePath},
operations::insert::Insert,
geometry::SurfacePath,
operations::{geometry::UpdateCurveGeometry, insert::Insert},
storage::Handle,
topology::{Curve, Surface},
Core,
Expand All @@ -18,14 +18,11 @@ pub trait BuildCurve {
surface: Handle<Surface>,
core: &mut Core,
) -> Handle<Curve> {
let curve = Curve::new().insert(core);

core.layers.geometry.define_curve(
curve.clone(),
CurveGeom::from_path_and_surface(path, surface),
);

curve
Curve::new().insert(core).make_path_on_surface(
path,
surface,
&mut core.layers.geometry,
)
}
}

Expand Down
33 changes: 33 additions & 0 deletions crates/fj-core/src/operations/geometry/curve.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use crate::{
geometry::{CurveGeom, Geometry, SurfacePath},
layers::Layer,
storage::Handle,
topology::{Curve, Surface},
};

/// Update the geometry of a [`Curve`]
pub trait UpdateCurveGeometry {
/// Define the geometry as a path on a surface
fn make_path_on_surface(
self,
path: SurfacePath,
surface: Handle<Surface>,
geometry: &mut Layer<Geometry>,
) -> Self;
}

impl UpdateCurveGeometry for Handle<Curve> {
fn make_path_on_surface(
self,
path: SurfacePath,
surface: Handle<Surface>,
geometry: &mut Layer<Geometry>,
) -> Self {
geometry.define_curve(
self.clone(),
CurveGeom::from_path_and_surface(path, surface),
);

self
}
}
3 changes: 2 additions & 1 deletion crates/fj-core/src/operations/geometry/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Operations to update the geometry of objects
mod curve;
mod half_edge;

pub use self::half_edge::UpdateHalfEdgeGeometry;
pub use self::{curve::UpdateCurveGeometry, half_edge::UpdateHalfEdgeGeometry};

0 comments on commit 2ac0933

Please sign in to comment.