diff --git a/experiments/2024-12-09/src/model.rs b/experiments/2024-12-09/src/model.rs index 4cc4d09ae..738ee6bdb 100644 --- a/experiments/2024-12-09/src/model.rs +++ b/experiments/2024-12-09/src/model.rs @@ -14,7 +14,7 @@ pub fn model() -> AnyOp { let sketch = Sketch::from([[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [-0.5, 0.5]]); - let surface = stores.get().insert(Plane { + let surface = stores.surfaces.insert(Plane { origin: Point::from([0., 0., 0.5]), coords: Bivector { a: Vector::from([1., 0., 0.]), @@ -22,9 +22,11 @@ pub fn model() -> AnyOp { }, }); - sketch.to_face(surface, stores.get()) + sketch.to_face(surface, &mut stores.vertices) }; - let bottom = top.flip(stores.get()).translate([0., 0., -1.], &mut stores); + let bottom = top + .flip(&mut stores.surfaces) + .translate([0., 0., -1.], &mut stores); let [a, b, c, d] = bottom.vertices().collect_array().unwrap(); let [e, f, g, h] = top.vertices().collect_array().unwrap(); @@ -32,7 +34,7 @@ pub fn model() -> AnyOp { let [left, right, front, back] = [[a, e, h, d], [b, c, g, f], [a, b, f, e], [c, d, h, g]].map( |[q, r, s, t]| { - let surface = stores.get().insert(Plane::from_points( + let surface = stores.surfaces.insert(Plane::from_points( [q, r, s].map(|vertex| vertex.point), )); Face::new(surface, [q, r, s, t].map(|vertex| vertex.clone())) @@ -41,7 +43,7 @@ pub fn model() -> AnyOp { let solid = Solid::new( [bottom, top, left, right, front, back] - .map(|face| stores.get().insert(face)), + .map(|face| stores.faces.insert(face)), ); AnyOp::new(solid) diff --git a/experiments/2024-12-09/src/storage.rs b/experiments/2024-12-09/src/storage.rs index 44b86e6d3..786a699f2 100644 --- a/experiments/2024-12-09/src/storage.rs +++ b/experiments/2024-12-09/src/storage.rs @@ -1,22 +1,22 @@ use std::marker::PhantomData; -use anymap3::AnyMap; - -use crate::geometry::Handle; +use crate::{ + geometry::Handle, + math::Plane, + topology::{Face, Vertex}, +}; #[derive(Default)] pub struct Stores { - inner: AnyMap, + pub faces: Store, + pub surfaces: Store, + pub vertices: Store, } impl Stores { pub fn new() -> Self { Self::default() } - - pub fn get(&mut self) -> &mut Store { - self.inner.entry::>().or_default() - } } pub struct Store { diff --git a/experiments/2024-12-09/src/topology/face.rs b/experiments/2024-12-09/src/topology/face.rs index 239c181df..2d0c9485f 100644 --- a/experiments/2024-12-09/src/topology/face.rs +++ b/experiments/2024-12-09/src/topology/face.rs @@ -44,11 +44,11 @@ impl Face { let offset = offset.into(); Self { - surface: stores.get().insert(self.surface.translate(offset)), + surface: stores.surfaces.insert(self.surface.translate(offset)), vertices: self .vertices .iter() - .map(|vertex| stores.get().insert(vertex.translate(offset))) + .map(|vertex| stores.vertices.insert(vertex.translate(offset))) .collect(), } }