From 27c8030c5fd09ad3c8f2a4aa0a2691923aea50cf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:26:08 +0200 Subject: [PATCH 1/8] Refactor --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 914dabeb1..6e7bb8215 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -1,5 +1,5 @@ use fj_interop::mesh::Color; -use fj_math::{Line, Point, Scalar, Transform, Triangle}; +use fj_math::{Line, Scalar, Transform, Triangle}; use crate::{ algorithms::{ @@ -83,8 +83,8 @@ fn create_non_continuous_side_face( let top_edge = { let bottom_vertices = bottom_edge.vertices().get_or_panic(); - let points_surface = bottom_vertices - .map(|vertex| Point::from([vertex.position().t, Scalar::ONE])); + let points_surface = + bottom_vertices.map(|vertex| [vertex.position().t, Scalar::ONE]); let global_vertices = side_edges.map(|edge| { let [_, vertex] = edge.vertices().get_or_panic(); From da971a364d2111660763303f089c8cfbc6f351d0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:28:59 +0200 Subject: [PATCH 2/8] Refactor --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 6e7bb8215..d87bebc58 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -83,8 +83,9 @@ fn create_non_continuous_side_face( let top_edge = { let bottom_vertices = bottom_edge.vertices().get_or_panic(); - let points_surface = - bottom_vertices.map(|vertex| [vertex.position().t, Scalar::ONE]); + let points_surface = bottom_vertices.map(|vertex| { + (vertex.position(), [vertex.position().t, Scalar::ONE]) + }); let global_vertices = side_edges.map(|edge| { let [_, vertex] = edge.vertices().get_or_panic(); @@ -94,7 +95,6 @@ fn create_non_continuous_side_face( let curve = { let [a_curve, b_curve] = bottom_vertices.map(|vertex| vertex.position()); - let [a_surface, b_surface] = points_surface; let [a_global, b_global] = global_vertices.map(|vertex| vertex.position()); @@ -107,10 +107,7 @@ fn create_non_continuous_side_face( GlobalCurve::from_kind(CurveKind::Line(line)) }; - let line = Line::from_points_with_line_coords([ - (a_curve, a_surface), - (b_curve, b_surface), - ]); + let line = Line::from_points_with_line_coords(points_surface); Curve::new(surface, CurveKind::Line(line), global) }; From 32c47101094b008f281ce2787a1023d1fe803bbe Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:30:06 +0200 Subject: [PATCH 3/8] Move variable definition to where it is used --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index d87bebc58..794629c83 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -83,9 +83,6 @@ fn create_non_continuous_side_face( let top_edge = { let bottom_vertices = bottom_edge.vertices().get_or_panic(); - let points_surface = bottom_vertices.map(|vertex| { - (vertex.position(), [vertex.position().t, Scalar::ONE]) - }); let global_vertices = side_edges.map(|edge| { let [_, vertex] = edge.vertices().get_or_panic(); @@ -107,6 +104,9 @@ fn create_non_continuous_side_face( GlobalCurve::from_kind(CurveKind::Line(line)) }; + let points_surface = bottom_vertices.map(|vertex| { + (vertex.position(), [vertex.position().t, Scalar::ONE]) + }); let line = Line::from_points_with_line_coords(points_surface); Curve::new(surface, CurveKind::Line(line), global) From b6d78e3118eb53b8b83f2da3a72dac96319f61d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:30:33 +0200 Subject: [PATCH 4/8] Simplify variable name --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 794629c83..b82926b3a 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -104,10 +104,10 @@ fn create_non_continuous_side_face( GlobalCurve::from_kind(CurveKind::Line(line)) }; - let points_surface = bottom_vertices.map(|vertex| { + let points = bottom_vertices.map(|vertex| { (vertex.position(), [vertex.position().t, Scalar::ONE]) }); - let line = Line::from_points_with_line_coords(points_surface); + let line = Line::from_points_with_line_coords(points); Curve::new(surface, CurveKind::Line(line), global) }; From 1abc26447018bc47da3f6819bb2aa4c2912611d7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:31:01 +0200 Subject: [PATCH 5/8] Reduce scope of variables --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index b82926b3a..09ae5ff0a 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -90,12 +90,12 @@ fn create_non_continuous_side_face( }); let curve = { - let [a_curve, b_curve] = - bottom_vertices.map(|vertex| vertex.position()); - let [a_global, b_global] = - global_vertices.map(|vertex| vertex.position()); - let global = { + let [a_curve, b_curve] = + bottom_vertices.map(|vertex| vertex.position()); + let [a_global, b_global] = + global_vertices.map(|vertex| vertex.position()); + let line = Line::from_points_with_line_coords([ (a_curve, a_global), (b_curve, b_global), From 8bcf32ebe8cf5dc07042109f18afc49630c10975 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 14:47:53 +0200 Subject: [PATCH 6/8] Refactor --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 09ae5ff0a..6b412d0fd 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -107,9 +107,10 @@ fn create_non_continuous_side_face( let points = bottom_vertices.map(|vertex| { (vertex.position(), [vertex.position().t, Scalar::ONE]) }); - let line = Line::from_points_with_line_coords(points); + let kind = + CurveKind::Line(Line::from_points_with_line_coords(points)); - Curve::new(surface, CurveKind::Line(line), global) + Curve::new(surface, kind, global) }; let global = { From ac31a3669b12bc2e1373f567667fb719b3405c45 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 15:11:37 +0200 Subject: [PATCH 7/8] Add comments --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 6b412d0fd..4da33b538 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -57,6 +57,9 @@ fn create_non_continuous_side_face( let vertices = edge.vertices().get_or_panic(); let curve = { + // Please note that creating a line here is correct, even if the + // global curve is a circle. Projected into the side surface, it is + // going to be a line either way. let points = vertices.map(|vertex| { (vertex.position(), [vertex.position().t, Scalar::ZERO]) }); @@ -104,6 +107,9 @@ fn create_non_continuous_side_face( GlobalCurve::from_kind(CurveKind::Line(line)) }; + // Please note that creating a line here is correct, even if the + // global curve is a circle. Projected into the side surface, it is + // going to be a line either way. let points = bottom_vertices.map(|vertex| { (vertex.position(), [vertex.position().t, Scalar::ONE]) }); From ffb2a97e14cc766644fa7152c4059224325c4833 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 5 Sep 2022 15:30:55 +0200 Subject: [PATCH 8/8] Simplify global curve calculation This also removes the assumption that the curve must be a line, which only holds as long as there are no edges defined by circles, that are also bound by vertices. --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index 4da33b538..bb90ad64b 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -5,10 +5,11 @@ use crate::{ algorithms::{ approx::{Approx, Tolerance}, reverse::Reverse, + transform::TransformObject, }, objects::{ - Curve, CurveKind, Cycle, Edge, Face, GlobalCurve, GlobalEdge, Surface, - Vertex, VerticesOfEdge, + Curve, CurveKind, Cycle, Edge, Face, GlobalEdge, Surface, Vertex, + VerticesOfEdge, }, }; @@ -93,19 +94,7 @@ fn create_non_continuous_side_face( }); let curve = { - let global = { - let [a_curve, b_curve] = - bottom_vertices.map(|vertex| vertex.position()); - let [a_global, b_global] = - global_vertices.map(|vertex| vertex.position()); - - let line = Line::from_points_with_line_coords([ - (a_curve, a_global), - (b_curve, b_global), - ]); - - GlobalCurve::from_kind(CurveKind::Line(line)) - }; + let global = bottom_edge.curve().global().translate(path.inner()); // Please note that creating a line here is correct, even if the // global curve is a circle. Projected into the side surface, it is