From d4c5dfe34987520257365927c4b49bd8f814ba0f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 16:41:10 +0100 Subject: [PATCH 1/4] Use `Vertex` in `PartialHalfEdge` --- crates/fj-kernel/src/algorithms/sweep/edge.rs | 4 ++-- crates/fj-kernel/src/partial/objects/edge.rs | 20 +++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep/edge.rs b/crates/fj-kernel/src/algorithms/sweep/edge.rs index d168a93da..42da26e0f 100644 --- a/crates/fj-kernel/src/algorithms/sweep/edge.rs +++ b/crates/fj-kernel/src/algorithms/sweep/edge.rs @@ -6,7 +6,7 @@ use crate::{ builder::{CycleBuilder, HalfEdgeBuilder}, insert::Insert, objects::{Face, HalfEdge, Objects, Surface, Vertex}, - partial::{Partial, PartialFace, PartialObject}, + partial::{PartialFace, PartialObject}, services::Service, storage::Handle, }; @@ -97,7 +97,7 @@ impl Sweep for (Handle, &Handle, &Surface, Color) { // Writing to the start vertices is enough. Neighboring half- // edges share surface vertices, so writing the start vertex of // each half-edge writes to all vertices. - half_edge.start_vertex = Partial::from(global_vertex); + half_edge.start_vertex = global_vertex; }); // With the vertices set, we can now update the curves. diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index d764a645a..f14008865 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -4,7 +4,7 @@ use crate::{ geometry::curve::Curve, insert::Insert, objects::{GlobalEdge, HalfEdge, Objects, Vertex}, - partial::{FullToPartialCache, Partial, PartialObject}, + partial::{FullToPartialCache, PartialObject}, services::Service, storage::Handle, }; @@ -19,7 +19,7 @@ pub struct PartialHalfEdge { pub boundary: [Option>; 2], /// The surface vertex where the half-edge starts - pub start_vertex: Partial, + pub start_vertex: Handle, /// The global form of the half-edge pub global_form: Handle, @@ -52,27 +52,21 @@ impl PartialObject for PartialHalfEdge { Self { curve: None, boundary: [None; 2], - start_vertex: Partial::new(objects), + start_vertex: Vertex::new().insert(objects), global_form: GlobalEdge::new().insert(objects), } } - fn from_full( - half_edge: &Self::Full, - cache: &mut FullToPartialCache, - ) -> Self { + fn from_full(half_edge: &Self::Full, _: &mut FullToPartialCache) -> Self { Self { curve: Some(half_edge.curve().into()), boundary: half_edge.boundary().map(Some), - start_vertex: Partial::from_full( - half_edge.start_vertex().clone(), - cache, - ), + start_vertex: half_edge.start_vertex().clone(), global_form: half_edge.global_form().clone(), } } - fn build(self, objects: &mut Service) -> Self::Full { + fn build(self, _: &mut Service) -> Self::Full { let curve = match self.curve.expect("Need path to build curve") { MaybeCurve::Defined(path) => path, undefined => { @@ -84,7 +78,7 @@ impl PartialObject for PartialHalfEdge { let boundary = self.boundary.map(|point| { point.expect("Can't build `HalfEdge` without boundary positions") }); - let start_vertex = self.start_vertex.build(objects); + let start_vertex = self.start_vertex; HalfEdge::new(curve, boundary, start_vertex, self.global_form) } From 64d7fc58f67a9929e9caa92307edd00018ad5442 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 16:42:19 +0100 Subject: [PATCH 2/4] Inline variable --- crates/fj-kernel/src/partial/objects/edge.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/partial/objects/edge.rs b/crates/fj-kernel/src/partial/objects/edge.rs index f14008865..140c75dcd 100644 --- a/crates/fj-kernel/src/partial/objects/edge.rs +++ b/crates/fj-kernel/src/partial/objects/edge.rs @@ -78,9 +78,8 @@ impl PartialObject for PartialHalfEdge { let boundary = self.boundary.map(|point| { point.expect("Can't build `HalfEdge` without boundary positions") }); - let start_vertex = self.start_vertex; - HalfEdge::new(curve, boundary, start_vertex, self.global_form) + HalfEdge::new(curve, boundary, self.start_vertex, self.global_form) } } From 63a574d8b4e9bce8ace72a6ce13b59db99bacbc3 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 16:43:26 +0100 Subject: [PATCH 3/4] Remove `VertexBuilder` --- crates/fj-kernel/src/builder/mod.rs | 2 -- crates/fj-kernel/src/builder/vertex.rs | 9 --------- 2 files changed, 11 deletions(-) delete mode 100644 crates/fj-kernel/src/builder/vertex.rs diff --git a/crates/fj-kernel/src/builder/mod.rs b/crates/fj-kernel/src/builder/mod.rs index 8536a7ad6..f88f695c2 100644 --- a/crates/fj-kernel/src/builder/mod.rs +++ b/crates/fj-kernel/src/builder/mod.rs @@ -7,14 +7,12 @@ mod face; mod shell; mod sketch; mod solid; -mod vertex; use std::array; pub use self::{ cycle::CycleBuilder, edge::HalfEdgeBuilder, face::FaceBuilder, shell::ShellBuilder, sketch::SketchBuilder, solid::SolidBuilder, - vertex::VertexBuilder, }; /// Pass objects to a builder method diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs deleted file mode 100644 index c82c42411..000000000 --- a/crates/fj-kernel/src/builder/vertex.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::partial::PartialVertex; - -/// Builder API for [`PartialVertex`] -pub trait VertexBuilder { - // No methods are currently defined. This trait serves as a placeholder, to - // make it clear where to add such methods, once necessary. -} - -impl VertexBuilder for PartialVertex {} From 62ce9288b8647843fa5c099f29681efb69295d10 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 3 Mar 2023 16:44:17 +0100 Subject: [PATCH 4/4] Remove `PartialVertex` --- crates/fj-kernel/src/partial/mod.rs | 1 - crates/fj-kernel/src/partial/objects/mod.rs | 1 - .../fj-kernel/src/partial/objects/vertex.rs | 25 ------------------- crates/fj-kernel/src/partial/traits.rs | 1 - 4 files changed, 28 deletions(-) delete mode 100644 crates/fj-kernel/src/partial/objects/vertex.rs diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index 03de2a081..17e9d8257 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -22,7 +22,6 @@ pub use self::{ shell::PartialShell, sketch::PartialSketch, solid::PartialSolid, - vertex::PartialVertex, }, traits::{HasPartial, PartialObject}, wrapper::{FullToPartialCache, Partial}, diff --git a/crates/fj-kernel/src/partial/objects/mod.rs b/crates/fj-kernel/src/partial/objects/mod.rs index 3fa269749..8928937cb 100644 --- a/crates/fj-kernel/src/partial/objects/mod.rs +++ b/crates/fj-kernel/src/partial/objects/mod.rs @@ -4,4 +4,3 @@ pub mod face; pub mod shell; pub mod sketch; pub mod solid; -pub mod vertex; diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs deleted file mode 100644 index 1f4de0bc4..000000000 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::{ - objects::{Objects, Vertex}, - partial::{FullToPartialCache, PartialObject}, - services::Service, -}; - -/// A partial [`Vertex`] -#[derive(Clone, Debug)] -pub struct PartialVertex {} - -impl PartialObject for PartialVertex { - type Full = Vertex; - - fn new(_: &mut Service) -> Self { - Self {} - } - - fn from_full(_: &Self::Full, _: &mut FullToPartialCache) -> Self { - Self {} - } - - fn build(self, _: &mut Service) -> Self::Full { - Vertex::new() - } -} diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 9e6be6c30..d0ff79827 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -42,5 +42,4 @@ impl_trait!( Shell, PartialShell; Sketch, PartialSketch; Solid, PartialSolid; - Vertex, PartialVertex; );