From 96cf194f7f2941da8c186cd527ee4e0fa83a2bbe Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 2 Mar 2023 15:09:16 +0100 Subject: [PATCH] Remove `SurfaceVertex`/`PartialSurfaceVertex` --- .../src/algorithms/transform/vertex.rs | 18 +---------- crates/fj-kernel/src/builder/mod.rs | 2 +- crates/fj-kernel/src/builder/vertex.rs | 10 +----- crates/fj-kernel/src/insert.rs | 3 +- crates/fj-kernel/src/objects/full/vertex.rs | 20 ------------ crates/fj-kernel/src/objects/mod.rs | 2 +- crates/fj-kernel/src/objects/object.rs | 3 +- crates/fj-kernel/src/objects/stores.rs | 5 +-- crates/fj-kernel/src/partial/mod.rs | 2 +- .../fj-kernel/src/partial/objects/vertex.rs | 32 ++----------------- crates/fj-kernel/src/partial/traits.rs | 1 - crates/fj-kernel/src/validate/vertex.rs | 11 +------ 12 files changed, 11 insertions(+), 98 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/transform/vertex.rs b/crates/fj-kernel/src/algorithms/transform/vertex.rs index c88109ba1c..a4c31e8e80 100644 --- a/crates/fj-kernel/src/algorithms/transform/vertex.rs +++ b/crates/fj-kernel/src/algorithms/transform/vertex.rs @@ -1,28 +1,12 @@ use fj_math::Transform; use crate::{ - objects::{GlobalVertex, Objects, SurfaceVertex}, + objects::{GlobalVertex, Objects}, services::Service, }; use super::{TransformCache, TransformObject}; -impl TransformObject for SurfaceVertex { - fn transform_with_cache( - self, - transform: &Transform, - objects: &mut Service, - cache: &mut TransformCache, - ) -> Self { - let global_form = self - .global_form() - .clone() - .transform_with_cache(transform, objects, cache); - - Self::new(global_form) - } -} - impl TransformObject for GlobalVertex { fn transform_with_cache( self, diff --git a/crates/fj-kernel/src/builder/mod.rs b/crates/fj-kernel/src/builder/mod.rs index 6df6f9b939..a63837d4b5 100644 --- a/crates/fj-kernel/src/builder/mod.rs +++ b/crates/fj-kernel/src/builder/mod.rs @@ -20,7 +20,7 @@ pub use self::{ sketch::SketchBuilder, solid::SolidBuilder, surface::SurfaceBuilder, - vertex::{GlobalVertexBuilder, SurfaceVertexBuilder}, + vertex::GlobalVertexBuilder, }; /// Pass objects to a builder method diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index 299a1ff0a6..3c38f5c69a 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -1,12 +1,4 @@ -use crate::partial::{PartialGlobalVertex, PartialSurfaceVertex}; - -/// Builder API for [`PartialSurfaceVertex`] -pub trait SurfaceVertexBuilder { - // No methods are currently defined. This trait serves as a placeholder, to - // make it clear where to add such methods, once necessary. -} - -impl SurfaceVertexBuilder for PartialSurfaceVertex {} +use crate::partial::PartialGlobalVertex; /// Builder API for [`PartialGlobalVertex`] pub trait GlobalVertexBuilder { diff --git a/crates/fj-kernel/src/insert.rs b/crates/fj-kernel/src/insert.rs index 65e1dadf24..30a5a9805d 100644 --- a/crates/fj-kernel/src/insert.rs +++ b/crates/fj-kernel/src/insert.rs @@ -5,7 +5,7 @@ use crate::{ objects::{ Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Objects, Shell, - Sketch, Solid, Surface, SurfaceVertex, + Sketch, Solid, Surface, }, services::{Service, ServiceObjectsExt}, storage::Handle, @@ -42,6 +42,5 @@ impl_insert!( Shell, shells; Sketch, sketches; Solid, solids; - SurfaceVertex, surface_vertices; Surface, surfaces; ); diff --git a/crates/fj-kernel/src/objects/full/vertex.rs b/crates/fj-kernel/src/objects/full/vertex.rs index a34591ce7a..d7193494c7 100644 --- a/crates/fj-kernel/src/objects/full/vertex.rs +++ b/crates/fj-kernel/src/objects/full/vertex.rs @@ -1,25 +1,5 @@ use fj_math::Point; -use crate::storage::Handle; - -/// A vertex, defined in surface (2D) coordinates -#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub struct SurfaceVertex { - global_form: Handle, -} - -impl SurfaceVertex { - /// Construct a new instance of `SurfaceVertex` - pub fn new(global_form: Handle) -> Self { - Self { global_form } - } - - /// Access the global form of the vertex - pub fn global_form(&self) -> &Handle { - &self.global_form - } -} - /// A vertex, defined in global (3D) coordinates /// /// This struct exists to distinguish between vertices and points at the type diff --git a/crates/fj-kernel/src/objects/mod.rs b/crates/fj-kernel/src/objects/mod.rs index 0e7e590e2d..9a0be67961 100644 --- a/crates/fj-kernel/src/objects/mod.rs +++ b/crates/fj-kernel/src/objects/mod.rs @@ -86,7 +86,7 @@ pub use self::{ sketch::Sketch, solid::Solid, surface::Surface, - vertex::{GlobalVertex, SurfaceVertex}, + vertex::GlobalVertex, }, object::{Bare, BehindHandle, Form, Object, WithHandle}, stores::{Objects, Surfaces}, diff --git a/crates/fj-kernel/src/objects/object.rs b/crates/fj-kernel/src/objects/object.rs index 0a3162e41c..742795b62c 100644 --- a/crates/fj-kernel/src/objects/object.rs +++ b/crates/fj-kernel/src/objects/object.rs @@ -3,7 +3,7 @@ use std::any::Any; use crate::{ objects::{ Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Objects, Shell, - Sketch, Solid, Surface, SurfaceVertex, + Sketch, Solid, Surface, }, storage::{Handle, ObjectId}, validate::{Validate, ValidationError}, @@ -117,7 +117,6 @@ object!( Sketch, "sketch", sketches; Solid, "solid", solids; Surface, "surface", surfaces; - SurfaceVertex, "surface vertex", surface_vertices; ); /// The form that an object can take diff --git a/crates/fj-kernel/src/objects/stores.rs b/crates/fj-kernel/src/objects/stores.rs index 7e22728437..c5351b6a94 100644 --- a/crates/fj-kernel/src/objects/stores.rs +++ b/crates/fj-kernel/src/objects/stores.rs @@ -7,7 +7,7 @@ use crate::{ use super::{ Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Shell, Sketch, Solid, - Surface, SurfaceVertex, + Surface, }; /// The available object stores @@ -37,9 +37,6 @@ pub struct Objects { /// Store for [`Solid`]s pub solids: Store, - /// Store for [`SurfaceVertex`] objects - pub surface_vertices: Store, - /// Store for [`Surface`]s pub surfaces: Surfaces, } diff --git a/crates/fj-kernel/src/partial/mod.rs b/crates/fj-kernel/src/partial/mod.rs index 693cfd3e1d..2636c340cd 100644 --- a/crates/fj-kernel/src/partial/mod.rs +++ b/crates/fj-kernel/src/partial/mod.rs @@ -24,7 +24,7 @@ pub use self::{ sketch::PartialSketch, solid::PartialSolid, surface::PartialSurface, - vertex::{PartialGlobalVertex, PartialSurfaceVertex}, + vertex::PartialGlobalVertex, }, traits::{HasPartial, PartialObject}, wrapper::{FullToPartialCache, Partial}, diff --git a/crates/fj-kernel/src/partial/objects/vertex.rs b/crates/fj-kernel/src/partial/objects/vertex.rs index 1fd0b74ca2..907bfbf484 100644 --- a/crates/fj-kernel/src/partial/objects/vertex.rs +++ b/crates/fj-kernel/src/partial/objects/vertex.rs @@ -1,39 +1,11 @@ use fj_math::Point; use crate::{ - objects::{GlobalVertex, Objects, SurfaceVertex}, - partial::{FullToPartialCache, Partial, PartialObject}, + objects::{GlobalVertex, Objects}, + partial::{FullToPartialCache, PartialObject}, services::Service, }; -/// A partial [`SurfaceVertex`] -#[derive(Clone, Debug, Default)] -pub struct PartialSurfaceVertex { - /// The global form of the vertex - pub global_form: Partial, -} - -impl PartialObject for PartialSurfaceVertex { - type Full = SurfaceVertex; - - fn from_full( - surface_vertex: &Self::Full, - cache: &mut FullToPartialCache, - ) -> Self { - Self { - global_form: Partial::from_full( - surface_vertex.global_form().clone(), - cache, - ), - } - } - - fn build(self, objects: &mut Service) -> Self::Full { - let global_form = self.global_form.build(objects); - SurfaceVertex::new(global_form) - } -} - /// A partial [`GlobalVertex`] #[derive(Clone, Debug, Default)] pub struct PartialGlobalVertex { diff --git a/crates/fj-kernel/src/partial/traits.rs b/crates/fj-kernel/src/partial/traits.rs index 93670c1a38..23cd49679f 100644 --- a/crates/fj-kernel/src/partial/traits.rs +++ b/crates/fj-kernel/src/partial/traits.rs @@ -42,5 +42,4 @@ impl_trait!( Sketch, PartialSketch; Solid, PartialSolid; Surface, PartialSurface; - SurfaceVertex, PartialSurfaceVertex; ); diff --git a/crates/fj-kernel/src/validate/vertex.rs b/crates/fj-kernel/src/validate/vertex.rs index bcad84f247..df3415c93e 100644 --- a/crates/fj-kernel/src/validate/vertex.rs +++ b/crates/fj-kernel/src/validate/vertex.rs @@ -1,16 +1,7 @@ -use crate::objects::{GlobalVertex, SurfaceVertex}; +use crate::objects::GlobalVertex; use super::{Validate, ValidationConfig, ValidationError}; -impl Validate for SurfaceVertex { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } -} - impl Validate for GlobalVertex { fn validate_with_config( &self,