From d23108147a68c02d28298924a706bb322b1cdb86 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 14:42:22 +0200 Subject: [PATCH 01/31] Move `builder::curve` to `partial` The new `partial::curve` doesn't follow the style of the `partial` module yet. I'm going to address that in follow-up commits. --- crates/fj-kernel/src/builder/mod.rs | 2 -- crates/fj-kernel/src/objects/curve.rs | 2 +- crates/fj-kernel/src/{builder => partial}/curve.rs | 0 crates/fj-kernel/src/partial/mod.rs | 6 ++++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename crates/fj-kernel/src/{builder => partial}/curve.rs (100%) diff --git a/crates/fj-kernel/src/builder/mod.rs b/crates/fj-kernel/src/builder/mod.rs index 680d3fff0..f71b4b476 100644 --- a/crates/fj-kernel/src/builder/mod.rs +++ b/crates/fj-kernel/src/builder/mod.rs @@ -1,6 +1,5 @@ //! API for building objects -mod curve; mod cycle; mod edge; mod face; @@ -9,7 +8,6 @@ mod sketch; mod solid; pub use self::{ - curve::{CurveBuilder, GlobalCurveBuilder}, cycle::CycleBuilder, edge::{GlobalEdgeBuilder, HalfEdgeBuilder}, face::FaceBuilder, diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 934a2fa3b..b980cfd69 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -1,5 +1,5 @@ use crate::{ - builder::{CurveBuilder, GlobalCurveBuilder}, + partial::{CurveBuilder, GlobalCurveBuilder}, path::{GlobalPath, SurfacePath}, stores::{Handle, Stores}, }; diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/partial/curve.rs similarity index 100% rename from crates/fj-kernel/src/builder/curve.rs rename to crates/fj-kernel/src/partial/curve.rs diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index 70f138d6a..c44c42b96 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -25,8 +25,10 @@ //! - All `with_*`, `as_*`, and `build` methods can be chained, to provide a //! convenient API. +mod curve; mod vertex; -pub use self::vertex::{ - PartialGlobalVertex, PartialSurfaceVertex, PartialVertex, +pub use self::{ + curve::{CurveBuilder, GlobalCurveBuilder}, + vertex::{PartialGlobalVertex, PartialSurfaceVertex, PartialVertex}, }; From 875ee3a610cdb5beedc64774eb5cfc35b76044fe Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:35:33 +0200 Subject: [PATCH 02/31] Rename `GlobalCurveBuilder` The new name doesn't fit yet, but I'm working on that. --- crates/fj-kernel/src/objects/curve.rs | 8 ++++---- crates/fj-kernel/src/partial/curve.rs | 4 ++-- crates/fj-kernel/src/partial/mod.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index b980cfd69..55d81951c 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -1,5 +1,5 @@ use crate::{ - partial::{CurveBuilder, GlobalCurveBuilder}, + partial::{CurveBuilder, PartialGlobalCurve}, path::{GlobalPath, SurfacePath}, stores::{Handle, Stores}, }; @@ -56,9 +56,9 @@ pub struct GlobalCurve { } impl GlobalCurve { - /// Build a `Curve` using [`GlobalCurveBuilder`] - pub fn builder(stores: &Stores) -> GlobalCurveBuilder { - GlobalCurveBuilder { stores } + /// Build a `Curve` using [`PartialGlobalCurve`] + pub fn builder(stores: &Stores) -> PartialGlobalCurve { + PartialGlobalCurve { stores } } /// Construct a `GlobalCurve` from the path that defines it diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index bc421a319..0ab655f52 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -67,12 +67,12 @@ impl<'a> CurveBuilder<'a> { /// API for building a [`GlobalCurve`] /// /// Also see [`GlobalCurve::builder`]. -pub struct GlobalCurveBuilder<'a> { +pub struct PartialGlobalCurve<'a> { /// The stores that the created objects are put in pub stores: &'a Stores, } -impl<'a> GlobalCurveBuilder<'a> { +impl<'a> PartialGlobalCurve<'a> { /// Build a line that represents the x-axis pub fn x_axis(&self) -> Handle { self.stores diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index c44c42b96..7b9c1cc17 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -29,6 +29,6 @@ mod curve; mod vertex; pub use self::{ - curve::{CurveBuilder, GlobalCurveBuilder}, + curve::{CurveBuilder, PartialGlobalCurve}, vertex::{PartialGlobalVertex, PartialSurfaceVertex, PartialVertex}, }; From 77d61e66484c5796fc20e79edbd289828b242648 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:38:47 +0200 Subject: [PATCH 03/31] Rename `GlobalCurve::builder` --- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 4 ++-- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/objects/curve.rs | 2 +- crates/fj-kernel/src/partial/curve.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index 7de75d8c0..d2642b9e6 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -137,7 +137,7 @@ impl Sweep for GlobalVertex { let a = self; let b = GlobalVertex::from_position(self.position() + path.into()); - let curve = GlobalCurve::builder(stores) + let curve = GlobalCurve::partial(stores) .line_from_points([a.position(), b.position()]); GlobalEdge::new(curve, [a, b]) @@ -182,7 +182,7 @@ mod tests { .sweep([0., 0., 1.], &stores); let expected_edge = GlobalEdge::new( - GlobalCurve::builder(&stores).z_axis(), + GlobalCurve::partial(&stores).z_axis(), [[0., 0., 0.], [0., 0., 1.]].map(GlobalVertex::from_position), ); assert_eq!(edge, expected_edge); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 70902efa0..e7e39be7b 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -425,7 +425,7 @@ mod tests { fn global_curve() { let stores = Stores::new(); - let object = GlobalCurve::builder(&stores).x_axis(); + let object = GlobalCurve::partial(&stores).x_axis(); assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 55d81951c..95a0b1bd3 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -57,7 +57,7 @@ pub struct GlobalCurve { impl GlobalCurve { /// Build a `Curve` using [`PartialGlobalCurve`] - pub fn builder(stores: &Stores) -> PartialGlobalCurve { + pub fn partial(stores: &Stores) -> PartialGlobalCurve { PartialGlobalCurve { stores } } diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 0ab655f52..cb8f5546e 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -40,7 +40,7 @@ impl<'a> CurveBuilder<'a> { let path = SurfacePath::circle_from_radius(radius); let global_form = - GlobalCurve::builder(self.stores).circle_from_radius(radius); + GlobalCurve::partial(self.stores).circle_from_radius(radius); Curve::new(self.surface, path, global_form) } @@ -66,7 +66,7 @@ impl<'a> CurveBuilder<'a> { /// API for building a [`GlobalCurve`] /// -/// Also see [`GlobalCurve::builder`]. +/// Also see [`GlobalCurve::partial`]. pub struct PartialGlobalCurve<'a> { /// The stores that the created objects are put in pub stores: &'a Stores, From 323f720c41365057042d3a1e7000d5bb7c098618 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:41:43 +0200 Subject: [PATCH 04/31] Add path to `PartialGlobalCurve` --- crates/fj-kernel/src/objects/curve.rs | 2 +- crates/fj-kernel/src/partial/curve.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 95a0b1bd3..e79d8d453 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -58,7 +58,7 @@ pub struct GlobalCurve { impl GlobalCurve { /// Build a `Curve` using [`PartialGlobalCurve`] pub fn partial(stores: &Stores) -> PartialGlobalCurve { - PartialGlobalCurve { stores } + PartialGlobalCurve { stores, path: None } } /// Construct a `GlobalCurve` from the path that defines it diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index cb8f5546e..953796e8d 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -70,9 +70,20 @@ impl<'a> CurveBuilder<'a> { pub struct PartialGlobalCurve<'a> { /// The stores that the created objects are put in pub stores: &'a Stores, + + /// The path that defines the [`GlobalCurve`] + /// + /// Must be provided before [`PartialGlobalCurve::build`] is called. + pub path: Option, } impl<'a> PartialGlobalCurve<'a> { + /// Provide a path for the partial global curve + pub fn with_path(mut self, path: GlobalPath) -> Self { + self.path = Some(path); + self + } + /// Build a line that represents the x-axis pub fn x_axis(&self) -> Handle { self.stores @@ -115,4 +126,16 @@ impl<'a> PartialGlobalCurve<'a> { .global_curves .insert(GlobalCurve::from_path(GlobalPath::Line(line))) } + + /// Build a full [`GlobalCurve`] from the partial global curve + /// + /// # Panics + /// + /// Panics, if no path was provided. + pub fn build(self) -> Handle { + let path = self.path.expect("Can't build `GlobalCurve` without a path"); + self.stores + .global_curves + .insert(GlobalCurve::from_path(path)) + } } From 444cb099780ea4935b24cd3d76eb44b0a0fa0141 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:43:34 +0200 Subject: [PATCH 05/31] Replace `PartialGlobalCurve::x_axis` --- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/partial/curve.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index e7e39be7b..23b96602e 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -425,7 +425,7 @@ mod tests { fn global_curve() { let stores = Stores::new(); - let object = GlobalCurve::partial(&stores).x_axis(); + let object = GlobalCurve::partial(&stores).as_x_axis().build(); assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 953796e8d..a468668b4 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -84,11 +84,9 @@ impl<'a> PartialGlobalCurve<'a> { self } - /// Build a line that represents the x-axis - pub fn x_axis(&self) -> Handle { - self.stores - .global_curves - .insert(GlobalCurve::from_path(GlobalPath::x_axis())) + /// Update partial global curve to represent the x-axis + pub fn as_x_axis(self) -> Self { + self.with_path(GlobalPath::x_axis()) } /// Build a line that represents the y-axis From ba60279aea383889470f981a73406089e611a1f6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:44:28 +0200 Subject: [PATCH 06/31] Replace `PartialGlobalCurve::y_axis` --- crates/fj-kernel/src/partial/curve.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index a468668b4..9fd88c71f 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -89,11 +89,9 @@ impl<'a> PartialGlobalCurve<'a> { self.with_path(GlobalPath::x_axis()) } - /// Build a line that represents the y-axis - pub fn y_axis(&self) -> Handle { - self.stores - .global_curves - .insert(GlobalCurve::from_path(GlobalPath::y_axis())) + /// Update partial global curve to represent the y-axis + pub fn as_y_axis(self) -> Self { + self.with_path(GlobalPath::y_axis()) } /// Build a line that represents the z-axis From e2949450efae79df16f339d0d775ceb21e2bf0d2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:46:45 +0200 Subject: [PATCH 07/31] Replace `PartialGlobalCurve::z_axis` --- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 2 +- crates/fj-kernel/src/partial/curve.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index d2642b9e6..b306c9735 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -182,7 +182,7 @@ mod tests { .sweep([0., 0., 1.], &stores); let expected_edge = GlobalEdge::new( - GlobalCurve::partial(&stores).z_axis(), + GlobalCurve::partial(&stores).as_z_axis().build(), [[0., 0., 0.], [0., 0., 1.]].map(GlobalVertex::from_position), ); assert_eq!(edge, expected_edge); diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 9fd88c71f..651f7fc02 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -94,11 +94,9 @@ impl<'a> PartialGlobalCurve<'a> { self.with_path(GlobalPath::y_axis()) } - /// Build a line that represents the z-axis - pub fn z_axis(&self) -> Handle { - self.stores - .global_curves - .insert(GlobalCurve::from_path(GlobalPath::z_axis())) + /// Update partial global curve to represent the z-axis + pub fn as_z_axis(self) -> Self { + self.with_path(GlobalPath::z_axis()) } /// Build a circle from the given radius From 5a3a0154f3a8e4e5a683d30ed7dd4077ce1cad14 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 15:56:25 +0200 Subject: [PATCH 08/31] Replace `PartialGlobalCurve::circle_from_radius` --- crates/fj-kernel/src/partial/curve.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 651f7fc02..5e8133c49 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -39,8 +39,9 @@ impl<'a> CurveBuilder<'a> { let radius = radius.into(); let path = SurfacePath::circle_from_radius(radius); - let global_form = - GlobalCurve::partial(self.stores).circle_from_radius(radius); + let global_form = GlobalCurve::partial(self.stores) + .as_circle_from_radius(radius) + .build(); Curve::new(self.surface, path, global_form) } @@ -99,15 +100,9 @@ impl<'a> PartialGlobalCurve<'a> { self.with_path(GlobalPath::z_axis()) } - /// Build a circle from the given radius - pub fn circle_from_radius( - &self, - radius: impl Into, - ) -> Handle { - let path = GlobalPath::circle_from_radius(radius); - self.stores - .global_curves - .insert(GlobalCurve::from_path(path)) + /// Update partial global curve as a circle, from the provided radius + pub fn as_circle_from_radius(self, radius: impl Into) -> Self { + self.with_path(GlobalPath::circle_from_radius(radius)) } /// Create a line from the given points From 40d432b3dc1f63148a7f85827c56598a713d28ba Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:01:37 +0200 Subject: [PATCH 09/31] Replace `PartialGlobalCurve::line_from_points` --- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 3 ++- crates/fj-kernel/src/partial/curve.rs | 12 +++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index b306c9735..97f89adf2 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -138,7 +138,8 @@ impl Sweep for GlobalVertex { let b = GlobalVertex::from_position(self.position() + path.into()); let curve = GlobalCurve::partial(stores) - .line_from_points([a.position(), b.position()]); + .as_line_from_points([a.position(), b.position()]) + .build(); GlobalEdge::new(curve, [a, b]) } diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 5e8133c49..29269f0e1 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -105,15 +105,9 @@ impl<'a> PartialGlobalCurve<'a> { self.with_path(GlobalPath::circle_from_radius(radius)) } - /// Create a line from the given points - pub fn line_from_points( - &self, - points: [impl Into>; 2], - ) -> Handle { - let line = Line::from_points(points); - self.stores - .global_curves - .insert(GlobalCurve::from_path(GlobalPath::Line(line))) + /// Update partial global curve as a line, from the provided points + pub fn as_line_from_points(self, points: [impl Into>; 2]) -> Self { + self.with_path(GlobalPath::line_from_points(points)) } /// Build a full [`GlobalCurve`] from the partial global curve From f3a7d8cbe2cb0bc2e2442edc8554ca7f5ac59770 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:04:01 +0200 Subject: [PATCH 10/31] Expect `&Stores` in `PartialGlobalCurve::build` --- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 6 +++--- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/objects/curve.rs | 4 ++-- crates/fj-kernel/src/partial/curve.rs | 17 ++++++----------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index 97f89adf2..f15b71701 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -137,9 +137,9 @@ impl Sweep for GlobalVertex { let a = self; let b = GlobalVertex::from_position(self.position() + path.into()); - let curve = GlobalCurve::partial(stores) + let curve = GlobalCurve::partial() .as_line_from_points([a.position(), b.position()]) - .build(); + .build(stores); GlobalEdge::new(curve, [a, b]) } @@ -183,7 +183,7 @@ mod tests { .sweep([0., 0., 1.], &stores); let expected_edge = GlobalEdge::new( - GlobalCurve::partial(&stores).as_z_axis().build(), + GlobalCurve::partial().as_z_axis().build(&stores), [[0., 0., 0.], [0., 0., 1.]].map(GlobalVertex::from_position), ); assert_eq!(edge, expected_edge); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 23b96602e..3747e5171 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -425,7 +425,7 @@ mod tests { fn global_curve() { let stores = Stores::new(); - let object = GlobalCurve::partial(&stores).as_x_axis().build(); + let object = GlobalCurve::partial().as_x_axis().build(&stores); assert_eq!(0, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index e79d8d453..444df4e50 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -57,8 +57,8 @@ pub struct GlobalCurve { impl GlobalCurve { /// Build a `Curve` using [`PartialGlobalCurve`] - pub fn partial(stores: &Stores) -> PartialGlobalCurve { - PartialGlobalCurve { stores, path: None } + pub fn partial() -> PartialGlobalCurve { + PartialGlobalCurve { path: None } } /// Construct a `GlobalCurve` from the path that defines it diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 29269f0e1..6c34898e4 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -39,9 +39,9 @@ impl<'a> CurveBuilder<'a> { let radius = radius.into(); let path = SurfacePath::circle_from_radius(radius); - let global_form = GlobalCurve::partial(self.stores) + let global_form = GlobalCurve::partial() .as_circle_from_radius(radius) - .build(); + .build(self.stores); Curve::new(self.surface, path, global_form) } @@ -68,17 +68,14 @@ impl<'a> CurveBuilder<'a> { /// API for building a [`GlobalCurve`] /// /// Also see [`GlobalCurve::partial`]. -pub struct PartialGlobalCurve<'a> { - /// The stores that the created objects are put in - pub stores: &'a Stores, - +pub struct PartialGlobalCurve { /// The path that defines the [`GlobalCurve`] /// /// Must be provided before [`PartialGlobalCurve::build`] is called. pub path: Option, } -impl<'a> PartialGlobalCurve<'a> { +impl PartialGlobalCurve { /// Provide a path for the partial global curve pub fn with_path(mut self, path: GlobalPath) -> Self { self.path = Some(path); @@ -115,10 +112,8 @@ impl<'a> PartialGlobalCurve<'a> { /// # Panics /// /// Panics, if no path was provided. - pub fn build(self) -> Handle { + pub fn build(self, stores: &Stores) -> Handle { let path = self.path.expect("Can't build `GlobalCurve` without a path"); - self.stores - .global_curves - .insert(GlobalCurve::from_path(path)) + stores.global_curves.insert(GlobalCurve::from_path(path)) } } From 236ee6b7fae450f7cf7986207f45f5d8edd4a194 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:05:12 +0200 Subject: [PATCH 11/31] Derive `Default` for `PartialGlobalCurve` --- crates/fj-kernel/src/objects/curve.rs | 2 +- crates/fj-kernel/src/partial/curve.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 444df4e50..7874ba99f 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -58,7 +58,7 @@ pub struct GlobalCurve { impl GlobalCurve { /// Build a `Curve` using [`PartialGlobalCurve`] pub fn partial() -> PartialGlobalCurve { - PartialGlobalCurve { path: None } + PartialGlobalCurve::default() } /// Construct a `GlobalCurve` from the path that defines it diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 6c34898e4..142ff8f77 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -68,6 +68,7 @@ impl<'a> CurveBuilder<'a> { /// API for building a [`GlobalCurve`] /// /// Also see [`GlobalCurve::partial`]. +#[derive(Default)] pub struct PartialGlobalCurve { /// The path that defines the [`GlobalCurve`] /// From f327abaf8fb65fbfd63b962c801b870f87b283ea Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:06:07 +0200 Subject: [PATCH 12/31] Update documentation of `PartialGlobalCurve` --- crates/fj-kernel/src/objects/curve.rs | 5 ++++- crates/fj-kernel/src/partial/curve.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 7874ba99f..093104cc5 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -56,7 +56,10 @@ pub struct GlobalCurve { } impl GlobalCurve { - /// Build a `Curve` using [`PartialGlobalCurve`] + /// Create a [`PartialGlobalCurve`] + /// + /// This function exists just for convenience, and will just return a + /// default [`PartialGlobalCurve`]. pub fn partial() -> PartialGlobalCurve { PartialGlobalCurve::default() } diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 142ff8f77..3d1e77003 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -65,9 +65,9 @@ impl<'a> CurveBuilder<'a> { } } -/// API for building a [`GlobalCurve`] +/// A partial [`GlobalCurve`] /// -/// Also see [`GlobalCurve::partial`]. +/// See [`crate::partial`] for more information. #[derive(Default)] pub struct PartialGlobalCurve { /// The path that defines the [`GlobalCurve`] From aaad1d9ca74cc50d51664d7fdd8c71e7775487e6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:09:59 +0200 Subject: [PATCH 13/31] Rename `CurveBuilder` to `PartialCurve` The new name doesn't fit yet. I'm working on that. --- crates/fj-kernel/src/objects/curve.rs | 8 ++++---- crates/fj-kernel/src/partial/curve.rs | 4 ++-- crates/fj-kernel/src/partial/mod.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 093104cc5..0136d149e 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -1,5 +1,5 @@ use crate::{ - partial::{CurveBuilder, PartialGlobalCurve}, + partial::{PartialCurve, PartialGlobalCurve}, path::{GlobalPath, SurfacePath}, stores::{Handle, Stores}, }; @@ -15,9 +15,9 @@ pub struct Curve { } impl Curve { - /// Build a `Curve` using [`CurveBuilder`] - pub fn builder(stores: &Stores, surface: Surface) -> CurveBuilder { - CurveBuilder { stores, surface } + /// Build a `Curve` using [`PartialCurve`] + pub fn builder(stores: &Stores, surface: Surface) -> PartialCurve { + PartialCurve { stores, surface } } /// Construct a new instance of `Curve` diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 3d1e77003..11d053f4f 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -9,7 +9,7 @@ use crate::{ /// API for building a [`Curve`] /// /// Also see [`Curve::builder`]. -pub struct CurveBuilder<'a> { +pub struct PartialCurve<'a> { /// The stores that the created objects are put in pub stores: &'a Stores, @@ -17,7 +17,7 @@ pub struct CurveBuilder<'a> { pub surface: Surface, } -impl<'a> CurveBuilder<'a> { +impl<'a> PartialCurve<'a> { /// Build a line that represents the u-axis on the surface pub fn build_u_axis(self) -> Curve { let a = Point::origin(); diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index 7b9c1cc17..6ffa28d08 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -29,6 +29,6 @@ mod curve; mod vertex; pub use self::{ - curve::{CurveBuilder, PartialGlobalCurve}, + curve::{PartialCurve, PartialGlobalCurve}, vertex::{PartialGlobalVertex, PartialSurfaceVertex, PartialVertex}, }; From 5ba7d97405ddf3a27530c80dfc14924c00d4741d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:10:50 +0200 Subject: [PATCH 14/31] Rename `Curve::builder` to `Curve::partial` --- crates/fj-kernel/src/algorithms/approx/curve.rs | 8 ++++---- crates/fj-kernel/src/algorithms/intersect/curve_edge.rs | 8 ++++---- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 2 +- crates/fj-kernel/src/algorithms/intersect/face_face.rs | 2 +- .../fj-kernel/src/algorithms/intersect/surface_surface.rs | 4 ++-- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 2 +- crates/fj-kernel/src/builder/edge.rs | 2 +- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/objects/curve.rs | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 09fd66828..7602b98f2 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -209,7 +209,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = Curve::builder(&stores, surface) + let curve = Curve::partial(&stores, surface) .build_line_from_points([[1., 1.], [2., 1.]]); let range = RangeOnPath::from([[0.], [1.]]); @@ -224,7 +224,7 @@ mod tests { let surface = Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]); - let curve = Curve::builder(&stores, surface) + let curve = Curve::partial(&stores, surface) .build_line_from_points([[1., 1.], [1., 2.]]); let range = RangeOnPath::from([[0.], [1.]]); @@ -239,7 +239,7 @@ mod tests { let path = GlobalPath::circle_from_radius(1.); let surface = Surface::new(path, [0., 0., 1.]); - let curve = Curve::builder(&stores, surface) + let curve = Curve::partial(&stores, surface) .build_line_from_points([[0., 1.], [1., 1.]]); let range = RangeOnPath::from([[0.], [TAU]]); @@ -267,7 +267,7 @@ mod tests { let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); let curve = - Curve::builder(&stores, surface).build_circle_from_radius(1.); + Curve::partial(&stores, surface).build_circle_from_radius(1.); let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index 47746980a..4f364e194 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -86,7 +86,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[1., -1.], [1., 1.]]) .build(); @@ -106,7 +106,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [-1., 1.]]) .build(); @@ -126,7 +126,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [1., -1.]]) .build(); @@ -141,7 +141,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., 0.], [1., 0.]]) .build(); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 35ee1f673..4f9aef08e 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -168,7 +168,7 @@ mod tests { let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface) + let curve = Curve::partial(&stores, surface) .build_line_from_points([[-3., 0.], [-2., 0.]]); #[rustfmt::skip] diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 1e93b9151..704b58c44 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -114,7 +114,7 @@ mod tests { let intersection = FaceFaceIntersection::compute([&a, &b], &stores); let expected_curves = surfaces.map(|surface| { - Curve::builder(&stores, surface) + Curve::partial(&stores, surface) .build_line_from_points([[0., 0.], [1., 0.]]) }); let expected_intervals = diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 7676a4170..94681559d 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -186,8 +186,8 @@ mod tests { None, ); - let expected_xy = Curve::builder(&stores, xy).build_u_axis(); - let expected_xz = Curve::builder(&stores, xz).build_u_axis(); + let expected_xy = Curve::partial(&stores, xy).build_u_axis(); + let expected_xz = Curve::partial(&stores, xz).build_u_axis(); assert_eq!( SurfaceSurfaceIntersection::compute([&xy, &xz], &stores), diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index f15b71701..c8de58988 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -161,7 +161,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xz_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let vertex = Vertex::partial() .with_position([0.]) .with_curve(curve) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 335cb50a6..d2460aba0 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -53,7 +53,7 @@ impl<'a> HalfEdgeBuilder<'a> { /// Build the [`HalfEdge`] as a circle from the given radius pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { - let curve = Curve::builder(self.stores, self.surface) + let curve = Curve::partial(self.stores, self.surface) .build_circle_from_radius(radius); let vertices = { diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 3747e5171..7f56ab5ac 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -362,7 +362,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let object = Curve::builder(&stores, surface).build_u_axis(); + let object = Curve::partial(&stores, surface).build_u_axis(); assert_eq!(1, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); @@ -561,7 +561,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::builder(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).build_u_axis(); let global_vertex = GlobalVertex::from_position([0., 0., 0.]); let surface_vertex = SurfaceVertex::new([0., 0.], surface, global_vertex); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 0136d149e..dd07468d6 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -16,7 +16,7 @@ pub struct Curve { impl Curve { /// Build a `Curve` using [`PartialCurve`] - pub fn builder(stores: &Stores, surface: Surface) -> PartialCurve { + pub fn partial(stores: &Stores, surface: Surface) -> PartialCurve { PartialCurve { stores, surface } } From ef1544d1694c17c78b10770d0ef7efed2b8387c8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:18:41 +0200 Subject: [PATCH 15/31] Split `PartialCurve::build_line_from_points` --- .../fj-kernel/src/algorithms/approx/curve.rs | 9 ++-- .../src/algorithms/intersect/curve_face.rs | 3 +- .../src/algorithms/intersect/face_face.rs | 3 +- crates/fj-kernel/src/objects/curve.rs | 7 ++- crates/fj-kernel/src/partial/curve.rs | 43 ++++++++++++++----- 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 7602b98f2..e68c425bc 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -210,7 +210,8 @@ mod tests { let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); let curve = Curve::partial(&stores, surface) - .build_line_from_points([[1., 1.], [2., 1.]]); + .as_line_from_points([[1., 1.], [2., 1.]]) + .build(); let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -225,7 +226,8 @@ mod tests { let surface = Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]); let curve = Curve::partial(&stores, surface) - .build_line_from_points([[1., 1.], [1., 2.]]); + .as_line_from_points([[1., 1.], [1., 2.]]) + .build(); let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -240,7 +242,8 @@ mod tests { let path = GlobalPath::circle_from_radius(1.); let surface = Surface::new(path, [0., 0., 1.]); let curve = Curve::partial(&stores, surface) - .build_line_from_points([[0., 1.], [1., 1.]]); + .as_line_from_points([[0., 1.], [1., 1.]]) + .build(); let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 4f9aef08e..5b26c1cff 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -169,7 +169,8 @@ mod tests { let surface = Surface::xy_plane(); let curve = Curve::partial(&stores, surface) - .build_line_from_points([[-3., 0.], [-2., 0.]]); + .as_line_from_points([[-3., 0.], [-2., 0.]]) + .build(); #[rustfmt::skip] let exterior = [ diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 704b58c44..1f0935611 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -115,7 +115,8 @@ mod tests { let expected_curves = surfaces.map(|surface| { Curve::partial(&stores, surface) - .build_line_from_points([[0., 0.], [1., 0.]]) + .as_line_from_points([[0., 0.], [1., 0.]]) + .build() }); let expected_intervals = CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index dd07468d6..ea963e7bf 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -17,7 +17,12 @@ pub struct Curve { impl Curve { /// Build a `Curve` using [`PartialCurve`] pub fn partial(stores: &Stores, surface: Surface) -> PartialCurve { - PartialCurve { stores, surface } + PartialCurve { + stores, + path: None, + surface, + global_form: None, + } } /// Construct a new instance of `Curve` diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 11d053f4f..350a2d3d0 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -13,8 +13,18 @@ pub struct PartialCurve<'a> { /// The stores that the created objects are put in pub stores: &'a Stores, + /// The path that defines the [`Curve`] + /// + /// Must be provided before calling [`PartialCurve::build`]. + pub path: Option, + /// The surface that the [`Curve`] is defined in pub surface: Surface, + + /// The global form of the [`Curve`] + /// + /// Must be provided before calling [`PartialCurve::build`]. + pub global_form: Option, } impl<'a> PartialCurve<'a> { @@ -23,7 +33,7 @@ impl<'a> PartialCurve<'a> { let a = Point::origin(); let b = a + Vector::unit_u(); - self.build_line_from_points([a, b]) + self.as_line_from_points([a, b]).build() } /// Build a line that represents the v-axis on the surface @@ -31,7 +41,7 @@ impl<'a> PartialCurve<'a> { let a = Point::origin(); let b = a + Vector::unit_v(); - self.build_line_from_points([a, b]) + self.as_line_from_points([a, b]).build() } /// Build a circle from the given radius @@ -46,20 +56,31 @@ impl<'a> PartialCurve<'a> { Curve::new(self.surface, path, global_form) } - /// Build a line from the given points - pub fn build_line_from_points( - &self, + /// Update partial curve as a line, from the provided points + pub fn as_line_from_points( + mut self, points: [impl Into>; 2], - ) -> Curve { + ) -> Self { let points = points.map(Into::into); - let path = SurfacePath::Line(Line::from_points(points)); - let global_form = self.stores.global_curves.insert( - GlobalCurve::from_path(GlobalPath::Line(Line::from_points( + self.path = Some(SurfacePath::Line(Line::from_points(points))); + self.global_form = + Some(GlobalCurve::from_path(GlobalPath::Line(Line::from_points( points .map(|point| self.surface.point_from_surface_coords(point)), - ))), - ); + )))); + + self + } + + /// Build a full [`Curve`] from the partial curve + pub fn build(self) -> Curve { + let path = self.path.expect("Can't build `Curve` without path"); + let global_form = self + .global_form + .expect("Can't build `Curve` without a global form"); + + let global_form = self.stores.global_curves.insert(global_form); Curve::new(self.surface, path, global_form) } From b9edbd1ae7bfa7f09f6948aafa55f3aa9bafaa60 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:21:51 +0200 Subject: [PATCH 16/31] Refactor --- crates/fj-kernel/src/partial/curve.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 350a2d3d0..f3ae6217d 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -24,7 +24,7 @@ pub struct PartialCurve<'a> { /// The global form of the [`Curve`] /// /// Must be provided before calling [`PartialCurve::build`]. - pub global_form: Option, + pub global_form: Option, } impl<'a> PartialCurve<'a> { @@ -65,10 +65,11 @@ impl<'a> PartialCurve<'a> { self.path = Some(SurfacePath::Line(Line::from_points(points))); self.global_form = - Some(GlobalCurve::from_path(GlobalPath::Line(Line::from_points( - points - .map(|point| self.surface.point_from_surface_coords(point)), - )))); + Some(GlobalCurve::partial().with_path(GlobalPath::Line( + Line::from_points(points.map(|point| { + self.surface.point_from_surface_coords(point) + })), + ))); self } @@ -78,9 +79,8 @@ impl<'a> PartialCurve<'a> { let path = self.path.expect("Can't build `Curve` without path"); let global_form = self .global_form - .expect("Can't build `Curve` without a global form"); - - let global_form = self.stores.global_curves.insert(global_form); + .expect("Can't build `Curve` without a global form") + .build(self.stores); Curve::new(self.surface, path, global_form) } From f19f7ac143f70e227758a58b4e03ff310e7bf650 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:22:20 +0200 Subject: [PATCH 17/31] Refactor --- crates/fj-kernel/src/partial/curve.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index f3ae6217d..9fc6d4b1e 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -64,12 +64,9 @@ impl<'a> PartialCurve<'a> { let points = points.map(Into::into); self.path = Some(SurfacePath::Line(Line::from_points(points))); - self.global_form = - Some(GlobalCurve::partial().with_path(GlobalPath::Line( - Line::from_points(points.map(|point| { - self.surface.point_from_surface_coords(point) - })), - ))); + self.global_form = Some(GlobalCurve::partial().as_line_from_points( + points.map(|point| self.surface.point_from_surface_coords(point)), + )); self } From 9cd00c5ceb9b51614024f8ad4ee6aa95da90cbc3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:25:00 +0200 Subject: [PATCH 18/31] Replace `PartialCurve::build_circle_from_radius` --- crates/fj-kernel/src/algorithms/approx/curve.rs | 5 +++-- crates/fj-kernel/src/builder/edge.rs | 3 ++- crates/fj-kernel/src/partial/curve.rs | 13 ++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index e68c425bc..6d50e327b 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -269,8 +269,9 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = - Curve::partial(&stores, surface).build_circle_from_radius(1.); + let curve = Curve::partial(&stores, surface) + .as_circle_from_radius(1.) + .build(); let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index d2460aba0..a80fa656c 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -54,7 +54,8 @@ impl<'a> HalfEdgeBuilder<'a> { /// Build the [`HalfEdge`] as a circle from the given radius pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { let curve = Curve::partial(self.stores, self.surface) - .build_circle_from_radius(radius); + .as_circle_from_radius(radius) + .build(); let vertices = { let [a_curve, b_curve] = diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 9fc6d4b1e..bbe1b1c78 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -44,16 +44,15 @@ impl<'a> PartialCurve<'a> { self.as_line_from_points([a, b]).build() } - /// Build a circle from the given radius - pub fn build_circle_from_radius(self, radius: impl Into) -> Curve { + /// Update partial curve as a circle, from the provided radius + pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { let radius = radius.into(); - let path = SurfacePath::circle_from_radius(radius); - let global_form = GlobalCurve::partial() - .as_circle_from_radius(radius) - .build(self.stores); + self.path = Some(SurfacePath::circle_from_radius(radius)); + self.global_form = + Some(GlobalCurve::partial().as_circle_from_radius(radius)); - Curve::new(self.surface, path, global_form) + self } /// Update partial curve as a line, from the provided points From 5c03961cf95e8594f387935c1f5942e9b659f7d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:26:17 +0200 Subject: [PATCH 19/31] Replace `PartialCurve::build_v_axis` --- crates/fj-kernel/src/partial/curve.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index bbe1b1c78..8128ecbab 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -36,12 +36,12 @@ impl<'a> PartialCurve<'a> { self.as_line_from_points([a, b]).build() } - /// Build a line that represents the v-axis on the surface - pub fn build_v_axis(self) -> Curve { + /// Update partial curve to represent the v-axis + pub fn as_v_axis(self) -> Self { let a = Point::origin(); let b = a + Vector::unit_v(); - self.as_line_from_points([a, b]).build() + self.as_line_from_points([a, b]) } /// Update partial curve as a circle, from the provided radius From ec7e01f3b5f26aea814074d247aea59a35360ac3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:28:22 +0200 Subject: [PATCH 20/31] Replace `PartialCurve::build_u_axis` --- crates/fj-kernel/src/algorithms/intersect/curve_edge.rs | 8 ++++---- .../fj-kernel/src/algorithms/intersect/surface_surface.rs | 4 ++-- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 2 +- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/partial/curve.rs | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index 4f364e194..b51ad5bc6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -86,7 +86,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[1., -1.], [1., 1.]]) .build(); @@ -106,7 +106,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [-1., 1.]]) .build(); @@ -126,7 +126,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [1., -1.]]) .build(); @@ -141,7 +141,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., 0.], [1., 0.]]) .build(); diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 94681559d..4f9f39b5d 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -186,8 +186,8 @@ mod tests { None, ); - let expected_xy = Curve::partial(&stores, xy).build_u_axis(); - let expected_xz = Curve::partial(&stores, xz).build_u_axis(); + let expected_xy = Curve::partial(&stores, xy).as_u_axis().build(); + let expected_xz = Curve::partial(&stores, xz).as_u_axis().build(); assert_eq!( SurfaceSurfaceIntersection::compute([&xy, &xz], &stores), diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index c8de58988..1cf7d18de 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -161,7 +161,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xz_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let vertex = Vertex::partial() .with_position([0.]) .with_curve(curve) diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 7f56ab5ac..95045d02a 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -362,7 +362,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let object = Curve::partial(&stores, surface).build_u_axis(); + let object = Curve::partial(&stores, surface).as_u_axis().build(); assert_eq!(1, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); @@ -561,7 +561,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).build_u_axis(); + let curve = Curve::partial(&stores, surface).as_u_axis().build(); let global_vertex = GlobalVertex::from_position([0., 0., 0.]); let surface_vertex = SurfaceVertex::new([0., 0.], surface, global_vertex); diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 8128ecbab..778a5e2f2 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -28,12 +28,12 @@ pub struct PartialCurve<'a> { } impl<'a> PartialCurve<'a> { - /// Build a line that represents the u-axis on the surface - pub fn build_u_axis(self) -> Curve { + /// Update partial curve to represent the u-axis + pub fn as_u_axis(self) -> Self { let a = Point::origin(); let b = a + Vector::unit_u(); - self.as_line_from_points([a, b]).build() + self.as_line_from_points([a, b]) } /// Update partial curve to represent the v-axis From 038b32a4864a6fb3bcfb7186a863728d677377ce Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:35:09 +0200 Subject: [PATCH 21/31] Refactor --- crates/fj-kernel/src/partial/curve.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 778a5e2f2..9e5383ec9 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -1,4 +1,4 @@ -use fj_math::{Line, Point, Scalar, Vector}; +use fj_math::{Point, Scalar, Vector}; use crate::{ objects::{Curve, GlobalCurve, Surface}, @@ -62,7 +62,7 @@ impl<'a> PartialCurve<'a> { ) -> Self { let points = points.map(Into::into); - self.path = Some(SurfacePath::Line(Line::from_points(points))); + self.path = Some(SurfacePath::line_from_points(points)); self.global_form = Some(GlobalCurve::partial().as_line_from_points( points.map(|point| self.surface.point_from_surface_coords(point)), )); From e24dd2487d18cc0c75df650907a5193f5c0af417 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:35:55 +0200 Subject: [PATCH 22/31] Rename variable to be more specific --- crates/fj-kernel/src/partial/curve.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 9e5383ec9..05d609733 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -60,12 +60,15 @@ impl<'a> PartialCurve<'a> { mut self, points: [impl Into>; 2], ) -> Self { - let points = points.map(Into::into); - - self.path = Some(SurfacePath::line_from_points(points)); - self.global_form = Some(GlobalCurve::partial().as_line_from_points( - points.map(|point| self.surface.point_from_surface_coords(point)), - )); + let points_surface = points.map(Into::into); + + self.path = Some(SurfacePath::line_from_points(points_surface)); + self.global_form = Some( + GlobalCurve::partial() + .as_line_from_points(points_surface.map(|point| { + self.surface.point_from_surface_coords(point) + })), + ); self } From 680d74c82a7db6b028afb58f327f3eb830aad6c1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:36:29 +0200 Subject: [PATCH 23/31] Refactor --- crates/fj-kernel/src/partial/curve.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 05d609733..5ac1ed789 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -61,14 +61,12 @@ impl<'a> PartialCurve<'a> { points: [impl Into>; 2], ) -> Self { let points_surface = points.map(Into::into); + let points_global = points_surface + .map(|point| self.surface.point_from_surface_coords(point)); self.path = Some(SurfacePath::line_from_points(points_surface)); - self.global_form = Some( - GlobalCurve::partial() - .as_line_from_points(points_surface.map(|point| { - self.surface.point_from_surface_coords(point) - })), - ); + self.global_form = + Some(GlobalCurve::partial().as_line_from_points(points_global)); self } From d534af5831f80ced00431dbd324514efffbe2ada Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:37:48 +0200 Subject: [PATCH 24/31] Add `PartialCurve::with_global_form` --- crates/fj-kernel/src/partial/curve.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 5ac1ed789..68ab2bcf9 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -28,6 +28,12 @@ pub struct PartialCurve<'a> { } impl<'a> PartialCurve<'a> { + /// Provide a global form for the partial curve + pub fn with_global_form(mut self, global_form: PartialGlobalCurve) -> Self { + self.global_form = Some(global_form); + self + } + /// Update partial curve to represent the u-axis pub fn as_u_axis(self) -> Self { let a = Point::origin(); @@ -49,10 +55,9 @@ impl<'a> PartialCurve<'a> { let radius = radius.into(); self.path = Some(SurfacePath::circle_from_radius(radius)); - self.global_form = - Some(GlobalCurve::partial().as_circle_from_radius(radius)); - - self + self.with_global_form( + GlobalCurve::partial().as_circle_from_radius(radius), + ) } /// Update partial curve as a line, from the provided points @@ -65,10 +70,9 @@ impl<'a> PartialCurve<'a> { .map(|point| self.surface.point_from_surface_coords(point)); self.path = Some(SurfacePath::line_from_points(points_surface)); - self.global_form = - Some(GlobalCurve::partial().as_line_from_points(points_global)); - - self + self.with_global_form( + GlobalCurve::partial().as_line_from_points(points_global), + ) } /// Build a full [`Curve`] from the partial curve From 2d7f0fdd51ff08bd46f2a22f24de4fdc2765380a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:39:02 +0200 Subject: [PATCH 25/31] Add `PartialCurve::with_path` --- crates/fj-kernel/src/partial/curve.rs | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 68ab2bcf9..c9cb31f94 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -28,6 +28,12 @@ pub struct PartialCurve<'a> { } impl<'a> PartialCurve<'a> { + /// Provide a path for the partial curve + pub fn with_path(mut self, path: SurfacePath) -> Self { + self.path = Some(path); + self + } + /// Provide a global form for the partial curve pub fn with_global_form(mut self, global_form: PartialGlobalCurve) -> Self { self.global_form = Some(global_form); @@ -51,28 +57,25 @@ impl<'a> PartialCurve<'a> { } /// Update partial curve as a circle, from the provided radius - pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { + pub fn as_circle_from_radius(self, radius: impl Into) -> Self { let radius = radius.into(); - self.path = Some(SurfacePath::circle_from_radius(radius)); - self.with_global_form( - GlobalCurve::partial().as_circle_from_radius(radius), - ) + self.with_path(SurfacePath::circle_from_radius(radius)) + .with_global_form( + GlobalCurve::partial().as_circle_from_radius(radius), + ) } /// Update partial curve as a line, from the provided points - pub fn as_line_from_points( - mut self, - points: [impl Into>; 2], - ) -> Self { + pub fn as_line_from_points(self, points: [impl Into>; 2]) -> Self { let points_surface = points.map(Into::into); let points_global = points_surface .map(|point| self.surface.point_from_surface_coords(point)); - self.path = Some(SurfacePath::line_from_points(points_surface)); - self.with_global_form( - GlobalCurve::partial().as_line_from_points(points_global), - ) + self.with_path(SurfacePath::line_from_points(points_surface)) + .with_global_form( + GlobalCurve::partial().as_line_from_points(points_global), + ) } /// Build a full [`Curve`] from the partial curve From 9bc4e2187ec128406a7a2a74fa374dc59308fa81 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:43:40 +0200 Subject: [PATCH 26/31] Expect `&Stores` in `PartialCurve::build` --- crates/fj-kernel/src/algorithms/approx/curve.rs | 16 ++++++++-------- .../src/algorithms/intersect/curve_edge.rs | 8 ++++---- .../src/algorithms/intersect/curve_face.rs | 4 ++-- .../src/algorithms/intersect/face_face.rs | 4 ++-- .../src/algorithms/intersect/surface_surface.rs | 4 ++-- crates/fj-kernel/src/algorithms/sweep/vertex.rs | 2 +- crates/fj-kernel/src/builder/edge.rs | 4 ++-- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/objects/curve.rs | 5 ++--- crates/fj-kernel/src/partial/curve.rs | 11 ++++------- 10 files changed, 29 insertions(+), 33 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 6d50e327b..18a22f9d2 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -209,9 +209,9 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = Curve::partial(&stores, surface) + let curve = Curve::partial(surface) .as_line_from_points([[1., 1.], [2., 1.]]) - .build(); + .build(&stores); let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -225,9 +225,9 @@ mod tests { let surface = Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]); - let curve = Curve::partial(&stores, surface) + let curve = Curve::partial(surface) .as_line_from_points([[1., 1.], [1., 2.]]) - .build(); + .build(&stores); let range = RangeOnPath::from([[0.], [1.]]); let approx = (&curve, range).approx(1.); @@ -241,9 +241,9 @@ mod tests { let path = GlobalPath::circle_from_radius(1.); let surface = Surface::new(path, [0., 0., 1.]); - let curve = Curve::partial(&stores, surface) + let curve = Curve::partial(surface) .as_line_from_points([[0., 1.], [1., 1.]]) - .build(); + .build(&stores); let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; @@ -269,9 +269,9 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = Curve::partial(&stores, surface) + let curve = Curve::partial(surface) .as_circle_from_radius(1.) - .build(); + .build(&stores); let range = RangeOnPath::from([[0.], [TAU]]); let tolerance = 1.; diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index b51ad5bc6..8dcdb6981 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -86,7 +86,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[1., -1.], [1., 1.]]) .build(); @@ -106,7 +106,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [-1., 1.]]) .build(); @@ -126,7 +126,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [1., -1.]]) .build(); @@ -141,7 +141,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., 0.], [1., 0.]]) .build(); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 5b26c1cff..b8af458a1 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -168,9 +168,9 @@ mod tests { let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface) + let curve = Curve::partial(surface) .as_line_from_points([[-3., 0.], [-2., 0.]]) - .build(); + .build(&stores); #[rustfmt::skip] let exterior = [ diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 1f0935611..923f862b3 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -114,9 +114,9 @@ mod tests { let intersection = FaceFaceIntersection::compute([&a, &b], &stores); let expected_curves = surfaces.map(|surface| { - Curve::partial(&stores, surface) + Curve::partial(surface) .as_line_from_points([[0., 0.], [1., 0.]]) - .build() + .build(&stores) }); let expected_intervals = CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 4f9f39b5d..86e838b9f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -186,8 +186,8 @@ mod tests { None, ); - let expected_xy = Curve::partial(&stores, xy).as_u_axis().build(); - let expected_xz = Curve::partial(&stores, xz).as_u_axis().build(); + let expected_xy = Curve::partial(xy).as_u_axis().build(&stores); + let expected_xz = Curve::partial(xz).as_u_axis().build(&stores); assert_eq!( SurfaceSurfaceIntersection::compute([&xy, &xz], &stores), diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index 1cf7d18de..b16786d5b 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -161,7 +161,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xz_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let vertex = Vertex::partial() .with_position([0.]) .with_curve(curve) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index a80fa656c..f4e9cd6ea 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -53,9 +53,9 @@ impl<'a> HalfEdgeBuilder<'a> { /// Build the [`HalfEdge`] as a circle from the given radius pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { - let curve = Curve::partial(self.stores, self.surface) + let curve = Curve::partial(self.surface) .as_circle_from_radius(radius) - .build(); + .build(self.stores); let vertices = { let [a_curve, b_curve] = diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 95045d02a..cd99d383b 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -362,7 +362,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let object = Curve::partial(&stores, surface).as_u_axis().build(); + let object = Curve::partial(surface).as_u_axis().build(&stores); assert_eq!(1, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); @@ -561,7 +561,7 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(&stores, surface).as_u_axis().build(); + let curve = Curve::partial(surface).as_u_axis().build(&stores); let global_vertex = GlobalVertex::from_position([0., 0., 0.]); let surface_vertex = SurfaceVertex::new([0., 0.], surface, global_vertex); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index ea963e7bf..42d91fe9b 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -1,7 +1,7 @@ use crate::{ partial::{PartialCurve, PartialGlobalCurve}, path::{GlobalPath, SurfacePath}, - stores::{Handle, Stores}, + stores::Handle, }; use super::Surface; @@ -16,9 +16,8 @@ pub struct Curve { impl Curve { /// Build a `Curve` using [`PartialCurve`] - pub fn partial(stores: &Stores, surface: Surface) -> PartialCurve { + pub fn partial(surface: Surface) -> PartialCurve { PartialCurve { - stores, path: None, surface, global_form: None, diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index c9cb31f94..c705d6d4a 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -9,10 +9,7 @@ use crate::{ /// API for building a [`Curve`] /// /// Also see [`Curve::builder`]. -pub struct PartialCurve<'a> { - /// The stores that the created objects are put in - pub stores: &'a Stores, - +pub struct PartialCurve { /// The path that defines the [`Curve`] /// /// Must be provided before calling [`PartialCurve::build`]. @@ -27,7 +24,7 @@ pub struct PartialCurve<'a> { pub global_form: Option, } -impl<'a> PartialCurve<'a> { +impl PartialCurve { /// Provide a path for the partial curve pub fn with_path(mut self, path: SurfacePath) -> Self { self.path = Some(path); @@ -79,12 +76,12 @@ impl<'a> PartialCurve<'a> { } /// Build a full [`Curve`] from the partial curve - pub fn build(self) -> Curve { + pub fn build(self, stores: &Stores) -> Curve { let path = self.path.expect("Can't build `Curve` without path"); let global_form = self .global_form .expect("Can't build `Curve` without a global form") - .build(self.stores); + .build(stores); Curve::new(self.surface, path, global_form) } From 8fa6bac5f23b72930c897d47348d7dded00ab8e2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:49:05 +0200 Subject: [PATCH 27/31] Make `surface` in `PartialCurve` optional --- .../fj-kernel/src/algorithms/approx/curve.rs | 12 +++++++---- .../src/algorithms/intersect/curve_edge.rs | 20 +++++++++++++++---- .../src/algorithms/intersect/curve_face.rs | 3 ++- .../src/algorithms/intersect/face_face.rs | 3 ++- .../algorithms/intersect/surface_surface.rs | 6 ++++-- .../fj-kernel/src/algorithms/sweep/vertex.rs | 5 ++++- crates/fj-kernel/src/builder/edge.rs | 3 ++- crates/fj-kernel/src/iter.rs | 10 ++++++++-- crates/fj-kernel/src/objects/curve.rs | 4 ++-- crates/fj-kernel/src/partial/curve.rs | 16 ++++++++++++--- 10 files changed, 61 insertions(+), 21 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curve.rs b/crates/fj-kernel/src/algorithms/approx/curve.rs index 18a22f9d2..b1b80628d 100644 --- a/crates/fj-kernel/src/algorithms/approx/curve.rs +++ b/crates/fj-kernel/src/algorithms/approx/curve.rs @@ -209,7 +209,8 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = Curve::partial(surface) + let curve = Curve::partial() + .with_surface(surface) .as_line_from_points([[1., 1.], [2., 1.]]) .build(&stores); let range = RangeOnPath::from([[0.], [1.]]); @@ -225,7 +226,8 @@ mod tests { let surface = Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]); - let curve = Curve::partial(surface) + let curve = Curve::partial() + .with_surface(surface) .as_line_from_points([[1., 1.], [1., 2.]]) .build(&stores); let range = RangeOnPath::from([[0.], [1.]]); @@ -241,7 +243,8 @@ mod tests { let path = GlobalPath::circle_from_radius(1.); let surface = Surface::new(path, [0., 0., 1.]); - let curve = Curve::partial(surface) + let curve = Curve::partial() + .with_surface(surface) .as_line_from_points([[0., 1.], [1., 1.]]) .build(&stores); @@ -269,7 +272,8 @@ mod tests { let stores = Stores::new(); let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]); - let curve = Curve::partial(surface) + let curve = Curve::partial() + .with_surface(surface) .as_circle_from_radius(1.) .build(&stores); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index 8dcdb6981..76cf88a13 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -86,7 +86,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[1., -1.], [1., 1.]]) .build(); @@ -106,7 +109,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [-1., 1.]]) .build(); @@ -126,7 +132,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., -1.], [1., -1.]]) .build(); @@ -141,7 +150,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let half_edge = HalfEdge::builder(&stores, surface) .as_line_segment_from_points([[-1., 0.], [1., 0.]]) .build(); diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index b8af458a1..b0b461a2f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -168,7 +168,8 @@ mod tests { let surface = Surface::xy_plane(); - let curve = Curve::partial(surface) + let curve = Curve::partial() + .with_surface(surface) .as_line_from_points([[-3., 0.], [-2., 0.]]) .build(&stores); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 923f862b3..a0708fee9 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -114,7 +114,8 @@ mod tests { let intersection = FaceFaceIntersection::compute([&a, &b], &stores); let expected_curves = surfaces.map(|surface| { - Curve::partial(surface) + Curve::partial() + .with_surface(surface) .as_line_from_points([[0., 0.], [1., 0.]]) .build(&stores) }); diff --git a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs index 86e838b9f..895168a8d 100644 --- a/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs +++ b/crates/fj-kernel/src/algorithms/intersect/surface_surface.rs @@ -186,8 +186,10 @@ mod tests { None, ); - let expected_xy = Curve::partial(xy).as_u_axis().build(&stores); - let expected_xz = Curve::partial(xz).as_u_axis().build(&stores); + let expected_xy = + Curve::partial().with_surface(xy).as_u_axis().build(&stores); + let expected_xz = + Curve::partial().with_surface(xz).as_u_axis().build(&stores); assert_eq!( SurfaceSurfaceIntersection::compute([&xy, &xz], &stores), diff --git a/crates/fj-kernel/src/algorithms/sweep/vertex.rs b/crates/fj-kernel/src/algorithms/sweep/vertex.rs index b16786d5b..d0dcf535f 100644 --- a/crates/fj-kernel/src/algorithms/sweep/vertex.rs +++ b/crates/fj-kernel/src/algorithms/sweep/vertex.rs @@ -161,7 +161,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xz_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let vertex = Vertex::partial() .with_position([0.]) .with_curve(curve) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index f4e9cd6ea..983706969 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -53,7 +53,8 @@ impl<'a> HalfEdgeBuilder<'a> { /// Build the [`HalfEdge`] as a circle from the given radius pub fn as_circle_from_radius(mut self, radius: impl Into) -> Self { - let curve = Curve::partial(self.surface) + let curve = Curve::partial() + .with_surface(self.surface) .as_circle_from_radius(radius) .build(self.stores); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index cd99d383b..aff05ce1c 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -362,7 +362,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let object = Curve::partial(surface).as_u_axis().build(&stores); + let object = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); assert_eq!(1, object.curve_iter().count()); assert_eq!(0, object.cycle_iter().count()); @@ -561,7 +564,10 @@ mod tests { let stores = Stores::new(); let surface = Surface::xy_plane(); - let curve = Curve::partial(surface).as_u_axis().build(&stores); + let curve = Curve::partial() + .with_surface(surface) + .as_u_axis() + .build(&stores); let global_vertex = GlobalVertex::from_position([0., 0., 0.]); let surface_vertex = SurfaceVertex::new([0., 0.], surface, global_vertex); diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index 42d91fe9b..a52feaa13 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -16,10 +16,10 @@ pub struct Curve { impl Curve { /// Build a `Curve` using [`PartialCurve`] - pub fn partial(surface: Surface) -> PartialCurve { + pub fn partial() -> PartialCurve { PartialCurve { path: None, - surface, + surface: None, global_form: None, } } diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index c705d6d4a..45bf6aa41 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -16,7 +16,7 @@ pub struct PartialCurve { pub path: Option, /// The surface that the [`Curve`] is defined in - pub surface: Surface, + pub surface: Option, /// The global form of the [`Curve`] /// @@ -31,6 +31,12 @@ impl PartialCurve { self } + /// Provide a surface for the partial curve + pub fn with_surface(mut self, surface: Surface) -> Self { + self.surface = Some(surface); + self + } + /// Provide a global form for the partial curve pub fn with_global_form(mut self, global_form: PartialGlobalCurve) -> Self { self.global_form = Some(global_form); @@ -65,9 +71,11 @@ impl PartialCurve { /// Update partial curve as a line, from the provided points pub fn as_line_from_points(self, points: [impl Into>; 2]) -> Self { + let surface = self.surface.expect("Can't build line without surface"); + let points_surface = points.map(Into::into); let points_global = points_surface - .map(|point| self.surface.point_from_surface_coords(point)); + .map(|point| surface.point_from_surface_coords(point)); self.with_path(SurfacePath::line_from_points(points_surface)) .with_global_form( @@ -78,12 +86,14 @@ impl PartialCurve { /// Build a full [`Curve`] from the partial curve pub fn build(self, stores: &Stores) -> Curve { let path = self.path.expect("Can't build `Curve` without path"); + let surface = + self.surface.expect("Can't build `Curve` without surface"); let global_form = self .global_form .expect("Can't build `Curve` without a global form") .build(stores); - Curve::new(self.surface, path, global_form) + Curve::new(surface, path, global_form) } } From 659fa9aa20d56a64d2ca542208893e53184a457f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:49:59 +0200 Subject: [PATCH 28/31] Derive `Default` for `PartialCurve` --- crates/fj-kernel/src/objects/curve.rs | 6 +----- crates/fj-kernel/src/partial/curve.rs | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index a52feaa13..da161aab1 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -17,11 +17,7 @@ pub struct Curve { impl Curve { /// Build a `Curve` using [`PartialCurve`] pub fn partial() -> PartialCurve { - PartialCurve { - path: None, - surface: None, - global_form: None, - } + PartialCurve::default() } /// Construct a new instance of `Curve` diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 45bf6aa41..219389331 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -9,6 +9,7 @@ use crate::{ /// API for building a [`Curve`] /// /// Also see [`Curve::builder`]. +#[derive(Default)] pub struct PartialCurve { /// The path that defines the [`Curve`] /// From fe2ac53cdcc2527e586c11231bf86f92c7892c3a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:52:24 +0200 Subject: [PATCH 29/31] Update documentation of `PartialCurve` --- crates/fj-kernel/src/objects/curve.rs | 5 ++++- crates/fj-kernel/src/partial/curve.rs | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/objects/curve.rs b/crates/fj-kernel/src/objects/curve.rs index da161aab1..d65b1702c 100644 --- a/crates/fj-kernel/src/objects/curve.rs +++ b/crates/fj-kernel/src/objects/curve.rs @@ -15,7 +15,10 @@ pub struct Curve { } impl Curve { - /// Build a `Curve` using [`PartialCurve`] + /// Create a [`PartialCurve`] + /// + /// This function exists just for convenience, and will just return a + /// default [`PartialCurve`]. pub fn partial() -> PartialCurve { PartialCurve::default() } diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 219389331..567dc5288 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -6,9 +6,9 @@ use crate::{ stores::{Handle, Stores}, }; -/// API for building a [`Curve`] +/// A partial [`Curve`] /// -/// Also see [`Curve::builder`]. +/// See [`crate::partial`] for more information. #[derive(Default)] pub struct PartialCurve { /// The path that defines the [`Curve`] @@ -17,6 +17,8 @@ pub struct PartialCurve { pub path: Option, /// The surface that the [`Curve`] is defined in + /// + /// Must be provided before calling [`PartialCurve::build`]. pub surface: Option, /// The global form of the [`Curve`] From da6ff4f522267e5c29165941883994b777128740 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:57:54 +0200 Subject: [PATCH 30/31] Compute global form in `PartialCurve::build` --- crates/fj-kernel/src/partial/curve.rs | 31 +++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 567dc5288..74f30da26 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -23,7 +23,8 @@ pub struct PartialCurve { /// The global form of the [`Curve`] /// - /// Must be provided before calling [`PartialCurve::build`]. + /// Will be computed from `path` and `surface` in [`PartialCurve::build`], + /// if not provided. pub global_form: Option, } @@ -65,25 +66,13 @@ impl PartialCurve { /// Update partial curve as a circle, from the provided radius pub fn as_circle_from_radius(self, radius: impl Into) -> Self { let radius = radius.into(); - self.with_path(SurfacePath::circle_from_radius(radius)) - .with_global_form( - GlobalCurve::partial().as_circle_from_radius(radius), - ) } /// Update partial curve as a line, from the provided points pub fn as_line_from_points(self, points: [impl Into>; 2]) -> Self { - let surface = self.surface.expect("Can't build line without surface"); - let points_surface = points.map(Into::into); - let points_global = points_surface - .map(|point| surface.point_from_surface_coords(point)); - self.with_path(SurfacePath::line_from_points(points_surface)) - .with_global_form( - GlobalCurve::partial().as_line_from_points(points_global), - ) } /// Build a full [`Curve`] from the partial curve @@ -91,9 +80,23 @@ impl PartialCurve { let path = self.path.expect("Can't build `Curve` without path"); let surface = self.surface.expect("Can't build `Curve` without surface"); + let global_form = self .global_form - .expect("Can't build `Curve` without a global form") + .unwrap_or_else(|| { + let path = match path { + SurfacePath::Circle(circle) => { + GlobalPath::circle_from_radius(circle.radius()) + } + SurfacePath::Line(line) => GlobalPath::line_from_points( + [line.origin(), line.origin() + line.direction()].map( + |point| surface.point_from_surface_coords(point), + ), + ), + }; + + GlobalCurve::partial().with_path(path) + }) .build(stores); Curve::new(surface, path, global_form) From cf9c3264a9bc0c3c4b89df977e1e5653a3a22300 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 22 Sep 2022 16:58:44 +0200 Subject: [PATCH 31/31] Refactor --- crates/fj-kernel/src/partial/curve.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/partial/curve.rs b/crates/fj-kernel/src/partial/curve.rs index 74f30da26..f56a5c953 100644 --- a/crates/fj-kernel/src/partial/curve.rs +++ b/crates/fj-kernel/src/partial/curve.rs @@ -65,14 +65,12 @@ impl PartialCurve { /// Update partial curve as a circle, from the provided radius pub fn as_circle_from_radius(self, radius: impl Into) -> Self { - let radius = radius.into(); self.with_path(SurfacePath::circle_from_radius(radius)) } /// Update partial curve as a line, from the provided points pub fn as_line_from_points(self, points: [impl Into>; 2]) -> Self { - let points_surface = points.map(Into::into); - self.with_path(SurfacePath::line_from_points(points_surface)) + self.with_path(SurfacePath::line_from_points(points)) } /// Build a full [`Curve`] from the partial curve