From c7d8a3dbf4488ab089cc4d5ed64b34eac055d377 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 3 Feb 2022 16:25:57 +0100 Subject: [PATCH] WIP --- src/kernel/geometry/cache.rs | 18 +++++++++++++++ src/kernel/geometry/mod.rs | 1 + src/kernel/geometry/points.rs | 43 +++++++++++++++++++++++++++++++++++ src/kernel/shapes/sketch.rs | 12 ++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/kernel/geometry/points.rs diff --git a/src/kernel/geometry/cache.rs b/src/kernel/geometry/cache.rs index b8f94a538..58e00604d 100644 --- a/src/kernel/geometry/cache.rs +++ b/src/kernel/geometry/cache.rs @@ -35,6 +35,11 @@ impl Cache { } } + // TASK: Make this generic over the value inserted. The easiest way to do + // that is to add a `Value` enum. + // TASK: Rename to signify that this is the first insertion of the value, + // not the subsequent addition of another representation of the same + // value, using the same handle. `create`? /// Insert an object into the cache /// /// Returns a handle that can henceforth be used to refer to that object. @@ -47,8 +52,21 @@ impl Cache { handle } + + // TASK: Add method that allows for adding another representation to an + // existing value by providing its handle. `add`? `append`? + + // TASK: Document. + // TASK: Un-suppress warning. + #[allow(unused)] + pub fn get(&self, handle: Handle) -> T { + // TASK: Implement. + todo!() + } } +// TASK: Making `Handle` strongly typed is too ambitious for a first stab at the +// problem. Just remove the `T`. Maybe we can add it back later. /// An handle that refers to a geometric object /// /// Instances of this struct are constructed when an object is added to diff --git a/src/kernel/geometry/mod.rs b/src/kernel/geometry/mod.rs index a21a9d37f..7bc6a90df 100644 --- a/src/kernel/geometry/mod.rs +++ b/src/kernel/geometry/mod.rs @@ -1,5 +1,6 @@ pub mod cache; pub mod curves; +pub mod points; pub mod surfaces; pub use self::{ diff --git a/src/kernel/geometry/points.rs b/src/kernel/geometry/points.rs new file mode 100644 index 000000000..cb2f06f19 --- /dev/null +++ b/src/kernel/geometry/points.rs @@ -0,0 +1,43 @@ +// TASK: Un-suppress warning. +#![allow(unused)] + +use super::Handle; + +// TASK: Document. +pub struct Point1D { + // TASK: Document. + pub s: f64, + + // TASK: Document. + pub handle: Handle, +} + +// TASK: Document. +pub struct Point2D { + // TASK: Document. + pub u: f64, + + // TASK: Document. + pub v: f64, + + // TASK: Document. + pub handle: Handle, +} + +// TASK: Document. +pub struct Point3D { + // TASK: Document. + pub x: f64, + + // TASK: Document. + pub y: f64, + + // TASK: Document. + pub z: f64, + + // TASK: Document. + pub handle: Handle, +} + +// TASK: Document. +pub struct Point; diff --git a/src/kernel/shapes/sketch.rs b/src/kernel/shapes/sketch.rs index 6efc5f102..72ac136ae 100644 --- a/src/kernel/shapes/sketch.rs +++ b/src/kernel/shapes/sketch.rs @@ -54,8 +54,13 @@ impl Shape for fj::Sketch { let a = window[0]; let b = window[1]; + // TASK: Insert `a` and `b` into cache. + // TASK: Provides handles to `Line` here instead of the points + // themselves. let line = Curve::Line(Line { a, b }); + // TASK: Add these as alternative representations of previously + // created 3D points. let a = cache.insert(point![0.]); let b = cache.insert(point![1.]); @@ -67,6 +72,13 @@ impl Shape for fj::Sketch { Edges::single_cycle(edges) } + // TASK: This isn't right. We have 2-dimensional points, but here we return + // 3-dimensional points. In the approximations, we started going back + // to lower dimensions. + // + // Because for triangulation, we want to operate in surface + // coordinates again. That was required to make the triangulation + // simple/flexible enough to support transformations of b-rep faces. fn vertices(&self) -> Vec> { self.to_points() .into_iter()