Skip to content

Commit

Permalink
Add infrastructure for defining new curve geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Sep 16, 2024
1 parent 9088ebb commit d32cdd2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/fj-core/src/geometry/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ impl Geometry {
.insert(surface, geometry);
}

pub(crate) fn define_curve_inner_2(
&mut self,
curve: Handle<Curve>,
geometry: CurveGeom2,
) {
self.curve2.insert(curve, geometry);
}

pub(crate) fn define_surface_inner(
&mut self,
surface: Handle<Surface>,
Expand Down
55 changes: 54 additions & 1 deletion crates/fj-core/src/layers/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Layer infrastructure for [`Geometry`]
use crate::{
geometry::{Geometry, LocalCurveGeom, LocalVertexGeom, SurfaceGeom},
geometry::{
CurveGeom2, Geometry, LocalCurveGeom, LocalVertexGeom, SurfaceGeom,
},
storage::Handle,
topology::{Curve, Surface, Vertex},
};
Expand All @@ -27,6 +29,23 @@ impl Layer<Geometry> {
);
}

/// # Define the geometry of the provided curve
///
/// ## Implementation Note
///
/// There currently is an ongoing transition to a new geometry system. This
/// method defines new-style geometry. Its name is temporary, while the
/// method defining the old-style geometry is still taking up the more
/// concise name.
pub fn define_curve_2(
&mut self,
curve: Handle<Curve>,
geometry: CurveGeom2,
) {
let mut events = Vec::new();
self.process(DefineCurve2 { curve, geometry }, &mut events);
}

/// # Define the geometry of the provided surface
///
/// ## Panics
Expand Down Expand Up @@ -91,6 +110,40 @@ impl Event<Geometry> for DefineCurve {
}
}

/// # Define the geometry of a curve
///
/// ## Implementation Note
///
/// There currently is an ongoing transition to a new geometry representation.
/// This type is involved in defining the new-style geometry. Its name is
/// temporary, while the respective type that defines old-style geometry is
/// still taking up the more compact name.
pub struct DefineCurve2 {
curve: Handle<Curve>,
geometry: CurveGeom2,
}

impl Command<Geometry> for DefineCurve2 {
type Result = ();
type Event = Self;

fn decide(
self,
_: &Geometry,
events: &mut Vec<Self::Event>,
) -> Self::Result {
events.push(self);
}
}

impl Event<Geometry> for DefineCurve2 {
fn evolve(&self, state: &mut Geometry) {
// TASK: This can't work, as designed. I need to clone the geometry
// here, but I can't just clone a `Box`.
state.define_curve_inner_2(self.curve.clone(), self.geometry.clone());
}
}

/// Define the geometry of a surface
pub struct DefineSurface {
surface: Handle<Surface>,
Expand Down

0 comments on commit d32cdd2

Please sign in to comment.