mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-12 03:06:59 +00:00
Add infrastructure for defining half-edge geometry
This commit is contained in:
parent
987ddd7e50
commit
03a7cd1ad0
@ -56,6 +56,14 @@ impl Geometry {
|
||||
self_
|
||||
}
|
||||
|
||||
pub(crate) fn define_half_edge_inner(
|
||||
&mut self,
|
||||
half_edge: Handle<HalfEdge>,
|
||||
geometry: HalfEdgeGeometry,
|
||||
) {
|
||||
self.half_edge.insert(half_edge, geometry);
|
||||
}
|
||||
|
||||
pub(crate) fn define_surface_inner(
|
||||
&mut self,
|
||||
surface: Handle<Surface>,
|
||||
|
@ -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<Geometry> {
|
||||
/// Define the geometry of the provided half-edge
|
||||
pub fn define_half_edge(
|
||||
&mut self,
|
||||
half_edge: Handle<HalfEdge>,
|
||||
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<Geometry> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Define the geometry of a half-edge
|
||||
pub struct DefineHalfEdge {
|
||||
half_edge: Handle<HalfEdge>,
|
||||
geometry: HalfEdgeGeometry,
|
||||
}
|
||||
|
||||
impl Command<Geometry> for DefineHalfEdge {
|
||||
type Result = ();
|
||||
type Event = Self;
|
||||
|
||||
fn decide(
|
||||
self,
|
||||
_: &Geometry,
|
||||
events: &mut Vec<Self::Event>,
|
||||
) -> Self::Result {
|
||||
events.push(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl Event<Geometry> 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<Surface>,
|
||||
|
Loading…
Reference in New Issue
Block a user