From 13fd057169b291a2d29132feee792b12f85362ae Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 10:37:50 +0100 Subject: [PATCH 01/28] Simplify `PartialHalfEdge` construction --- crates/fj-kernel/src/builder/shell.rs | 66 ++++++++------------------- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 74f946bbe..3505dced2 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -127,56 +127,28 @@ impl ShellBuilder { let from = from.read(); from.surface_form.clone() }; - let to_surface = PartialSurfaceVertex { - position: Some( - from_surface.read().position.unwrap() - + [Z, edge_length], - ), - surface: surface.clone(), - ..Default::default() - }; + let to_position = from_surface.read().position.unwrap() + + [Z, edge_length]; - let vertices = [ - PartialVertex { - curve: Partial::from_partial(PartialCurve { - surface: from_surface.read().surface.clone(), - ..Default::default() - }), - surface_form: from_surface.clone(), - ..Default::default() - }, - PartialVertex { - curve: Partial::from_partial(PartialCurve { - surface: to_surface.surface.clone(), - ..Default::default() - }), - surface_form: Partial::from_partial(to_surface), - ..Default::default() - }, - ] - .map(Partial::::from_partial); + let mut half_edge = PartialHalfEdge::default(); - let global_curve = { - let [vertex, _] = &vertices; - vertex.read().curve.read().global_form.clone() - }; - let global_vertices = - vertices.each_ref_ext().map(|vertex| { - vertex - .read() - .surface_form - .read() - .global_form - .clone() - }); + half_edge.curve().write().surface = surface.clone(); + + { + let [from, to] = &mut half_edge.vertices; + from.write().surface_form = from_surface.clone(); + + let mut to = to.write(); + let mut to_surface = to.surface_form.write(); + to_surface.position = Some(to_position); + to_surface.surface = surface.clone(); + + half_edge.global_form.write().vertices = [ + from_surface.read().global_form.clone(), + to_surface.global_form.clone(), + ]; + } - let mut half_edge = PartialHalfEdge { - vertices, - global_form: Partial::from_partial(PartialGlobalEdge { - curve: global_curve, - vertices: global_vertices, - }), - }; half_edge.update_as_line_segment(); Partial::from_partial(half_edge) From 72ffffe2058dba2acb92ce83dc0e1e42a09df56b Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 10:42:57 +0100 Subject: [PATCH 02/28] Make variable name more specific --- crates/fj-kernel/src/builder/shell.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 3505dced2..1ad57b72c 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -173,10 +173,10 @@ impl ShellBuilder { side_up_prev.read().vertices.clone(); let [to, _] = bottom.read().vertices.clone(); - let to = to.read().surface_form.clone(); + let to_surface = to.read().surface_form.clone(); let from = PartialSurfaceVertex { position: Some( - to.read().position.unwrap() + to_surface.read().position.unwrap() + [Z, edge_length], ), surface: surface.clone(), @@ -212,11 +212,14 @@ impl ShellBuilder { PartialVertex { curve: Partial::from_partial( PartialCurve { - surface: to.read().surface.clone(), + surface: to_surface + .read() + .surface + .clone(), ..curve.clone() }, ), - surface_form: to.clone(), + surface_form: to_surface.clone(), ..Default::default() }, ] From 9cb4008c4eedf298185afea5ee2279a926a6fead Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 10:53:49 +0100 Subject: [PATCH 03/28] Simplify `PartialHalfEdge` construction --- crates/fj-kernel/src/builder/shell.rs | 99 +++++++++------------------ 1 file changed, 34 insertions(+), 65 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 1ad57b72c..44958e85d 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -173,77 +173,46 @@ impl ShellBuilder { side_up_prev.read().vertices.clone(); let [to, _] = bottom.read().vertices.clone(); + let from_global = from + .read() + .surface_form + .read() + .global_form + .clone(); let to_surface = to.read().surface_form.clone(); - let from = PartialSurfaceVertex { - position: Some( - to_surface.read().position.unwrap() - + [Z, edge_length], - ), - surface: surface.clone(), - global_form: from - .read() - .surface_form - .read() - .global_form - .clone(), - }; - let curve = PartialCurve { - global_form: side_up_prev + let mut half_edge = PartialHalfEdge::default(); + + half_edge.curve().write().surface = surface.clone(); + half_edge.curve().write().global_form = + side_up_prev .read() .curve() .read() .global_form - .clone(), - ..Default::default() - }; - - let vertices = [ - PartialVertex { - curve: Partial::from_partial( - PartialCurve { - surface: from.surface.clone(), - ..curve.clone() - }, - ), - surface_form: Partial::from_partial(from), - ..Default::default() - }, - PartialVertex { - curve: Partial::from_partial( - PartialCurve { - surface: to_surface - .read() - .surface - .clone(), - ..curve.clone() - }, - ), - surface_form: to_surface.clone(), - ..Default::default() - }, - ] - .map(Partial::::from_partial); - - let global_vertices = - vertices.each_ref_ext().map(|vertex| { - vertex - .read() - .surface_form - .read() - .global_form - .clone() - }); - - let mut half_edge = PartialHalfEdge { - vertices, - global_form: Partial::from_partial( - PartialGlobalEdge { - vertices: global_vertices, - curve: curve.global_form, - }, - ), - }; + .clone(); + + { + let [from, to] = &mut half_edge.vertices; + + let mut from = from.write(); + let mut from_surface = + from.surface_form.write(); + from_surface.position = Some( + to_surface.read().position.unwrap() + + [Z, edge_length], + ); + from_surface.surface = surface.clone(); + from_surface.global_form = from_global.clone(); + + to.write().surface_form = to_surface.clone(); + + half_edge.global_form.write().vertices = [ + from_global, + to_surface.read().global_form.clone(), + ]; + } + half_edge.update_as_line_segment(); Partial::from_partial(half_edge) From a1e035dd06250870af9aa9fde048936cd86fd615 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 10:54:35 +0100 Subject: [PATCH 04/28] 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 44958e85d..748f155e7 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -229,15 +229,15 @@ impl ShellBuilder { let [_, from] = side_up.read().vertices.clone(); let [to, _] = side_down.read().vertices.clone(); - let from = from.read().surface_form.clone(); + let from_surface = from.read().surface_form.clone(); let to = to.read().surface_form.clone(); let from = 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() }; let to = PartialVertex { From 76ec79aaf2cf22b193009fc21d39f8589bb4eaa3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 10:54:52 +0100 Subject: [PATCH 05/28] 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 748f155e7..6558e8e95 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -230,7 +230,7 @@ impl ShellBuilder { let [to, _] = side_down.read().vertices.clone(); let from_surface = from.read().surface_form.clone(); - let to = to.read().surface_form.clone(); + let to_surface = to.read().surface_form.clone(); let from = PartialVertex { curve: Partial::from_partial(PartialCurve { @@ -242,10 +242,10 @@ impl ShellBuilder { }; let to = PartialVertex { curve: Partial::from_partial(PartialCurve { - surface: to.read().surface.clone(), + surface: to_surface.read().surface.clone(), ..Default::default() }), - surface_form: to.clone(), + surface_form: to_surface.clone(), ..Default::default() }; From fc719bf524796f7fe9156147f360ef18422898a2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:04:15 +0100 Subject: [PATCH 06/28] Simplify `PartialHalfEdge` construction --- crates/fj-kernel/src/builder/shell.rs | 54 ++++++++------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 6558e8e95..bf288ca99 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, SurfaceVertex, Vertex}, + objects::{Face, FaceSet, HalfEdge, Objects, Shell, SurfaceVertex}, partial::{ Partial, PartialCurve, PartialCycle, PartialFace, PartialGlobalEdge, PartialHalfEdge, PartialObject, PartialSurface, PartialSurfaceVertex, @@ -232,46 +232,22 @@ impl ShellBuilder { let from_surface = from.read().surface_form.clone(); let to_surface = to.read().surface_form.clone(); - let from = PartialVertex { - curve: Partial::from_partial(PartialCurve { - surface: from_surface.read().surface.clone(), - ..Default::default() - }), - surface_form: from_surface.clone(), - ..Default::default() - }; - let to = PartialVertex { - curve: Partial::from_partial(PartialCurve { - surface: to_surface.read().surface.clone(), - ..Default::default() - }), - surface_form: to_surface.clone(), - ..Default::default() - }; + let mut half_edge = PartialHalfEdge::default(); - let vertices = - [from, to].map(Partial::::from_partial); - let global_curve = { - let [vertex, _] = &vertices; - vertex.read().curve.read().global_form.clone() - }; - let global_vertices = - vertices.each_ref_ext().map(|vertex| { - vertex - .read() - .surface_form - .read() - .global_form - .clone() - }); + half_edge.curve().write().surface = + from_surface.read().surface.clone(); + + half_edge.global_form.write().vertices = [ + from_surface.read().global_form.clone(), + to_surface.read().global_form.clone(), + ]; + + { + let [from, to] = &mut half_edge.vertices; + from.write().surface_form = from_surface; + to.write().surface_form = to_surface; + } - let mut half_edge = PartialHalfEdge { - vertices, - global_form: Partial::from_partial(PartialGlobalEdge { - curve: global_curve, - vertices: global_vertices, - }), - }; half_edge.update_as_line_segment(); Partial::from_partial(half_edge) From c538d4cb308e2898657b0e13fa678dff8261e2ae Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:12:47 +0100 Subject: [PATCH 07/28] Refactor --- crates/fj-kernel/src/builder/shell.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index bf288ca99..d4438df83 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -274,8 +274,9 @@ impl ShellBuilder { }; let top = { - let surface = - objects.surfaces.xy_plane().translate([Z, Z, h], objects); + let surface = Partial::from_full_entry_point( + objects.surfaces.xy_plane().translate([Z, Z, h], objects), + ); let mut top_edges = top_edges; top_edges.reverse(); @@ -301,9 +302,8 @@ impl ShellBuilder { Partial::from_partial(PartialSurfaceVertex { position: Some(point.into()), - surface: Partial::from_full_entry_point( - surface.clone(), - ), + surface: surface.clone(), + global_form: global_vertex, }) }); From 1708e127c97fb21aa9e7a8fbea5882ca8beb01e6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:13:41 +0100 Subject: [PATCH 08/28] Simplify `PartialHalfEdge` construction --- crates/fj-kernel/src/builder/shell.rs | 56 +++++++++------------------ 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index d4438df83..4a0f5c9f2 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -10,11 +10,10 @@ use crate::{ FaceBuilder, HalfEdgeBuilder, SurfaceBuilder, SurfaceVertexBuilder, }, insert::Insert, - objects::{Face, FaceSet, HalfEdge, Objects, Shell, SurfaceVertex}, + objects::{Face, FaceSet, HalfEdge, Objects, Shell}, partial::{ - Partial, PartialCurve, PartialCycle, PartialFace, PartialGlobalEdge, - PartialHalfEdge, PartialObject, PartialSurface, PartialSurfaceVertex, - PartialVertex, + Partial, PartialCycle, PartialFace, PartialHalfEdge, PartialObject, + PartialSurface, PartialSurfaceVertex, }, services::Service, storage::Handle, @@ -317,43 +316,24 @@ impl ShellBuilder { .array_windows_ext() .zip(top_edges) { - let global_edge = edge.read().global_form.clone(); + let global_form = edge.read().global_form.clone(); - let vertices = edge - .read() - .vertices - .each_ref_ext() - .into_iter_fixed() - .zip(surface_vertices.clone()) - .collect::<[_; 2]>() - .map( - |(vertex, surface_form): ( - _, - Partial, - )| PartialVertex { - position: vertex.read().position, - curve: Partial::from_partial(PartialCurve { - surface: surface_form.read().surface.clone(), + let mut half_edge = PartialHalfEdge::default(); - global_form: vertex - .read() - .curve - .read() - .global_form - .clone(), - ..Default::default() - }), - surface_form: surface_form.clone(), - }, - ); + half_edge.curve().write().surface = surface.clone(); + half_edge.curve().write().global_form = + global_form.read().curve.clone(); + + half_edge.global_form = global_form; + + for (vertex, surface_form) in half_edge + .vertices + .each_mut_ext() + .zip_ext(surface_vertices.each_ref_ext()) + { + vertex.write().surface_form = surface_form.clone(); + } - let mut half_edge = PartialHalfEdge { - vertices: vertices.map(Partial::from_partial), - global_form: Partial::from_partial(PartialGlobalEdge { - curve: global_edge.read().curve.clone(), - vertices: global_edge.read().vertices.clone(), - }), - }; half_edge.update_as_line_segment(); edges.push(Partial::from_partial(half_edge)); From f2b40dc9deac88c3fe58ad0cf190cda75321856f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:16:38 +0100 Subject: [PATCH 09/28] Remove obsolete comment --- crates/fj-operations/src/sketch.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 7409fe863..7f297a8ee 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -27,9 +27,6 @@ impl Shape for fj::Sketch { let face = match self.chain() { fj::Chain::Circle(circle) => { - // Circles have just a single round edge with no vertices. So - // none need to be added here. - let half_edge = { let surface = Partial::from_full_entry_point(surface); let curve = Partial::from_partial(PartialCurve { From 64ce13e5fbcc6c14fd7edac8d414719d4437aa56 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:26:02 +0100 Subject: [PATCH 10/28] Simplify `PartialHalfEdge` construction --- crates/fj-operations/src/sketch.rs | 51 ++++++++---------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 7f297a8ee..54599b8de 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -1,13 +1,12 @@ -use std::{array, ops::Deref}; +use std::ops::Deref; -use fj_interop::{debug::DebugInfo, ext::ArrayExt, mesh::Color}; +use fj_interop::{debug::DebugInfo, mesh::Color}; use fj_kernel::{ builder::{FaceBuilder, HalfEdgeBuilder}, insert::Insert, - objects::{Objects, Sketch, Vertex}, + objects::{Objects, Sketch}, partial::{ - Partial, PartialCurve, PartialCycle, PartialFace, PartialGlobalEdge, - PartialHalfEdge, PartialObject, PartialSurfaceVertex, PartialVertex, + Partial, PartialCycle, PartialFace, PartialHalfEdge, PartialObject, }, services::Service, }; @@ -29,40 +28,16 @@ impl Shape for fj::Sketch { fj::Chain::Circle(circle) => { let half_edge = { let surface = Partial::from_full_entry_point(surface); - let curve = Partial::from_partial(PartialCurve { - surface: surface.clone(), - ..Default::default() - }); - let vertices = array::from_fn(|_| { - Partial::from_partial(PartialVertex { - curve: curve.clone(), - surface_form: Partial::from_partial( - PartialSurfaceVertex { - surface: surface.clone(), - ..Default::default() - }, - ), - ..Default::default() - }) - }); - let global_vertices = vertices.each_ref_ext().map( - |vertex: &Partial| { - vertex - .read() - .surface_form - .read() - .global_form - .clone() - }, - ); - let mut half_edge = PartialHalfEdge { - vertices, - global_form: Partial::from_partial(PartialGlobalEdge { - curve: curve.read().global_form.clone(), - vertices: global_vertices, - }), - }; + let mut half_edge = PartialHalfEdge::default(); + + half_edge.curve().write().surface = surface.clone(); + + for vertex in &mut half_edge.vertices { + vertex.write().surface_form.write().surface = + surface.clone(); + } + half_edge.update_as_circle_from_radius(circle.radius()); Partial::from_partial(half_edge) From 03f6e9e30193a36bca2ed0e8e152377430e2c0a4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:27:10 +0100 Subject: [PATCH 11/28] Remove redundant code --- crates/fj-kernel/src/builder/edge.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index a12dbb0ca..94804a2e9 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -91,7 +91,6 @@ impl HalfEdgeBuilder for PartialHalfEdge { for (vertex, position) in self.vertices.each_mut_ext().zip_ext([0., 1.]) { vertex.write().position = Some([position].into()); - vertex.write().curve = curve.clone(); } self.global_form.write().curve = curve.read().global_form.clone(); From 574a4f1a08360465e121c917d3f27757586857d8 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:36:04 +0100 Subject: [PATCH 12/28] Consolidate related code in one place --- crates/fj-kernel/src/builder/edge.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 94804a2e9..0489545d3 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -87,13 +87,12 @@ impl HalfEdgeBuilder for PartialHalfEdge { let mut curve = self.curve(); curve.write().update_as_line_from_points(points_surface); + self.global_form.write().curve = curve.read().global_form.clone(); for (vertex, position) in self.vertices.each_mut_ext().zip_ext([0., 1.]) { vertex.write().position = Some([position].into()); } - - self.global_form.write().curve = curve.read().global_form.clone(); } } From 1e7f01509e6c9c09e980ac57ff702f3e19fde934 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:37:35 +0100 Subject: [PATCH 13/28] Remove redundant code --- crates/fj-kernel/src/builder/edge.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 0489545d3..7cf91a0f9 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -6,7 +6,7 @@ use crate::{ partial::{Partial, PartialGlobalEdge, PartialHalfEdge}, }; -use super::{CurveBuilder, SurfaceVertexBuilder}; +use super::CurveBuilder; /// Builder API for [`PartialHalfEdge`] pub trait HalfEdgeBuilder { @@ -69,7 +69,6 @@ impl HalfEdgeBuilder for PartialHalfEdge { let mut surface_form = vertex.surface_form.write(); surface_form.position = Some(point.into()); surface_form.surface = surface.clone(); - surface_form.infer_global_position(); } self.update_as_line_segment() From a389c9cea91dc93e332e8bdad9e610667d207c07 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:41:41 +0100 Subject: [PATCH 14/28] Refactor --- crates/fj-kernel/src/builder/face.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 2eb68d7c5..dfab52940 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -31,11 +31,11 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - self.exterior = Partial::from_partial( - PartialCycle::default() - .with_poly_chain_from_points(surface, points) - .close_with_line_segment(), - ); + let cycle = PartialCycle::default() + .with_poly_chain_from_points(surface, points) + .close_with_line_segment(); + + self.exterior = Partial::from_partial(cycle); self } @@ -44,11 +44,11 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - self.interiors = vec![Partial::from_partial( - PartialCycle::default() - .with_poly_chain_from_points(surface, points) - .close_with_line_segment(), - )]; + let cycle = PartialCycle::default() + .with_poly_chain_from_points(surface, points) + .close_with_line_segment(); + + self.interiors = vec![Partial::from_partial(cycle)]; self } } From f4963e9a4fb2fb5d23176dcf02b0515086ceecd6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:45:13 +0100 Subject: [PATCH 15/28] Refactor --- crates/fj-kernel/src/validate/face.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 80795932b..0a646b184 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -130,15 +130,16 @@ mod tests { ) .build(&mut services.objects); let invalid = { - let interiors = [PartialCycle::default() + let cycle = PartialCycle::default() .with_poly_chain_from_points( services.objects.surfaces.xz_plane(), [[1., 1.], [1., 2.], [2., 1.]], ) .close_with_line_segment() .build(&mut services.objects) - .insert(&mut services.objects)]; + .insert(&mut services.objects); + let interiors = [cycle]; Face::new(valid.exterior().clone(), interiors, valid.color()) }; From b704ed75f8260ec3444012f0d88903e5aa6feb30 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:46:20 +0100 Subject: [PATCH 16/28] Update `CycleBuilder` method to latest style --- crates/fj-kernel/src/builder/cycle.rs | 7 +++---- crates/fj-kernel/src/builder/face.rs | 12 ++++++------ crates/fj-kernel/src/iter.rs | 12 ++++++------ crates/fj-kernel/src/validate/cycle.rs | 13 ++++++------- crates/fj-kernel/src/validate/face.rs | 7 ++++--- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 46e946dcd..16dab26cb 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -27,7 +27,7 @@ pub trait CycleBuilder { /// Update the partial cycle by closing it with a line segment /// /// Builds a line segment from the last and first vertex, closing the cycle. - fn close_with_line_segment(self) -> Self; + fn close_with_line_segment(&mut self); } impl CycleBuilder for PartialCycle { @@ -99,7 +99,7 @@ impl CycleBuilder for PartialCycle { })) } - fn close_with_line_segment(mut self) -> Self { + fn close_with_line_segment(&mut self) { let first = self.half_edges.first(); let last = self.half_edges.last(); @@ -114,7 +114,7 @@ impl CycleBuilder for PartialCycle { }); let [Some([first, _]), Some([_, last])] = vertices else { - return self; + return; }; let mut half_edge = PartialHalfEdge::default(); @@ -138,6 +138,5 @@ impl CycleBuilder for PartialCycle { half_edge.update_as_line_segment(); self.half_edges.push(Partial::from_partial(half_edge)); - self } } diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index dfab52940..9c6fae1c4 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -31,9 +31,9 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - let cycle = PartialCycle::default() - .with_poly_chain_from_points(surface, points) - .close_with_line_segment(); + let mut cycle = PartialCycle::default() + .with_poly_chain_from_points(surface, points); + cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); self @@ -44,9 +44,9 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - let cycle = PartialCycle::default() - .with_poly_chain_from_points(surface, points) - .close_with_line_segment(); + let mut cycle = PartialCycle::default() + .with_poly_chain_from_points(surface, points); + cycle.close_with_line_segment(); self.interiors = vec![Partial::from_partial(cycle)]; self diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 066f49c5b..35d5e4e3a 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -407,12 +407,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let object = PartialCycle::default() - .with_poly_chain_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ) - .close_with_line_segment() + let mut object = PartialCycle::default().with_poly_chain_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); + object.close_with_line_segment(); + let object = object .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/validate/cycle.rs b/crates/fj-kernel/src/validate/cycle.rs index 82cf04de6..0a0a3914c 100644 --- a/crates/fj-kernel/src/validate/cycle.rs +++ b/crates/fj-kernel/src/validate/cycle.rs @@ -77,13 +77,12 @@ mod tests { fn cycle_half_edge_connections() { let mut services = Services::new(); - let valid = PartialCycle::default() - .with_poly_chain_from_points( - services.objects.surfaces.xy_plane(), - [[0., 0.], [1., 0.], [0., 1.]], - ) - .close_with_line_segment() - .build(&mut services.objects); + let mut valid = PartialCycle::default().with_poly_chain_from_points( + services.objects.surfaces.xy_plane(), + [[0., 0.], [1., 0.], [0., 1.]], + ); + valid.close_with_line_segment(); + let valid = valid.build(&mut services.objects); let invalid = { let mut half_edges = valid .half_edges() diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 0a646b184..5b298387c 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -130,12 +130,13 @@ mod tests { ) .build(&mut services.objects); let invalid = { - let cycle = PartialCycle::default() + let mut cycle = PartialCycle::default() .with_poly_chain_from_points( services.objects.surfaces.xz_plane(), [[1., 1.], [1., 2.], [2., 1.]], - ) - .close_with_line_segment() + ); + cycle.close_with_line_segment(); + let cycle = cycle .build(&mut services.objects) .insert(&mut services.objects); From 81e4cda8e3af866b34f238745718f4c8720b2eb2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:49:16 +0100 Subject: [PATCH 17/28] Refactor --- crates/fj-kernel/src/iter.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 35d5e4e3a..fd5807f29 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -407,14 +407,18 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let mut object = PartialCycle::default().with_poly_chain_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ); - object.close_with_line_segment(); - let object = object - .build(&mut services.objects) - .insert(&mut services.objects); + let object = { + let mut cycle = PartialCycle::default() + .with_poly_chain_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); + cycle.close_with_line_segment(); + + cycle + .build(&mut services.objects) + .insert(&mut services.objects) + }; assert_eq!(3, object.curve_iter().count()); assert_eq!(1, object.cycle_iter().count()); From 955879acaba017b56dc182918c805fbe538be7c2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:50:23 +0100 Subject: [PATCH 18/28] Refactor --- crates/fj-kernel/src/validate/cycle.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/validate/cycle.rs b/crates/fj-kernel/src/validate/cycle.rs index 0a0a3914c..133855633 100644 --- a/crates/fj-kernel/src/validate/cycle.rs +++ b/crates/fj-kernel/src/validate/cycle.rs @@ -77,12 +77,16 @@ mod tests { fn cycle_half_edge_connections() { let mut services = Services::new(); - let mut valid = PartialCycle::default().with_poly_chain_from_points( - services.objects.surfaces.xy_plane(), - [[0., 0.], [1., 0.], [0., 1.]], - ); - valid.close_with_line_segment(); - let valid = valid.build(&mut services.objects); + let valid = { + let mut cycle = PartialCycle::default() + .with_poly_chain_from_points( + services.objects.surfaces.xy_plane(), + [[0., 0.], [1., 0.], [0., 1.]], + ); + cycle.close_with_line_segment(); + + cycle.build(&mut services.objects) + }; let invalid = { let mut half_edges = valid .half_edges() From ba12971bdc8b2645ca2eecbc9f6bfdd572afc258 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:51:19 +0100 Subject: [PATCH 19/28] Update `CycleBuilder` method to latest style --- crates/fj-kernel/src/builder/cycle.rs | 26 +++++++++++++++----------- crates/fj-kernel/src/builder/face.rs | 8 ++++---- crates/fj-kernel/src/iter.rs | 10 +++++----- crates/fj-kernel/src/validate/cycle.rs | 10 +++++----- crates/fj-kernel/src/validate/face.rs | 10 +++++----- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 16dab26cb..4d4a6bbea 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -19,10 +19,10 @@ pub trait CycleBuilder { /// Update the partial cycle with a polygonal chain from the provided points fn with_poly_chain_from_points( - self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self; + ); /// Update the partial cycle by closing it with a line segment /// @@ -86,17 +86,21 @@ impl CycleBuilder for PartialCycle { } fn with_poly_chain_from_points( - self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self { - self.with_poly_chain(points.into_iter().map(|position| { - PartialSurfaceVertex { - position: Some(position.into()), - surface: Partial::from_full_entry_point(surface.clone()), - ..Default::default() - } - })) + ) { + *self = + self.clone() + .with_poly_chain(points.into_iter().map(|position| { + PartialSurfaceVertex { + position: Some(position.into()), + surface: Partial::from_full_entry_point( + surface.clone(), + ), + ..Default::default() + } + })); } fn close_with_line_segment(&mut self) { diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 9c6fae1c4..868f43d75 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -31,8 +31,8 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - let mut cycle = PartialCycle::default() - .with_poly_chain_from_points(surface, points); + let mut cycle = PartialCycle::default(); + cycle.with_poly_chain_from_points(surface, points); cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); @@ -44,8 +44,8 @@ impl FaceBuilder for PartialFace { surface: Handle, points: impl IntoIterator>>, ) -> Self { - let mut cycle = PartialCycle::default() - .with_poly_chain_from_points(surface, points); + let mut cycle = PartialCycle::default(); + cycle.with_poly_chain_from_points(surface, points); cycle.close_with_line_segment(); self.interiors = vec![Partial::from_partial(cycle)]; diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index fd5807f29..694e6d50a 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -408,11 +408,11 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let object = { - let mut cycle = PartialCycle::default() - .with_poly_chain_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ); + let mut cycle = PartialCycle::default(); + cycle.with_poly_chain_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); cycle.close_with_line_segment(); cycle diff --git a/crates/fj-kernel/src/validate/cycle.rs b/crates/fj-kernel/src/validate/cycle.rs index 133855633..2109b1a6b 100644 --- a/crates/fj-kernel/src/validate/cycle.rs +++ b/crates/fj-kernel/src/validate/cycle.rs @@ -78,11 +78,11 @@ mod tests { let mut services = Services::new(); let valid = { - let mut cycle = PartialCycle::default() - .with_poly_chain_from_points( - services.objects.surfaces.xy_plane(), - [[0., 0.], [1., 0.], [0., 1.]], - ); + let mut cycle = PartialCycle::default(); + cycle.with_poly_chain_from_points( + services.objects.surfaces.xy_plane(), + [[0., 0.], [1., 0.], [0., 1.]], + ); cycle.close_with_line_segment(); cycle.build(&mut services.objects) diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 5b298387c..d638c1835 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -130,11 +130,11 @@ mod tests { ) .build(&mut services.objects); let invalid = { - let mut cycle = PartialCycle::default() - .with_poly_chain_from_points( - services.objects.surfaces.xz_plane(), - [[1., 1.], [1., 2.], [2., 1.]], - ); + let mut cycle = PartialCycle::default(); + cycle.with_poly_chain_from_points( + services.objects.surfaces.xz_plane(), + [[1., 1.], [1., 2.], [2., 1.]], + ); cycle.close_with_line_segment(); let cycle = cycle .build(&mut services.objects) From 581508c0a86547b6d70936bba55f2701e7a205a0 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 11:52:32 +0100 Subject: [PATCH 20/28] Update `CycleBuilder` method to latest style --- crates/fj-kernel/src/builder/cycle.rs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 4d4a6bbea..c5db538b3 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -13,9 +13,9 @@ use super::HalfEdgeBuilder; pub trait CycleBuilder { /// Update the partial cycle with a polygonal chain from the provided points fn with_poly_chain( - self, + &mut self, vertices: impl IntoIterator, - ) -> Self; + ); /// Update the partial cycle with a polygonal chain from the provided points fn with_poly_chain_from_points( @@ -32,9 +32,9 @@ pub trait CycleBuilder { impl CycleBuilder for PartialCycle { fn with_poly_chain( - mut self, + &mut self, vertices: impl IntoIterator, - ) -> Self { + ) { let vertices = vertices.into_iter(); let mut previous: Option> = @@ -82,7 +82,6 @@ impl CycleBuilder for PartialCycle { } self.half_edges.extend(half_edges); - self } fn with_poly_chain_from_points( @@ -90,17 +89,13 @@ impl CycleBuilder for PartialCycle { surface: Handle, points: impl IntoIterator>>, ) { - *self = - self.clone() - .with_poly_chain(points.into_iter().map(|position| { - PartialSurfaceVertex { - position: Some(position.into()), - surface: Partial::from_full_entry_point( - surface.clone(), - ), - ..Default::default() - } - })); + self.with_poly_chain(points.into_iter().map(|position| { + PartialSurfaceVertex { + position: Some(position.into()), + surface: Partial::from_full_entry_point(surface.clone()), + ..Default::default() + } + })); } fn close_with_line_segment(&mut self) { From f3f5919562ec68e14f236dabb456226dcad4d309 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:08:11 +0100 Subject: [PATCH 21/28] Relax method argument --- crates/fj-kernel/src/builder/cycle.rs | 7 +++---- crates/fj-kernel/src/builder/face.rs | 10 ++++++++-- crates/fj-kernel/src/iter.rs | 2 +- crates/fj-kernel/src/validate/cycle.rs | 4 +++- crates/fj-kernel/src/validate/face.rs | 6 ++++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index c5db538b3..9badbcfc4 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -4,7 +4,6 @@ use fj_math::Point; use crate::{ objects::{Surface, SurfaceVertex}, partial::{Partial, PartialCycle, PartialHalfEdge, PartialSurfaceVertex}, - storage::Handle, }; use super::HalfEdgeBuilder; @@ -20,7 +19,7 @@ pub trait CycleBuilder { /// Update the partial cycle with a polygonal chain from the provided points fn with_poly_chain_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ); @@ -86,13 +85,13 @@ impl CycleBuilder for PartialCycle { fn with_poly_chain_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ) { self.with_poly_chain(points.into_iter().map(|position| { PartialSurfaceVertex { position: Some(position.into()), - surface: Partial::from_full_entry_point(surface.clone()), + surface: surface.clone(), ..Default::default() } })); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 868f43d75..aba99a6e0 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -32,7 +32,10 @@ impl FaceBuilder for PartialFace { points: impl IntoIterator>>, ) -> Self { let mut cycle = PartialCycle::default(); - cycle.with_poly_chain_from_points(surface, points); + cycle.with_poly_chain_from_points( + Partial::from_full_entry_point(surface), + points, + ); cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); @@ -45,7 +48,10 @@ impl FaceBuilder for PartialFace { points: impl IntoIterator>>, ) -> Self { let mut cycle = PartialCycle::default(); - cycle.with_poly_chain_from_points(surface, points); + cycle.with_poly_chain_from_points( + Partial::from_full_entry_point(surface), + points, + ); cycle.close_with_line_segment(); self.interiors = vec![Partial::from_partial(cycle)]; diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 694e6d50a..6c0726342 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -410,7 +410,7 @@ mod tests { let object = { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); cycle.close_with_line_segment(); diff --git a/crates/fj-kernel/src/validate/cycle.rs b/crates/fj-kernel/src/validate/cycle.rs index 2109b1a6b..f0851fff8 100644 --- a/crates/fj-kernel/src/validate/cycle.rs +++ b/crates/fj-kernel/src/validate/cycle.rs @@ -80,7 +80,9 @@ mod tests { let valid = { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( - services.objects.surfaces.xy_plane(), + Partial::from_full_entry_point( + services.objects.surfaces.xy_plane(), + ), [[0., 0.], [1., 0.], [0., 1.]], ); cycle.close_with_line_segment(); diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index d638c1835..51ad20f0a 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -108,7 +108,7 @@ mod tests { builder::{CycleBuilder, FaceBuilder}, insert::Insert, objects::Face, - partial::{PartialCycle, PartialFace, PartialObject}, + partial::{Partial, PartialCycle, PartialFace, PartialObject}, services::Services, validate::Validate, }; @@ -132,7 +132,9 @@ mod tests { let invalid = { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( - services.objects.surfaces.xz_plane(), + Partial::from_full_entry_point( + services.objects.surfaces.xz_plane(), + ), [[1., 1.], [1., 2.], [2., 1.]], ); cycle.close_with_line_segment(); From 63eae5f224fa73a999f7b071a6e2ee8ab7d23afb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:12:13 +0100 Subject: [PATCH 22/28] Update `FaceBuilder` method to latest style --- .../src/algorithms/intersect/curve_face.rs | 8 +++--- .../src/algorithms/triangulate/mod.rs | 7 +++-- crates/fj-kernel/src/builder/face.rs | 9 +++--- crates/fj-kernel/src/validate/face.rs | 28 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index a702b6035..4366a3770 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -185,10 +185,10 @@ mod tests { [ 1., -1.], ]; - let face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), exterior) - .with_interior_polygon_from_points(surface, interior) - .build(&mut services.objects); + let mut face = PartialFace::default() + .with_exterior_polygon_from_points(surface.clone(), exterior); + face.with_interior_polygon_from_points(surface, interior); + let face = face.build(&mut services.objects); let expected = CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 3805207ee..918d6ac33 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -132,9 +132,10 @@ mod tests { let h = [3., 1.]; let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]) - .with_interior_polygon_from_points(surface.clone(), [e, f, g, h]) + let mut face = PartialFace::default() + .with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); + face.with_interior_polygon_from_points(surface.clone(), [e, f, g, h]); + let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index aba99a6e0..81695d46a 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -19,10 +19,10 @@ pub trait FaceBuilder { /// Update the [`PartialFace`] with an interior polygon fn with_interior_polygon_from_points( - self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self; + ); } impl FaceBuilder for PartialFace { @@ -43,10 +43,10 @@ impl FaceBuilder for PartialFace { } fn with_interior_polygon_from_points( - mut self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self { + ) { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( Partial::from_full_entry_point(surface), @@ -55,6 +55,5 @@ impl FaceBuilder for PartialFace { cycle.close_with_line_segment(); self.interiors = vec![Partial::from_partial(cycle)]; - self } } diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 51ad20f0a..9254f8e77 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -119,16 +119,16 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let valid = PartialFace::default() + let mut valid = PartialFace::default() .with_exterior_polygon_from_points( surface.clone(), [[0., 0.], [3., 0.], [0., 3.]], - ) - .with_interior_polygon_from_points( - surface, - [[1., 1.], [1., 2.], [2., 1.]], - ) - .build(&mut services.objects); + ); + valid.with_interior_polygon_from_points( + surface, + [[1., 1.], [1., 2.], [2., 1.]], + ); + let valid = valid.build(&mut services.objects); let invalid = { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( @@ -156,16 +156,16 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let valid = PartialFace::default() + let mut valid = PartialFace::default() .with_exterior_polygon_from_points( surface.clone(), [[0., 0.], [3., 0.], [0., 3.]], - ) - .with_interior_polygon_from_points( - surface, - [[1., 1.], [1., 2.], [2., 1.]], - ) - .build(&mut services.objects); + ); + valid.with_interior_polygon_from_points( + surface, + [[1., 1.], [1., 2.], [2., 1.]], + ); + let valid = valid.build(&mut services.objects); let invalid = { let interiors = valid .interiors() From f96afb4f888ba231ab2a3f272e809fca5d69a569 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:13:14 +0100 Subject: [PATCH 23/28] Refactor --- .../fj-kernel/src/algorithms/intersect/curve_face.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 4366a3770..1de35a1d0 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -185,10 +185,13 @@ mod tests { [ 1., -1.], ]; - let mut face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), exterior); - face.with_interior_polygon_from_points(surface, interior); - let face = face.build(&mut services.objects); + let face = { + let mut face = PartialFace::default() + .with_exterior_polygon_from_points(surface.clone(), exterior); + face.with_interior_polygon_from_points(surface, interior); + + face.build(&mut services.objects) + }; let expected = CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]); From 495f81a1eef64eebfa0f329e263c89bdfcb08ae4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:31:08 +0100 Subject: [PATCH 24/28] Refactor --- crates/fj-kernel/src/builder/sketch.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 3f94b6692..b86fd2f36 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -35,10 +35,12 @@ impl SketchBuilder { points: impl IntoIterator>>, objects: &mut Service, ) -> Self { - self.faces.extend([PartialFace::default() + let face = PartialFace::default() .with_exterior_polygon_from_points(surface, points) .build(objects) - .insert(objects)]); + .insert(objects); + + self.faces.extend([face]); self } From 69d48b1b162e62db456cbbd158e52d9954934846 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:33:54 +0100 Subject: [PATCH 25/28] Refactor --- crates/fj-kernel/src/validate/face.rs | 41 +++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 9254f8e77..37e27c7c3 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -119,16 +119,19 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let mut valid = PartialFace::default() - .with_exterior_polygon_from_points( - surface.clone(), - [[0., 0.], [3., 0.], [0., 3.]], + let valid = { + let mut face = PartialFace::default() + .with_exterior_polygon_from_points( + surface.clone(), + [[0., 0.], [3., 0.], [0., 3.]], + ); + face.with_interior_polygon_from_points( + surface, + [[1., 1.], [1., 2.], [2., 1.]], ); - valid.with_interior_polygon_from_points( - surface, - [[1., 1.], [1., 2.], [2., 1.]], - ); - let valid = valid.build(&mut services.objects); + + face.build(&mut services.objects) + }; let invalid = { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( @@ -156,16 +159,18 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); - let mut valid = PartialFace::default() - .with_exterior_polygon_from_points( - surface.clone(), - [[0., 0.], [3., 0.], [0., 3.]], + let valid = { + let mut face = PartialFace::default() + .with_exterior_polygon_from_points( + surface.clone(), + [[0., 0.], [3., 0.], [0., 3.]], + ); + face.with_interior_polygon_from_points( + surface, + [[1., 1.], [1., 2.], [2., 1.]], ); - valid.with_interior_polygon_from_points( - surface, - [[1., 1.], [1., 2.], [2., 1.]], - ); - let valid = valid.build(&mut services.objects); + face.build(&mut services.objects) + }; let invalid = { let interiors = valid .interiors() From 1b198af0dd5c63fdec6bea58df4423c0e14f5323 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:36:43 +0100 Subject: [PATCH 26/28] Update `FaceBuilder` method to latest style --- .../src/algorithms/intersect/curve_face.rs | 4 +- .../src/algorithms/intersect/face_face.rs | 14 +-- .../src/algorithms/intersect/face_point.rs | 88 ++++++++++--------- .../src/algorithms/intersect/ray_face.rs | 77 ++++++++-------- crates/fj-kernel/src/algorithms/sweep/face.rs | 32 ++++--- .../src/algorithms/triangulate/mod.rs | 17 ++-- crates/fj-kernel/src/builder/face.rs | 9 +- crates/fj-kernel/src/builder/shell.rs | 7 +- crates/fj-kernel/src/builder/sketch.rs | 7 +- crates/fj-kernel/src/iter.rs | 22 ++--- crates/fj-kernel/src/validate/face.rs | 20 ++--- crates/fj-operations/src/sketch.rs | 4 +- 12 files changed, 165 insertions(+), 136 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 1de35a1d0..52d4b2709 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -186,8 +186,8 @@ mod tests { ]; let face = { - let mut face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), exterior); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface.clone(), exterior); face.with_interior_polygon_from_points(surface, interior); face.build(&mut services.objects) diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 247eb0b1b..8afb76673 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -93,9 +93,10 @@ mod tests { services.objects.surfaces.xz_plane(), ] .map(|surface| { - PartialFace::default() - .with_exterior_polygon_from_points(surface, points) - .build(&mut services.objects) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface, points); + + face.build(&mut services.objects) }); let intersection = @@ -120,9 +121,10 @@ mod tests { services.objects.surfaces.xz_plane(), ]; let [a, b] = surfaces.clone().map(|surface| { - PartialFace::default() - .with_exterior_polygon_from_points(surface, points) - .build(&mut services.objects) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface, points); + + face.build(&mut services.objects) }); let intersection = diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 9b91005b8..630dd81bc 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -148,11 +148,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [1., 1.], [0., 2.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [1., 1.], [0., 2.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([2., 1.]); @@ -166,11 +167,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [2., 1.], [0., 2.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [2., 1.], [0., 2.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 1.]); @@ -187,11 +189,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[4., 2.], [0., 4.], [0., 0.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[4., 2.], [0., 4.], [0., 0.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 2.]); @@ -208,11 +211,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [2., 1.], [3., 0.], [3., 4.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [2., 1.], [3., 0.], [3., 4.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 1.]); @@ -229,11 +233,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [2., 1.], [3., 1.], [0., 2.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [2., 1.], [3., 1.], [0., 2.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 1.]); @@ -250,11 +255,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 1.]); @@ -271,11 +277,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [2., 0.], [0., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [2., 0.], [0., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 0.]); @@ -301,11 +308,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let point = Point::from([1., 0.]); diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 3c4ef18e0..76907a400 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -166,11 +166,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.yz_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([-1., 0., 0.], &mut services.objects); @@ -185,11 +186,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.yz_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([1., 0., 0.], &mut services.objects); @@ -207,11 +209,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.yz_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([0., 0., 2.], &mut services.objects); @@ -226,11 +229,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.yz_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([1., 1., 0.], &mut services.objects); @@ -256,11 +260,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.yz_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([1., 1., 1.], &mut services.objects); @@ -284,11 +289,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -305,11 +311,12 @@ mod tests { let ray = HorizontalRayToTheRight::from([0., 0., 0.]); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects) .translate([0., 0., 1.], &mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index 0d0bb546a..b4044c2db 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -112,16 +112,18 @@ mod tests { .build(&mut services.objects) .sweep(UP, &mut services.objects); - let bottom = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), TRIANGLE) + let mut bottom = PartialFace::default(); + bottom.with_exterior_polygon_from_points(surface.clone(), TRIANGLE); + let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) .reverse(&mut services.objects); - let top = PartialFace::default() - .with_exterior_polygon_from_points( - surface.translate(UP, &mut services.objects), - TRIANGLE, - ) + let mut top = PartialFace::default(); + top.with_exterior_polygon_from_points( + surface.translate(UP, &mut services.objects), + TRIANGLE, + ); + let top = top .build(&mut services.objects) .insert(&mut services.objects); @@ -165,16 +167,18 @@ mod tests { .build(&mut services.objects) .sweep(DOWN, &mut services.objects); - let bottom = PartialFace::default() - .with_exterior_polygon_from_points( - surface.clone().translate(DOWN, &mut services.objects), - TRIANGLE, - ) + let mut bottom = PartialFace::default(); + bottom.with_exterior_polygon_from_points( + surface.clone().translate(DOWN, &mut services.objects), + TRIANGLE, + ); + let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) .reverse(&mut services.objects); - let top = PartialFace::default() - .with_exterior_polygon_from_points(surface, TRIANGLE) + let mut top = PartialFace::default(); + top.with_exterior_polygon_from_points(surface, TRIANGLE); + let top = top .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 918d6ac33..6b6e8528d 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -97,8 +97,9 @@ mod tests { let d = [0., 1.]; let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points(surface, [a, b, c, d]) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface, [a, b, c, d]); + let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -132,8 +133,8 @@ mod tests { let h = [3., 1.]; let surface = services.objects.surfaces.xy_plane(); - let mut face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); face.with_interior_polygon_from_points(surface.clone(), [e, f, g, h]); let face = face .build(&mut services.objects) @@ -191,8 +192,12 @@ mod tests { let e = [0.0, 1.0]; let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points(surface.clone(), [a, b, c, d, e]) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface.clone(), + [a, b, c, d, e], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 81695d46a..9130f1a94 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -12,10 +12,10 @@ use super::CycleBuilder; pub trait FaceBuilder { /// Update the [`PartialFace`] with an exterior polygon fn with_exterior_polygon_from_points( - self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self; + ); /// Update the [`PartialFace`] with an interior polygon fn with_interior_polygon_from_points( @@ -27,10 +27,10 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn with_exterior_polygon_from_points( - mut self, + &mut self, surface: Handle, points: impl IntoIterator>>, - ) -> Self { + ) { let mut cycle = PartialCycle::default(); cycle.with_poly_chain_from_points( Partial::from_full_entry_point(surface), @@ -39,7 +39,6 @@ impl FaceBuilder for PartialFace { cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); - self } fn with_interior_polygon_from_points( diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 4a0f5c9f2..3dd32888e 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -53,10 +53,13 @@ impl ShellBuilder { let surface = objects.surfaces.xy_plane().translate([Z, Z, -h], objects); - PartialFace::default().with_exterior_polygon_from_points( + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( surface, [[-h, -h], [h, -h], [h, h], [-h, h]], - ) + ); + + face }; let (sides, top_edges) = { diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index b86fd2f36..20682748b 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -35,10 +35,9 @@ impl SketchBuilder { points: impl IntoIterator>>, objects: &mut Service, ) -> Self { - let face = PartialFace::default() - .with_exterior_polygon_from_points(surface, points) - .build(objects) - .insert(objects); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface, points); + let face = face.build(objects).insert(objects); self.faces.extend([face]); self diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index 6c0726342..e5820ecf7 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -438,11 +438,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let object = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ) + let mut object = PartialFace::default(); + object.with_exterior_polygon_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); + let object = object .build(&mut services.objects) .insert(&mut services.objects); @@ -555,11 +556,12 @@ mod tests { let mut services = Services::new(); let surface = services.objects.surfaces.xy_plane(); - let face = PartialFace::default() - .with_exterior_polygon_from_points( - surface, - [[0., 0.], [1., 0.], [0., 1.]], - ) + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface, + [[0., 0.], [1., 0.], [0., 1.]], + ); + let face = face .build(&mut services.objects) .insert(&mut services.objects); let object = Sketch::builder() diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 37e27c7c3..1126f4f89 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -120,11 +120,11 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let valid = { - let mut face = PartialFace::default() - .with_exterior_polygon_from_points( - surface.clone(), - [[0., 0.], [3., 0.], [0., 3.]], - ); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface.clone(), + [[0., 0.], [3., 0.], [0., 3.]], + ); face.with_interior_polygon_from_points( surface, [[1., 1.], [1., 2.], [2., 1.]], @@ -160,11 +160,11 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let valid = { - let mut face = PartialFace::default() - .with_exterior_polygon_from_points( - surface.clone(), - [[0., 0.], [3., 0.], [0., 3.]], - ); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points( + surface.clone(), + [[0., 0.], [3., 0.], [0., 3.]], + ); face.with_interior_polygon_from_points( surface, [[1., 1.], [1., 2.], [2., 1.]], diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 54599b8de..859dd23ae 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -59,8 +59,8 @@ impl Shape for fj::Sketch { .map(|fj::SketchSegment::LineTo { point }| point) .map(Point::from); - let mut face = PartialFace::default() - .with_exterior_polygon_from_points(surface, points); + let mut face = PartialFace::default(); + face.with_exterior_polygon_from_points(surface, points); face.color = Some(Color(self.color())); face.build(objects).insert(objects) From f33ad6e0e3177e11d9c171fa44a6900770146fb6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:40:22 +0100 Subject: [PATCH 27/28] Relax method argument --- crates/fj-kernel/src/algorithms/intersect/curve_face.rs | 5 ++++- crates/fj-kernel/src/algorithms/triangulate/mod.rs | 7 +++++-- crates/fj-kernel/src/builder/face.rs | 9 +++------ crates/fj-kernel/src/validate/face.rs | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index 52d4b2709..b5cf9b76f 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -188,7 +188,10 @@ mod tests { let face = { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points(surface.clone(), exterior); - face.with_interior_polygon_from_points(surface, interior); + face.with_interior_polygon_from_points( + Partial::from_full_entry_point(surface), + interior, + ); face.build(&mut services.objects) }; diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 6b6e8528d..f663c3714 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -80,7 +80,7 @@ mod tests { builder::FaceBuilder, insert::Insert, objects::Face, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Services, storage::Handle, }; @@ -135,7 +135,10 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); - face.with_interior_polygon_from_points(surface.clone(), [e, f, g, h]); + face.with_interior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + [e, f, g, h], + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 9130f1a94..ebbac4eca 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -20,7 +20,7 @@ pub trait FaceBuilder { /// Update the [`PartialFace`] with an interior polygon fn with_interior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ); } @@ -43,14 +43,11 @@ impl FaceBuilder for PartialFace { fn with_interior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ) { let mut cycle = PartialCycle::default(); - cycle.with_poly_chain_from_points( - Partial::from_full_entry_point(surface), - points, - ); + cycle.with_poly_chain_from_points(surface, points); cycle.close_with_line_segment(); self.interiors = vec![Partial::from_partial(cycle)]; diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index 1126f4f89..a89e42d4d 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -126,7 +126,7 @@ mod tests { [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[1., 1.], [1., 2.], [2., 1.]], ); @@ -166,7 +166,7 @@ mod tests { [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[1., 1.], [1., 2.], [2., 1.]], ); face.build(&mut services.objects) From 2174bef87918ea8f16cf74e525fe9317bd670ee9 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 13 Dec 2022 13:46:10 +0100 Subject: [PATCH 28/28] Relax method argument --- .../src/algorithms/intersect/curve_face.rs | 5 ++++- .../src/algorithms/intersect/face_face.rs | 10 ++++++++-- .../src/algorithms/intersect/face_point.rs | 18 +++++++++--------- .../src/algorithms/intersect/ray_face.rs | 16 ++++++++-------- crates/fj-kernel/src/algorithms/sweep/face.rs | 18 ++++++++++++++---- .../src/algorithms/triangulate/mod.rs | 12 +++++++++--- crates/fj-kernel/src/builder/face.rs | 10 +++------- crates/fj-kernel/src/builder/shell.rs | 2 +- crates/fj-kernel/src/builder/sketch.rs | 7 +++++-- crates/fj-kernel/src/iter.rs | 4 ++-- crates/fj-kernel/src/validate/face.rs | 4 ++-- crates/fj-operations/src/sketch.rs | 5 ++++- 12 files changed, 69 insertions(+), 42 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs index b5cf9b76f..383e6fa45 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_face.rs @@ -187,7 +187,10 @@ mod tests { let face = { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface.clone(), exterior); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + exterior, + ); face.with_interior_polygon_from_points( Partial::from_full_entry_point(surface), interior, diff --git a/crates/fj-kernel/src/algorithms/intersect/face_face.rs b/crates/fj-kernel/src/algorithms/intersect/face_face.rs index 8afb76673..3f38743e6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_face.rs @@ -94,7 +94,10 @@ mod tests { ] .map(|surface| { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.build(&mut services.objects) }); @@ -122,7 +125,10 @@ mod tests { ]; let [a, b] = surfaces.clone().map(|surface| { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.build(&mut services.objects) }); diff --git a/crates/fj-kernel/src/algorithms/intersect/face_point.rs b/crates/fj-kernel/src/algorithms/intersect/face_point.rs index 630dd81bc..122c689c6 100644 --- a/crates/fj-kernel/src/algorithms/intersect/face_point.rs +++ b/crates/fj-kernel/src/algorithms/intersect/face_point.rs @@ -139,7 +139,7 @@ mod tests { builder::FaceBuilder, insert::Insert, iter::ObjectIters, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -150,7 +150,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 1.], [0., 2.]], ); let face = face @@ -169,7 +169,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [0., 2.]], ); let face = face @@ -191,7 +191,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[4., 2.], [0., 4.], [0., 0.]], ); let face = face @@ -213,7 +213,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 0.], [3., 4.]], ); let face = face @@ -235,7 +235,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 1.], [0., 2.]], ); let face = face @@ -257,7 +257,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]], ); let face = face @@ -279,7 +279,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [2., 0.], [0., 1.]], ); let face = face @@ -310,7 +310,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs index 76907a400..3050d5724 100644 --- a/crates/fj-kernel/src/algorithms/intersect/ray_face.rs +++ b/crates/fj-kernel/src/algorithms/intersect/ray_face.rs @@ -155,7 +155,7 @@ mod tests { builder::FaceBuilder, insert::Insert, iter::ObjectIters, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Services, }; @@ -168,7 +168,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -188,7 +188,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -211,7 +211,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -231,7 +231,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -262,7 +262,7 @@ mod tests { let surface = services.objects.surfaces.yz_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -291,7 +291,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face @@ -313,7 +313,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/algorithms/sweep/face.rs b/crates/fj-kernel/src/algorithms/sweep/face.rs index b4044c2db..0cb5b7bf0 100644 --- a/crates/fj-kernel/src/algorithms/sweep/face.rs +++ b/crates/fj-kernel/src/algorithms/sweep/face.rs @@ -113,14 +113,19 @@ mod tests { .sweep(UP, &mut services.objects); let mut bottom = PartialFace::default(); - bottom.with_exterior_polygon_from_points(surface.clone(), TRIANGLE); + bottom.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + TRIANGLE, + ); let bottom = bottom .build(&mut services.objects) .insert(&mut services.objects) .reverse(&mut services.objects); let mut top = PartialFace::default(); top.with_exterior_polygon_from_points( - surface.translate(UP, &mut services.objects), + Partial::from_full_entry_point( + surface.translate(UP, &mut services.objects), + ), TRIANGLE, ); let top = top @@ -169,7 +174,9 @@ mod tests { let mut bottom = PartialFace::default(); bottom.with_exterior_polygon_from_points( - surface.clone().translate(DOWN, &mut services.objects), + Partial::from_full_entry_point( + surface.clone().translate(DOWN, &mut services.objects), + ), TRIANGLE, ); let bottom = bottom @@ -177,7 +184,10 @@ mod tests { .insert(&mut services.objects) .reverse(&mut services.objects); let mut top = PartialFace::default(); - top.with_exterior_polygon_from_points(surface, TRIANGLE); + top.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + TRIANGLE, + ); let top = top .build(&mut services.objects) .insert(&mut services.objects); diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index f663c3714..3776989ba 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -98,7 +98,10 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, [a, b, c, d]); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + [a, b, c, d], + ); let face = face .build(&mut services.objects) .insert(&mut services.objects); @@ -134,7 +137,10 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface.clone()), + [a, b, c, d], + ); face.with_interior_polygon_from_points( Partial::from_full_entry_point(surface.clone()), [e, f, g, h], @@ -197,7 +203,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [a, b, c, d, e], ); let face = face diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index ebbac4eca..30605c8e3 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -3,7 +3,6 @@ use fj_math::Point; use crate::{ objects::Surface, partial::{Partial, PartialCycle, PartialFace}, - storage::Handle, }; use super::CycleBuilder; @@ -13,7 +12,7 @@ pub trait FaceBuilder { /// Update the [`PartialFace`] with an exterior polygon fn with_exterior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ); @@ -28,14 +27,11 @@ pub trait FaceBuilder { impl FaceBuilder for PartialFace { fn with_exterior_polygon_from_points( &mut self, - surface: Handle, + surface: Partial, points: impl IntoIterator>>, ) { let mut cycle = PartialCycle::default(); - cycle.with_poly_chain_from_points( - Partial::from_full_entry_point(surface), - points, - ); + cycle.with_poly_chain_from_points(surface, points); cycle.close_with_line_segment(); self.exterior = Partial::from_partial(cycle); diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 3dd32888e..eecedc379 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -55,7 +55,7 @@ impl ShellBuilder { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[-h, -h], [h, -h], [h, h], [-h, h]], ); diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index 20682748b..701c39857 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -3,7 +3,7 @@ use fj_math::Point; use crate::{ insert::Insert, objects::{Face, FaceSet, Objects, Sketch, Surface}, - partial::{PartialFace, PartialObject}, + partial::{Partial, PartialFace, PartialObject}, services::Service, storage::Handle, }; @@ -36,7 +36,10 @@ impl SketchBuilder { objects: &mut Service, ) -> Self { let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); let face = face.build(objects).insert(objects); self.faces.extend([face]); diff --git a/crates/fj-kernel/src/iter.rs b/crates/fj-kernel/src/iter.rs index e5820ecf7..649a86726 100644 --- a/crates/fj-kernel/src/iter.rs +++ b/crates/fj-kernel/src/iter.rs @@ -440,7 +440,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut object = PartialFace::default(); object.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let object = object @@ -558,7 +558,7 @@ mod tests { let surface = services.objects.surfaces.xy_plane(); let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface, + Partial::from_full_entry_point(surface), [[0., 0.], [1., 0.], [0., 1.]], ); let face = face diff --git a/crates/fj-kernel/src/validate/face.rs b/crates/fj-kernel/src/validate/face.rs index a89e42d4d..05660334c 100644 --- a/crates/fj-kernel/src/validate/face.rs +++ b/crates/fj-kernel/src/validate/face.rs @@ -122,7 +122,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( @@ -162,7 +162,7 @@ mod tests { let valid = { let mut face = PartialFace::default(); face.with_exterior_polygon_from_points( - surface.clone(), + Partial::from_full_entry_point(surface.clone()), [[0., 0.], [3., 0.], [0., 3.]], ); face.with_interior_polygon_from_points( diff --git a/crates/fj-operations/src/sketch.rs b/crates/fj-operations/src/sketch.rs index 859dd23ae..4fb98eb79 100644 --- a/crates/fj-operations/src/sketch.rs +++ b/crates/fj-operations/src/sketch.rs @@ -60,7 +60,10 @@ impl Shape for fj::Sketch { .map(Point::from); let mut face = PartialFace::default(); - face.with_exterior_polygon_from_points(surface, points); + face.with_exterior_polygon_from_points( + Partial::from_full_entry_point(surface), + points, + ); face.color = Some(Color(self.color())); face.build(objects).insert(objects)