From 1e454edc4d01935c5b67f82472aece45caaba9e9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 25 Aug 2022 16:28:52 +0200 Subject: [PATCH 1/4] Refactor --- crates/fj-kernel/src/builder/edge.rs | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 941ec97fc..1a972eb10 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -20,22 +20,23 @@ impl EdgeBuilder { /// Create a circle from the given radius pub fn circle_from_radius(&self, radius: Scalar) -> Edge { - let curve_local = CurveKind::Circle(Circle::new( - Point::origin(), - Vector::from([radius, Scalar::ZERO]), - Vector::from([Scalar::ZERO, radius]), - )); - let curve_global = - GlobalCurve::from_kind(CurveKind::Circle(Circle::new( + let curve = { + let curve_local = CurveKind::Circle(Circle::new( Point::origin(), - Vector::from([radius, Scalar::ZERO, Scalar::ZERO]), - Vector::from([Scalar::ZERO, radius, Scalar::ZERO]), - ))); + Vector::from([radius, Scalar::ZERO]), + Vector::from([Scalar::ZERO, radius]), + )); + let curve_global = + GlobalCurve::from_kind(CurveKind::Circle(Circle::new( + Point::origin(), + Vector::from([radius, Scalar::ZERO, Scalar::ZERO]), + Vector::from([Scalar::ZERO, radius, Scalar::ZERO]), + ))); + + Curve::new(self.surface, curve_local, curve_global) + }; - Edge::from_curve_and_vertices( - Curve::new(self.surface, curve_local, curve_global), - VerticesOfEdge::none(), - ) + Edge::from_curve_and_vertices(curve, VerticesOfEdge::none()) } /// Create a line segment from two points From 31ee263333969f77b73685c28dd2536bea738a33 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 25 Aug 2022 16:29:07 +0200 Subject: [PATCH 2/4] Simplify variable names --- crates/fj-kernel/src/builder/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 1a972eb10..e5a7c4625 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -21,19 +21,19 @@ impl EdgeBuilder { /// Create a circle from the given radius pub fn circle_from_radius(&self, radius: Scalar) -> Edge { let curve = { - let curve_local = CurveKind::Circle(Circle::new( + let local = CurveKind::Circle(Circle::new( Point::origin(), Vector::from([radius, Scalar::ZERO]), Vector::from([Scalar::ZERO, radius]), )); - let curve_global = + let global = GlobalCurve::from_kind(CurveKind::Circle(Circle::new( Point::origin(), Vector::from([radius, Scalar::ZERO, Scalar::ZERO]), Vector::from([Scalar::ZERO, radius, Scalar::ZERO]), ))); - Curve::new(self.surface, curve_local, curve_global) + Curve::new(self.surface, local, global) }; Edge::from_curve_and_vertices(curve, VerticesOfEdge::none()) From bf20515a9a391072559a36384cf27c8c7b13682c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 25 Aug 2022 16:29:59 +0200 Subject: [PATCH 3/4] Refactor --- crates/fj-kernel/src/builder/edge.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index e5a7c4625..2379091bb 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -36,7 +36,9 @@ impl EdgeBuilder { Curve::new(self.surface, local, global) }; - Edge::from_curve_and_vertices(curve, VerticesOfEdge::none()) + let vertices = VerticesOfEdge::none(); + + Edge::from_curve_and_vertices(curve, vertices) } /// Create a line segment from two points From 6d410f4bbc252211e936aa6afc9f94cd025ee665 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Sep 2022 14:53:00 +0200 Subject: [PATCH 4/4] Fix dodgy assumption in edge sweeping code --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 0a5ab39a4..bb63a6064 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -186,7 +186,10 @@ fn create_non_continuous_side_face( let [_, prev_last] = edges[i].vertices().get_or_panic(); let [next_first, _] = edges[j].vertices().get_or_panic(); - if prev_last.global_form() != next_first.global_form() { + // Need to compare surface forms here, as the global forms might be + // coincident when sweeping circles, despite the vertices being + // different! + if prev_last.surface_form() != next_first.surface_form() { edges[j] = edges[j].reverse(); }