Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Curve construction #1179

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ impl SurfaceSurfaceIntersection {
let curves = surfaces_and_planes.map(|(surface, plane)| {
let path = SurfacePath::Line(plane.project_line(&line));
let global_form = GlobalCurve::new(stores);
let curve = Curve::new(surface, path, global_form);

stores.curves.insert(curve)
Curve::new(surface, path, global_form, stores)
});

Some(Self {
Expand Down
11 changes: 4 additions & 7 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ impl Sweep for (HalfEdge, Color) {
points_curve_and_surface,
));

let curve = Curve::new(
Curve::new(
surface.clone(),
path,
edge.curve().global_form().clone(),
);

stores.curves.insert(curve)
stores,
)
};

let vertices = {
Expand Down Expand Up @@ -111,9 +110,7 @@ impl Sweep for (HalfEdge, Color) {
points_curve_and_surface,
));

let curve = Curve::new(surface.clone(), path, global);

stores.curves.insert(curve)
Curve::new(surface.clone(), path, global, stores)
};

let global =
Expand Down
7 changes: 4 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ impl Sweep for (Vertex, Handle<Surface>) {
// `Edge` is straight-forward.
let curve = {
let line = Line::from_points(points_surface);
let curve = Curve::new(

Curve::new(
surface.clone(),
SurfacePath::Line(line),
edge_global.curve().clone(),
);
stores.curves.insert(curve)
stores,
)
};

// And now the vertices. Again, nothing wild here.
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/validate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ mod tests {
let curve = {
let path = SurfacePath::line_from_points(points_surface);
let global_form = GlobalCurve::new(&stores);
let curve = Curve::new(surface.clone(), path, global_form);
stores.curves.insert(curve)

Curve::new(surface.clone(), path, global_form, &stores)
};

let [a_global, b_global] =
Expand Down
11 changes: 5 additions & 6 deletions crates/fj-kernel/src/objects/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ impl Curve {
surface: Handle<Surface>,
path: SurfacePath,
global_form: impl Into<HandleWrapper<GlobalCurve>>,
) -> Self {
let global_form = global_form.into();

Self {
stores: &Stores,
) -> Handle<Self> {
stores.curves.insert(Self {
surface,
path,
global_form,
}
global_form: global_form.into(),
})
}

/// Access the path that defines this curve
Expand Down
4 changes: 1 addition & 3 deletions crates/fj-kernel/src/partial/objects/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ impl PartialCurve {
.global_form
.unwrap_or_else(|| GlobalCurve::new(stores).into());

let curve = Curve::new(surface, path, global_form);

stores.curves.insert(curve)
Curve::new(surface, path, global_form, stores)
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/stores/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<T> Deref for Handle<T> {
// has at least been reserved.
// 2. That the memory objects live in is never deallocated.
//
// That means that as long as a `Handle` exists, the object is
// That means that as long as a `Handle` exists, the object it
// references has at least been reserved, and has not been deallocated.
//
// Given all this, we know that the following must be true:
Expand All @@ -71,7 +71,7 @@ impl<T> Deref for Handle<T> {
// the reference we return here are enforced.
//
// Furthermore, all of the code mentioned here is covered by unit tests,
// which I've run successfully run under Miri.
// which I've run successfully under Miri.
let cell = unsafe { &*self.ptr };

// Can only happen, if the object has been reserved, but the reservation
Expand Down