Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Feb 3, 2022
1 parent e79106a commit c7d8a3d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/kernel/geometry/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<T>(&self, handle: Handle<T>) -> 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
Expand Down
1 change: 1 addition & 0 deletions src/kernel/geometry/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod cache;
pub mod curves;
pub mod points;
pub mod surfaces;

pub use self::{
Expand Down
43 changes: 43 additions & 0 deletions src/kernel/geometry/points.rs
Original file line number Diff line number Diff line change
@@ -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<Point>,
}

// TASK: Document.
pub struct Point2D {
// TASK: Document.
pub u: f64,

// TASK: Document.
pub v: f64,

// TASK: Document.
pub handle: Handle<Point>,
}

// 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<Point>,
}

// TASK: Document.
pub struct Point;
12 changes: 12 additions & 0 deletions src/kernel/shapes/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.]);

Expand All @@ -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<Point<3>> {
self.to_points()
.into_iter()
Expand Down

0 comments on commit c7d8a3d

Please sign in to comment.