From fe5e0b48d404d68016ee37721a026def8c517249 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 11 Oct 2022 13:20:49 +0200 Subject: [PATCH] Remove redundant constructors Not only are they redundant, they also present a danger of duplicating those default surfaces. --- crates/fj-kernel/src/objects/mod.rs | 16 ++++++++++++---- crates/fj-kernel/src/objects/surface.rs | 24 ------------------------ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/crates/fj-kernel/src/objects/mod.rs b/crates/fj-kernel/src/objects/mod.rs index a4350354f..7f6ccc080 100644 --- a/crates/fj-kernel/src/objects/mod.rs +++ b/crates/fj-kernel/src/objects/mod.rs @@ -95,7 +95,12 @@ pub use self::{ vertex::{GlobalVertex, SurfaceVertex, Vertex}, }; -use crate::storage::{Handle, Store}; +use fj_math::Vector; + +use crate::{ + path::GlobalPath, + storage::{Handle, Store}, +}; /// The available object stores /// @@ -163,9 +168,12 @@ impl Default for Surfaces { fn default() -> Self { let store = Store::new(); - let xy_plane = store.insert(Surface::xy_plane()); - let xz_plane = store.insert(Surface::xz_plane()); - let yz_plane = store.insert(Surface::yz_plane()); + let xy_plane = + store.insert(Surface::new(GlobalPath::x_axis(), Vector::unit_y())); + let xz_plane = + store.insert(Surface::new(GlobalPath::x_axis(), Vector::unit_z())); + let yz_plane = + store.insert(Surface::new(GlobalPath::y_axis(), Vector::unit_z())); Self { store, diff --git a/crates/fj-kernel/src/objects/surface.rs b/crates/fj-kernel/src/objects/surface.rs index 2aa731074..6da597626 100644 --- a/crates/fj-kernel/src/objects/surface.rs +++ b/crates/fj-kernel/src/objects/surface.rs @@ -16,30 +16,6 @@ impl Surface { Self { u, v } } - /// Construct a `Surface` that represents the xy-plane - pub fn xy_plane() -> Self { - Self { - u: GlobalPath::x_axis(), - v: Vector::unit_y(), - } - } - - /// Construct a `Surface` that represents the xz-plane - pub fn xz_plane() -> Self { - Self { - u: GlobalPath::x_axis(), - v: Vector::unit_z(), - } - } - - /// Construct a `Surface` that represents the yz-plane - pub fn yz_plane() -> Self { - Self { - u: GlobalPath::y_axis(), - v: Vector::unit_z(), - } - } - /// Construct a plane from 3 points pub fn plane_from_points(points: [impl Into>; 3]) -> Self { let [a, b, c] = points.map(Into::into);