Skip to content

Commit

Permalink
Remove SurfaceVertex/PartialSurfaceVertex
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 2, 2023
1 parent 78c6953 commit ac4285a
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 98 deletions.
18 changes: 1 addition & 17 deletions crates/fj-kernel/src/algorithms/transform/vertex.rs
Original file line number Diff line number Diff line change
@@ -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<Objects>,
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,
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use self::{
sketch::SketchBuilder,
solid::SolidBuilder,
surface::SurfaceBuilder,
vertex::{GlobalVertexBuilder, SurfaceVertexBuilder},
vertex::GlobalVertexBuilder,
};

/// Pass objects to a builder method
Expand Down
10 changes: 1 addition & 9 deletions crates/fj-kernel/src/builder/vertex.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions crates/fj-kernel/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -42,6 +42,5 @@ impl_insert!(
Shell, shells;
Sketch, sketches;
Solid, solids;
SurfaceVertex, surface_vertices;
Surface, surfaces;
);
20 changes: 0 additions & 20 deletions crates/fj-kernel/src/objects/full/vertex.rs
Original file line number Diff line number Diff line change
@@ -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<GlobalVertex>,
}

impl SurfaceVertex {
/// Construct a new instance of `SurfaceVertex`
pub fn new(global_form: Handle<GlobalVertex>) -> Self {
Self { global_form }
}

/// Access the global form of the vertex
pub fn global_form(&self) -> &Handle<GlobalVertex> {
&self.global_form
}
}

/// A vertex, defined in global (3D) coordinates
///
/// This struct exists to distinguish between vertices and points at the type
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
3 changes: 1 addition & 2 deletions crates/fj-kernel/src/objects/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions crates/fj-kernel/src/objects/stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{

use super::{
Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Shell, Sketch, Solid,
Surface, SurfaceVertex,
Surface,
};

/// The available object stores
Expand Down Expand Up @@ -37,9 +37,6 @@ pub struct Objects {
/// Store for [`Solid`]s
pub solids: Store<Solid>,

/// Store for [`SurfaceVertex`] objects
pub surface_vertices: Store<SurfaceVertex>,

/// Store for [`Surface`]s
pub surfaces: Surfaces,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/partial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use self::{
sketch::PartialSketch,
solid::PartialSolid,
surface::PartialSurface,
vertex::{PartialGlobalVertex, PartialSurfaceVertex},
vertex::PartialGlobalVertex,
},
traits::{HasPartial, PartialObject},
wrapper::{FullToPartialCache, Partial},
Expand Down
32 changes: 2 additions & 30 deletions crates/fj-kernel/src/partial/objects/vertex.rs
Original file line number Diff line number Diff line change
@@ -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<GlobalVertex>,
}

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<Objects>) -> Self::Full {
let global_form = self.global_form.build(objects);
SurfaceVertex::new(global_form)
}
}

/// A partial [`GlobalVertex`]
#[derive(Clone, Debug, Default)]
pub struct PartialGlobalVertex {
Expand Down
1 change: 0 additions & 1 deletion crates/fj-kernel/src/partial/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ impl_trait!(
Sketch, PartialSketch;
Solid, PartialSolid;
Surface, PartialSurface;
SurfaceVertex, PartialSurfaceVertex;
);
11 changes: 1 addition & 10 deletions crates/fj-kernel/src/validate/vertex.rs
Original file line number Diff line number Diff line change
@@ -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<ValidationError>,
) {
}
}

impl Validate for GlobalVertex {
fn validate_with_config(
&self,
Expand Down

0 comments on commit ac4285a

Please sign in to comment.