mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-10 12:58:28 +00:00
Add infrastructure for defining new surface geom
This commit is contained in:
parent
a07353a8c7
commit
95111e6593
@ -19,6 +19,7 @@ pub struct Geometry {
|
||||
curve: BTreeMap<Handle<Curve>, CurveGeom>,
|
||||
curve2: BTreeMap<Handle<Curve>, CurveGeom2>,
|
||||
surface: BTreeMap<Handle<Surface>, SweptCurve>,
|
||||
surface2: BTreeMap<Handle<Surface>, SurfaceGeom>,
|
||||
vertex: BTreeMap<Handle<Vertex>, VertexGeom>,
|
||||
|
||||
space_2d: Handle<Surface>,
|
||||
@ -35,6 +36,7 @@ impl Geometry {
|
||||
curve: BTreeMap::new(),
|
||||
curve2: BTreeMap::new(),
|
||||
surface: BTreeMap::new(),
|
||||
surface2: BTreeMap::new(),
|
||||
vertex: BTreeMap::new(),
|
||||
|
||||
space_2d: topology.surfaces.space_2d(),
|
||||
@ -66,6 +68,34 @@ impl Geometry {
|
||||
},
|
||||
);
|
||||
|
||||
self_.define_surface_inner_2(
|
||||
self_.xy_plane.clone(),
|
||||
SurfaceGeom {
|
||||
geometry: Arc::new(SweptCurve {
|
||||
u: Path::x_axis(),
|
||||
v: Vector::unit_y(),
|
||||
}),
|
||||
},
|
||||
);
|
||||
self_.define_surface_inner_2(
|
||||
self_.xz_plane.clone(),
|
||||
SurfaceGeom {
|
||||
geometry: Arc::new(SweptCurve {
|
||||
u: Path::x_axis(),
|
||||
v: Vector::unit_z(),
|
||||
}),
|
||||
},
|
||||
);
|
||||
self_.define_surface_inner_2(
|
||||
self_.yz_plane.clone(),
|
||||
SurfaceGeom {
|
||||
geometry: Arc::new(SweptCurve {
|
||||
u: Path::y_axis(),
|
||||
v: Vector::unit_z(),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
self_
|
||||
}
|
||||
|
||||
@ -110,6 +140,26 @@ impl Geometry {
|
||||
self.surface.insert(surface, geometry);
|
||||
}
|
||||
|
||||
pub(crate) fn define_surface_inner_2(
|
||||
&mut self,
|
||||
surface: Handle<Surface>,
|
||||
geometry: SurfaceGeom,
|
||||
) {
|
||||
if surface == self.space_2d {
|
||||
panic!("Attempting to define geometry for 2D space");
|
||||
}
|
||||
|
||||
if self.surface2.contains_key(&surface)
|
||||
&& (surface == self.xy_plane
|
||||
|| surface == self.xz_plane
|
||||
|| surface == self.yz_plane)
|
||||
{
|
||||
panic!("Attempting to redefine basis plane.");
|
||||
}
|
||||
|
||||
self.surface2.insert(surface, geometry);
|
||||
}
|
||||
|
||||
pub(crate) fn define_vertex_inner(
|
||||
&mut self,
|
||||
vertex: Handle<Vertex>,
|
||||
|
@ -3,7 +3,7 @@
|
||||
use crate::{
|
||||
geometry::{
|
||||
surfaces::SweptCurve, CurveGeom2, Geometry, LocalCurveGeom,
|
||||
LocalVertexGeom,
|
||||
LocalVertexGeom, SurfaceGeom,
|
||||
},
|
||||
storage::Handle,
|
||||
topology::{Curve, Surface, Vertex},
|
||||
@ -62,6 +62,28 @@ impl Layer<Geometry> {
|
||||
self.process(DefineSurface { surface, geometry }, &mut events);
|
||||
}
|
||||
|
||||
/// # Define the geometry of the provided surface
|
||||
///
|
||||
/// ## Panics
|
||||
///
|
||||
/// Panics, if the surface is a special pre-defined plane, like the basis
|
||||
/// planes (xy-, xz-, or yz-plane).
|
||||
///
|
||||
/// ## 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_surface_2(
|
||||
&mut self,
|
||||
surface: Handle<Surface>,
|
||||
geometry: SurfaceGeom,
|
||||
) {
|
||||
let mut events = Vec::new();
|
||||
self.process(DefineSurface2 { surface, geometry }, &mut events);
|
||||
}
|
||||
|
||||
/// Define the geometry of the provided vertex
|
||||
pub fn define_vertex(
|
||||
&mut self,
|
||||
@ -170,6 +192,34 @@ impl Event<Geometry> for DefineSurface {
|
||||
}
|
||||
}
|
||||
|
||||
/// Define the geometry of a surface
|
||||
pub struct DefineSurface2 {
|
||||
surface: Handle<Surface>,
|
||||
geometry: SurfaceGeom,
|
||||
}
|
||||
|
||||
impl Command<Geometry> for DefineSurface2 {
|
||||
type Result = ();
|
||||
type Event = Self;
|
||||
|
||||
fn decide(
|
||||
self,
|
||||
_: &Geometry,
|
||||
events: &mut Vec<Self::Event>,
|
||||
) -> Self::Result {
|
||||
events.push(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl Event<Geometry> for DefineSurface2 {
|
||||
fn evolve(&self, state: &mut Geometry) {
|
||||
state.define_surface_inner_2(
|
||||
self.surface.clone(),
|
||||
self.geometry.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Define the geometry of a curve
|
||||
pub struct DefineVertex {
|
||||
vertex: Handle<Vertex>,
|
||||
|
Loading…
Reference in New Issue
Block a user