diff --git a/crates/fj-core/src/geometry/geometry.rs b/crates/fj-core/src/geometry/geometry.rs index c5869c40b..27e09c8d9 100644 --- a/crates/fj-core/src/geometry/geometry.rs +++ b/crates/fj-core/src/geometry/geometry.rs @@ -56,6 +56,14 @@ impl Geometry { self_ } + pub(crate) fn define_half_edge_inner( + &mut self, + half_edge: Handle, + geometry: HalfEdgeGeometry, + ) { + self.half_edge.insert(half_edge, geometry); + } + pub(crate) fn define_surface_inner( &mut self, surface: Handle, diff --git a/crates/fj-core/src/layers/geometry.rs b/crates/fj-core/src/layers/geometry.rs index 9564af1f6..16596c35f 100644 --- a/crates/fj-core/src/layers/geometry.rs +++ b/crates/fj-core/src/layers/geometry.rs @@ -1,14 +1,30 @@ //! Layer infrastructure for [`Geometry`] use crate::{ - geometry::{Geometry, SurfaceGeometry}, - objects::Surface, + geometry::{Geometry, HalfEdgeGeometry, SurfaceGeometry}, + objects::{HalfEdge, Surface}, storage::Handle, }; use super::{Command, Event, Layer}; impl Layer { + /// Define the geometry of the provided half-edge + pub fn define_half_edge( + &mut self, + half_edge: Handle, + geometry: HalfEdgeGeometry, + ) { + let mut events = Vec::new(); + self.process( + DefineHalfEdge { + half_edge, + geometry, + }, + &mut events, + ); + } + /// Define the geometry of the provided surface pub fn define_surface( &mut self, @@ -20,6 +36,31 @@ impl Layer { } } +/// Define the geometry of a half-edge +pub struct DefineHalfEdge { + half_edge: Handle, + geometry: HalfEdgeGeometry, +} + +impl Command for DefineHalfEdge { + type Result = (); + type Event = Self; + + fn decide( + self, + _: &Geometry, + events: &mut Vec, + ) -> Self::Result { + events.push(self); + } +} + +impl Event for DefineHalfEdge { + fn evolve(&self, state: &mut Geometry) { + state.define_half_edge_inner(self.half_edge.clone(), self.geometry); + } +} + /// Define the geometry of a surface pub struct DefineSurface { surface: Handle,