From 6ae8488ace4d6e26c7dd0561e26cbad957ab4464 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:13:15 +0100 Subject: [PATCH 01/17] Simplify `CurveBuilder` methods --- crates/fj-kernel/src/builder/curve.rs | 30 +++++++-------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/crates/fj-kernel/src/builder/curve.rs b/crates/fj-kernel/src/builder/curve.rs index cc904b321..9f03f186d 100644 --- a/crates/fj-kernel/src/builder/curve.rs +++ b/crates/fj-kernel/src/builder/curve.rs @@ -5,52 +5,38 @@ use crate::{geometry::path::SurfacePath, partial::PartialCurve}; /// Builder API for [`PartialCurve`] pub trait CurveBuilder { /// Update partial curve to represent the u-axis of the surface it is on - fn update_as_u_axis(&mut self) -> &mut Self; + fn update_as_u_axis(&mut self); /// Update partial curve to represent the v-axis of the surface it is on - fn update_as_v_axis(&mut self) -> &mut Self; + fn update_as_v_axis(&mut self); /// Update partial curve to be a circle, from the provided radius - fn update_as_circle_from_radius( - &mut self, - radius: impl Into, - ) -> &mut Self; + fn update_as_circle_from_radius(&mut self, radius: impl Into); /// Update partial curve to be a line, from the provided points - fn update_as_line_from_points( - &mut self, - points: [impl Into>; 2], - ) -> &mut Self; + fn update_as_line_from_points(&mut self, points: [impl Into>; 2]); } impl CurveBuilder for PartialCurve { - fn update_as_u_axis(&mut self) -> &mut Self { + fn update_as_u_axis(&mut self) { let a = Point::origin(); let b = a + Vector::unit_u(); self.update_as_line_from_points([a, b]) } - fn update_as_v_axis(&mut self) -> &mut Self { + fn update_as_v_axis(&mut self) { let a = Point::origin(); let b = a + Vector::unit_v(); self.update_as_line_from_points([a, b]) } - fn update_as_circle_from_radius( - &mut self, - radius: impl Into, - ) -> &mut Self { + fn update_as_circle_from_radius(&mut self, radius: impl Into) { self.path = Some(SurfacePath::circle_from_radius(radius)); - self } - fn update_as_line_from_points( - &mut self, - points: [impl Into>; 2], - ) -> &mut Self { + fn update_as_line_from_points(&mut self, points: [impl Into>; 2]) { self.path = Some(SurfacePath::line_from_points(points)); - self } } From ff307430c01ba80a02d06210c89ff360b40f5147 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:15:23 +0100 Subject: [PATCH 02/17] Simplify `SurfaceVertexBuilder` method --- crates/fj-kernel/src/builder/vertex.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index dcf1bac7a..8d856d701 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -13,11 +13,11 @@ impl VertexBuilder for PartialVertex {} /// Builder API for [`PartialSurfaceVertex`] pub trait SurfaceVertexBuilder { /// Infer the position of the surface vertex' global form - fn infer_global_position(&mut self) -> &mut Self; + fn infer_global_position(&mut self); } impl SurfaceVertexBuilder for PartialSurfaceVertex { - fn infer_global_position(&mut self) -> &mut Self { + fn infer_global_position(&mut self) { let position = self .position .expect("Can't infer global position without surface position"); @@ -29,8 +29,6 @@ impl SurfaceVertexBuilder for PartialSurfaceVertex { self.global_form.write().position = Some(surface.point_from_surface_coords(position)); - - self } } From 77d119712dbd47a88659d8fa18f547832b88aa0d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:17:16 +0100 Subject: [PATCH 03/17] Simplify `HalfEdgeBuilder` methods --- crates/fj-kernel/src/builder/edge.rs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 9df0a0caf..a12dbb0ca 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -11,27 +11,21 @@ use super::{CurveBuilder, SurfaceVertexBuilder}; /// Builder API for [`PartialHalfEdge`] pub trait HalfEdgeBuilder { /// Update partial half-edge to be a circle, from the given radius - fn update_as_circle_from_radius( - &mut self, - radius: impl Into, - ) -> &mut Self; + fn update_as_circle_from_radius(&mut self, radius: impl Into); /// Update partial half-edge to be a line segment, from the given points fn update_as_line_segment_from_points( &mut self, surface: Partial, points: [impl Into>; 2], - ) -> &mut Self; + ); /// Update partial half-edge to be a line segment - fn update_as_line_segment(&mut self) -> &mut Self; + fn update_as_line_segment(&mut self); } impl HalfEdgeBuilder for PartialHalfEdge { - fn update_as_circle_from_radius( - &mut self, - radius: impl Into, - ) -> &mut Self { + fn update_as_circle_from_radius(&mut self, radius: impl Into) { let mut curve = self.curve(); curve.write().update_as_circle_from_radius(radius); @@ -61,15 +55,13 @@ impl HalfEdgeBuilder for PartialHalfEdge { let global_vertex = surface_vertex.read().global_form.clone(); self.global_form.write().vertices = [global_vertex.clone(), global_vertex]; - - self } fn update_as_line_segment_from_points( &mut self, surface: Partial, points: [impl Into>; 2], - ) -> &mut Self { + ) { for (vertex, point) in self.vertices.each_mut_ext().zip_ext(points) { let mut vertex = vertex.write(); vertex.curve.write().surface = surface.clone(); @@ -83,7 +75,7 @@ impl HalfEdgeBuilder for PartialHalfEdge { self.update_as_line_segment() } - fn update_as_line_segment(&mut self) -> &mut Self { + fn update_as_line_segment(&mut self) { let points_surface = self.vertices.each_ref_ext().map(|vertex| { vertex .read() @@ -103,8 +95,6 @@ impl HalfEdgeBuilder for PartialHalfEdge { } self.global_form.write().curve = curve.read().global_form.clone(); - - self } } From 676120dbb75e15fb5cc339b3c24fcb14d393df0e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:21:08 +0100 Subject: [PATCH 04/17] Make variable name more explicit --- crates/fj-kernel/src/builder/vertex.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index 8d856d701..352b6d269 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -18,7 +18,7 @@ pub trait SurfaceVertexBuilder { impl SurfaceVertexBuilder for PartialSurfaceVertex { fn infer_global_position(&mut self) { - let position = self + let position_surface = self .position .expect("Can't infer global position without surface position"); let surface = self @@ -28,7 +28,7 @@ impl SurfaceVertexBuilder for PartialSurfaceVertex { .expect("Can't infer global position without surface geometry"); self.global_form.write().position = - Some(surface.point_from_surface_coords(position)); + Some(surface.point_from_surface_coords(position_surface)); } } From c7c9beb221763616d2fec8721987fb60885629d7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:21:55 +0100 Subject: [PATCH 05/17] Return inferred global position --- crates/fj-kernel/src/builder/vertex.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index 352b6d269..533100404 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -1,3 +1,5 @@ +use fj_math::Point; + use crate::partial::{ PartialGlobalVertex, PartialSurfaceVertex, PartialVertex, }; @@ -13,11 +15,11 @@ impl VertexBuilder for PartialVertex {} /// Builder API for [`PartialSurfaceVertex`] pub trait SurfaceVertexBuilder { /// Infer the position of the surface vertex' global form - fn infer_global_position(&mut self); + fn infer_global_position(&mut self) -> Point<3>; } impl SurfaceVertexBuilder for PartialSurfaceVertex { - fn infer_global_position(&mut self) { + fn infer_global_position(&mut self) -> Point<3> { let position_surface = self .position .expect("Can't infer global position without surface position"); @@ -27,8 +29,11 @@ impl SurfaceVertexBuilder for PartialSurfaceVertex { .geometry .expect("Can't infer global position without surface geometry"); - self.global_form.write().position = - Some(surface.point_from_surface_coords(position_surface)); + let position_global = + surface.point_from_surface_coords(position_surface); + self.global_form.write().position = Some(position_global); + + position_global } } From 18a3782cde98e3d9e6effe059d22aae1568379a8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:24:09 +0100 Subject: [PATCH 06/17] Update doc comment --- crates/fj-kernel/src/builder/vertex.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index 533100404..6f26651ac 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -15,6 +15,9 @@ impl VertexBuilder for PartialVertex {} /// Builder API for [`PartialSurfaceVertex`] pub trait SurfaceVertexBuilder { /// Infer the position of the surface vertex' global form + /// + /// Updates the global vertex referenced by this surface vertex with the + /// inferred position, and also returns the position. fn infer_global_position(&mut self) -> Point<3>; } From 899ad93689fa44e28b78ca6fb334f8bc677050a7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:26:21 +0100 Subject: [PATCH 07/17] Defer building object --- crates/fj-kernel/src/builder/shell.rs | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 1b30d88de..0727c0be5 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -6,7 +6,9 @@ use iter_fixed::IntoIteratorFixed; use crate::{ algorithms::transform::TransformObject, - builder::{FaceBuilder, HalfEdgeBuilder, SurfaceBuilder}, + builder::{ + FaceBuilder, HalfEdgeBuilder, SurfaceBuilder, SurfaceVertexBuilder, + }, insert::Insert, objects::{Face, FaceSet, HalfEdge, Objects, Shell, Vertex}, partial::{ @@ -52,24 +54,27 @@ impl ShellBuilder { let surface = objects.surfaces.xy_plane().translate([Z, Z, -h], objects); - PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-h, -h], [h, -h], [h, h], [-h, h]], - ) - .build(objects) - .insert(objects) + PartialFace::default().with_exterior_polygon_from_points( + surface, + [[-h, -h], [h, -h], [h, h], [-h, h]], + ) }; let (sides, top_edges) = { let surfaces = bottom - .exterior() - .half_edges() + .exterior + .read() + .half_edges + .iter() .map(|half_edge| { - let [a, b] = half_edge - .vertices() - .clone() - .map(|vertex| vertex.global_form().position()); + let [a, b] = + half_edge.read().vertices.clone().map(|mut vertex| { + vertex + .write() + .surface_form + .write() + .infer_global_position() + }); let c = a + [Z, Z, edge_length]; PartialSurface::plane_from_points([a, b, c]) @@ -79,23 +84,22 @@ impl ShellBuilder { .collect::>(); let bottoms = bottom - .exterior() - .half_edges() + .exterior + .read() + .half_edges + .iter() .zip(&surfaces) .map(|(half_edge, surface)| { - let global_edge = Partial::from_full_entry_point( - half_edge.global_form().clone(), - ) - .read() - .clone(); + let global_edge = half_edge.read().global_form.clone(); let mut half_edge = PartialHalfEdge { - vertices: global_edge.vertices.clone().map( + vertices: global_edge.read().vertices.clone().map( |global_vertex| { Partial::from_partial(PartialVertex { curve: Partial::from_partial( PartialCurve { global_form: global_edge + .read() .curve .clone(), ..Default::default() @@ -112,8 +116,8 @@ impl ShellBuilder { }, ), global_form: Partial::from_partial(PartialGlobalEdge { - curve: global_edge.curve, - vertices: global_edge.vertices, + curve: global_edge.read().curve.clone(), + vertices: global_edge.read().vertices.clone(), }), }; half_edge.update_as_line_segment_from_points( @@ -456,7 +460,7 @@ impl ShellBuilder { face.build(objects).insert(objects) }; - self.faces.extend([bottom]); + self.faces.extend([bottom.build(objects).insert(objects)]); self.faces.extend(sides); self.faces.extend([top]); From bcfdfe85388f9f3404ac8453dbe30c9fe85db0b4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:28:12 +0100 Subject: [PATCH 08/17] Remove redundant `build` call --- crates/fj-kernel/src/builder/shell.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 0727c0be5..acd8cc4dd 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -78,8 +78,6 @@ impl ShellBuilder { let c = a + [Z, Z, edge_length]; PartialSurface::plane_from_points([a, b, c]) - .build(objects) - .insert(objects) }) .collect::>(); @@ -121,7 +119,7 @@ impl ShellBuilder { }), }; half_edge.update_as_line_segment_from_points( - Partial::from_full_entry_point(surface.clone()), + Partial::from_partial(surface.clone()), [[Z, Z], [edge_length, Z]], ); @@ -141,9 +139,7 @@ impl ShellBuilder { position: Some( from.read().position.unwrap() + [Z, edge_length], ), - surface: Partial::from_full_entry_point( - surface.clone(), - ), + surface: Partial::from_partial(surface.clone()), ..Default::default() }; @@ -218,9 +214,7 @@ impl ShellBuilder { to.read().position.unwrap() + [Z, edge_length], ), - surface: Partial::from_full_entry_point( - surface.clone(), - ), + surface: Partial::from_partial(surface.clone()), global_form: from .read() .surface_form From b8d94ad3b9d57312a75db7c9ad5e7996d90edd9b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:31:43 +0100 Subject: [PATCH 09/17] Only create `Partial` once --- crates/fj-kernel/src/builder/shell.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index acd8cc4dd..4d37c3c5b 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -77,7 +77,9 @@ impl ShellBuilder { }); let c = a + [Z, Z, edge_length]; - PartialSurface::plane_from_points([a, b, c]) + Partial::from_partial(PartialSurface::plane_from_points([ + a, b, c, + ])) }) .collect::>(); @@ -119,7 +121,7 @@ impl ShellBuilder { }), }; half_edge.update_as_line_segment_from_points( - Partial::from_partial(surface.clone()), + surface.clone(), [[Z, Z], [edge_length, Z]], ); @@ -139,7 +141,7 @@ impl ShellBuilder { position: Some( from.read().position.unwrap() + [Z, edge_length], ), - surface: Partial::from_partial(surface.clone()), + surface: surface.clone(), ..Default::default() }; @@ -214,7 +216,7 @@ impl ShellBuilder { to.read().position.unwrap() + [Z, edge_length], ), - surface: Partial::from_partial(surface.clone()), + surface: surface.clone(), global_form: from .read() .surface_form From 953e8aaf113b2eb662cb78ecfbdb602bab48a135 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:34:52 +0100 Subject: [PATCH 10/17] Defer building object --- crates/fj-kernel/src/builder/shell.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 4d37c3c5b..85fecbcf5 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -352,11 +352,10 @@ impl ShellBuilder { let mut cycle = PartialCycle::default(); cycle.half_edges.extend([bottom, side_up, top, side_down]); - let face = PartialFace { + PartialFace { exterior: Partial::from_partial(cycle), ..Default::default() - }; - face.build(objects).insert(objects) + } }) .collect::>(); @@ -457,7 +456,12 @@ impl ShellBuilder { }; self.faces.extend([bottom.build(objects).insert(objects)]); - self.faces.extend(sides); + self.faces.extend( + sides + .iter() + .cloned() + .map(|face| face.build(objects).insert(objects)), + ); self.faces.extend([top]); self From fcbecdf4ad240dfb3b9b905d894bd4c2c026798d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 18:58:01 +0100 Subject: [PATCH 11/17] Defer building object --- crates/fj-kernel/src/builder/shell.rs | 46 +++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 85fecbcf5..d276b1fc1 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -10,7 +10,7 @@ use crate::{ FaceBuilder, HalfEdgeBuilder, SurfaceBuilder, SurfaceVertexBuilder, }, insert::Insert, - objects::{Face, FaceSet, HalfEdge, Objects, Shell, Vertex}, + objects::{Face, FaceSet, HalfEdge, Objects, Shell, SurfaceVertex, Vertex}, partial::{ Partial, PartialCurve, PartialCycle, PartialFace, PartialGlobalEdge, PartialHalfEdge, PartialObject, PartialSurface, PartialSurfaceVertex, @@ -388,15 +388,13 @@ impl ShellBuilder { .global_form .clone(); - PartialSurfaceVertex { + Partial::from_partial(PartialSurfaceVertex { position: Some(point.into()), surface: Partial::from_full_entry_point( surface.clone(), ), global_form: global_vertex, - } - .build(objects) - .insert(objects) + }) }); [a.clone(), b, c, d, a] @@ -417,24 +415,26 @@ impl ShellBuilder { .into_iter_fixed() .zip(surface_vertices.clone()) .collect::<[_; 2]>() - .map(|(vertex, surface_form)| PartialVertex { - position: vertex.read().position, - curve: Partial::from_partial(PartialCurve { - surface: Partial::from_full_entry_point( - surface_form.surface().clone(), - ), - global_form: vertex - .read() - .curve - .read() - .global_form - .clone(), - ..Default::default() - }), - surface_form: Partial::from_full_entry_point( - surface_form, - ), - }); + .map( + |(vertex, surface_form): ( + _, + Partial, + )| PartialVertex { + position: vertex.read().position, + curve: Partial::from_partial(PartialCurve { + surface: surface_form.read().surface.clone(), + + global_form: vertex + .read() + .curve + .read() + .global_form + .clone(), + ..Default::default() + }), + surface_form: surface_form.clone(), + }, + ); let mut half_edge = PartialHalfEdge { vertices: vertices.map(Partial::from_partial), From 7645fd497485226e610f95a6f253c8704c643be5 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:02:48 +0100 Subject: [PATCH 12/17] Defer building object --- crates/fj-kernel/src/builder/shell.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index d276b1fc1..370783f25 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -448,11 +448,10 @@ impl ShellBuilder { edges.push(Partial::from_partial(half_edge)); } - let face = PartialFace { + PartialFace { exterior: Partial::from_partial(PartialCycle::new(edges)), ..Default::default() - }; - face.build(objects).insert(objects) + } }; self.faces.extend([bottom.build(objects).insert(objects)]); @@ -462,7 +461,7 @@ impl ShellBuilder { .cloned() .map(|face| face.build(objects).insert(objects)), ); - self.faces.extend([top]); + self.faces.extend([top.build(objects).insert(objects)]); self } From fde14a141809f6d8935bb831356723fb187bf368 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:04:18 +0100 Subject: [PATCH 13/17] Refactor --- crates/fj-kernel/src/builder/shell.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 370783f25..d76ea9b87 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -454,14 +454,13 @@ impl ShellBuilder { } }; - self.faces.extend([bottom.build(objects).insert(objects)]); self.faces.extend( - sides - .iter() - .cloned() + [bottom] + .into_iter() + .chain(sides) + .chain([top]) .map(|face| face.build(objects).insert(objects)), ); - self.faces.extend([top.build(objects).insert(objects)]); self } From ffa3849aca9c9ee4be3367b5f7814b7f9a5a2f0a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:14:59 +0100 Subject: [PATCH 14/17] Simplify `PartialHalfEdge` construction --- crates/fj-kernel/src/builder/shell.rs | 44 ++++++++++----------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index d76ea9b87..2ed140919 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -92,34 +92,22 @@ impl ShellBuilder { .map(|(half_edge, surface)| { let global_edge = half_edge.read().global_form.clone(); - let mut half_edge = PartialHalfEdge { - vertices: global_edge.read().vertices.clone().map( - |global_vertex| { - Partial::from_partial(PartialVertex { - curve: Partial::from_partial( - PartialCurve { - global_form: global_edge - .read() - .curve - .clone(), - ..Default::default() - }, - ), - surface_form: Partial::from_partial( - PartialSurfaceVertex { - global_form: global_vertex, - ..Default::default() - }, - ), - ..Default::default() - }) - }, - ), - global_form: Partial::from_partial(PartialGlobalEdge { - curve: global_edge.read().curve.clone(), - vertices: global_edge.read().vertices.clone(), - }), - }; + let mut half_edge = PartialHalfEdge::default(); + + half_edge.curve().write().global_form = + global_edge.read().curve.clone(); + + for (vertex, global_form) in half_edge + .vertices + .iter_mut() + .zip(&global_edge.read().vertices) + { + vertex.write().surface_form.write().global_form = + global_form.clone(); + } + + half_edge.global_form = global_edge; + half_edge.update_as_line_segment_from_points( surface.clone(), [[Z, Z], [edge_length, Z]], From 022fd0081f031eefdc661fe718b8af29e5c72a69 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:21:42 +0100 Subject: [PATCH 15/17] Make variable name more explicit --- crates/fj-kernel/src/builder/shell.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 2ed140919..8fc705d99 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -124,10 +124,11 @@ impl ShellBuilder { .map(|(bottom, surface): (Partial, _)| { let [_, from] = &bottom.read().vertices; - let from = from.read().surface_form.clone(); + let from_surface = from.read().surface_form.clone(); let to = PartialSurfaceVertex { position: Some( - from.read().position.unwrap() + [Z, edge_length], + from_surface.read().position.unwrap() + + [Z, edge_length], ), surface: surface.clone(), ..Default::default() @@ -136,10 +137,10 @@ impl ShellBuilder { let vertices = [ PartialVertex { curve: Partial::from_partial(PartialCurve { - surface: from.read().surface.clone(), + surface: from_surface.read().surface.clone(), ..Default::default() }), - surface_form: from.clone(), + surface_form: from_surface.clone(), ..Default::default() }, PartialVertex { From 88bbce9fd8bd8b7a59d3c29c7784468acfc792f3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:23:38 +0100 Subject: [PATCH 16/17] Refactor --- crates/fj-kernel/src/builder/shell.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 8fc705d99..51b5ba270 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -122,9 +122,11 @@ impl ShellBuilder { .into_iter() .zip(&surfaces) .map(|(bottom, surface): (Partial, _)| { - let [_, from] = &bottom.read().vertices; - - let from_surface = from.read().surface_form.clone(); + let from_surface = { + let [_, from] = &bottom.read().vertices; + let from = from.read(); + from.surface_form.clone() + }; let to = PartialSurfaceVertex { position: Some( from_surface.read().position.unwrap() From 58e722c8790d2dc1e03a8c286cdb000cc7413f45 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 12 Dec 2022 19:26:05 +0100 Subject: [PATCH 17/17] Make variable name more explicit --- crates/fj-kernel/src/builder/shell.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 51b5ba270..74f946bbe 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -127,7 +127,7 @@ impl ShellBuilder { let from = from.read(); from.surface_form.clone() }; - let to = PartialSurfaceVertex { + let to_surface = PartialSurfaceVertex { position: Some( from_surface.read().position.unwrap() + [Z, edge_length], @@ -147,10 +147,10 @@ impl ShellBuilder { }, PartialVertex { curve: Partial::from_partial(PartialCurve { - surface: to.surface.clone(), + surface: to_surface.surface.clone(), ..Default::default() }), - surface_form: Partial::from_partial(to), + surface_form: Partial::from_partial(to_surface), ..Default::default() }, ]