diff --git a/crates/fj-kernel/src/builder/cycle.rs b/crates/fj-kernel/src/builder/cycle.rs index 2247f9c1e..4fb5e7659 100644 --- a/crates/fj-kernel/src/builder/cycle.rs +++ b/crates/fj-kernel/src/builder/cycle.rs @@ -35,19 +35,6 @@ pub trait CycleBuilder { point: impl Into>, ) -> Partial; - /// Add a new half-edge that starts at the provided point - /// - /// Opens the cycle between the last and first edge, updates the last edge - /// to go the provided point, and adds a new half-edge from the provided - /// point the the first edge. - /// - /// If the cycle doesn't have any edges yet, the new edge connects to - /// itself, starting and ending at the provided point. - fn add_half_edge_from_global_point_to_start( - &mut self, - point: impl Into>, - ) -> Partial; - /// Update cycle as a polygon from the provided points fn update_as_polygon_from_points( &mut self, @@ -135,21 +122,6 @@ impl CycleBuilder for PartialCycle { half_edge } - fn add_half_edge_from_global_point_to_start( - &mut self, - point: impl Into>, - ) -> Partial { - let mut half_edge = self.add_half_edge(); - half_edge - .write() - .start_vertex - .write() - .global_form - .write() - .position = Some(point.into()); - half_edge - } - fn update_as_polygon_from_points( &mut self, points: O, diff --git a/crates/fj-kernel/src/builder/edge.rs b/crates/fj-kernel/src/builder/edge.rs index 499ef479a..b061d3ecb 100644 --- a/crates/fj-kernel/src/builder/edge.rs +++ b/crates/fj-kernel/src/builder/edge.rs @@ -12,16 +12,6 @@ use crate::{ /// Builder API for [`PartialHalfEdge`] pub trait HalfEdgeBuilder { - /// Update partial half-edge to represent the u-axis of the surface it is on - /// - /// Returns the updated path. - fn update_as_u_axis(&mut self) -> Curve; - - /// Update partial curve to represent the v-axis of the surface it is on - /// - /// Returns the updated path. - fn update_as_v_axis(&mut self) -> Curve; - /// Update partial half-edge to be a circle, from the given radius fn update_as_circle_from_radius( &mut self, @@ -86,18 +76,6 @@ pub trait HalfEdgeBuilder { } impl HalfEdgeBuilder for PartialHalfEdge { - fn update_as_u_axis(&mut self) -> Curve { - let path = Curve::u_axis(); - self.curve = Some(path.into()); - path - } - - fn update_as_v_axis(&mut self) -> Curve { - let path = Curve::v_axis(); - self.curve = Some(path.into()); - path - } - fn update_as_circle_from_radius( &mut self, radius: impl Into, diff --git a/crates/fj-kernel/src/builder/face.rs b/crates/fj-kernel/src/builder/face.rs index 89037ca7f..9dd4b5502 100644 --- a/crates/fj-kernel/src/builder/face.rs +++ b/crates/fj-kernel/src/builder/face.rs @@ -1,35 +1,12 @@ -use std::{array, collections::VecDeque}; - -use fj_interop::ext::ArrayExt; -use itertools::Itertools; - use crate::{ - geometry::curve::Curve, - objects::{Cycle, Surface}, - partial::{MaybeCurve, Partial, PartialFace}, + objects::Cycle, + partial::{Partial, PartialFace}, }; -use super::SurfaceBuilder; - /// Builder API for [`PartialFace`] pub trait FaceBuilder { /// Add an interior cycle fn add_interior(&mut self) -> Partial; - - /// Update the face's surface as a plane - /// - /// The plane geometry is inferred from three of the face's vertices. Also - /// infers any undefined `SurfaceVertex` positions. - /// - /// # Panics - /// - /// Assumes that the face exterior has exactly three vertices to use. Panics - /// otherwise. This is a temporary limitation, not a fundamental one. It - /// could be overcome with some more work. - fn update_surface_as_plane(&mut self) -> Partial; - - /// Infer any undefined curves in the face - fn infer_curves(&mut self); } impl FaceBuilder for PartialFace { @@ -38,106 +15,4 @@ impl FaceBuilder for PartialFace { self.interiors.push(cycle.clone()); cycle } - - fn update_surface_as_plane(&mut self) -> Partial { - let exterior = self.exterior.read(); - let mut vertices = exterior - .half_edges - .iter() - .map(|half_edge| { - let surface_vertex = &half_edge.read().start_vertex; - let global_position = surface_vertex - .read() - .global_form - .read() - .position - .expect("Need global position to infer plane"); - - (surface_vertex.clone(), global_position) - }) - .collect::>(); - - let (significant_vertices, surface) = { - let first_three_vertices = array::from_fn(|_| { - vertices - .pop_front() - .expect("Expected at least three vertices") - }); - - let first_three_points_global = - first_three_vertices.each_ref_ext().map(|(_, point)| *point); - - let (first_three_points_surface, surface) = self - .surface - .write() - .update_as_plane_from_points(first_three_points_global); - - let first_three_vertices = first_three_vertices - .zip_ext(first_three_points_surface) - .map(|((vertex, _), point_global)| (vertex, point_global)); - - (first_three_vertices, surface) - }; - let rest_of_vertices = - vertices.into_iter().map(|(vertex, point_global)| { - let point_surface = surface.project_global_point(point_global); - (vertex, point_surface) - }); - - for (mut surface_vertex, point) in - significant_vertices.into_iter().chain(rest_of_vertices) - { - surface_vertex.write().position = Some(point); - } - - self.surface.clone() - } - - fn infer_curves(&mut self) { - for (mut half_edge, next_half_edge) in self - .exterior - .read() - .half_edges - .iter() - .cloned() - .circular_tuple_windows() - { - let mut half_edge = half_edge.write(); - - let mut curve = half_edge.curve; - - if let Some(path) = &mut curve { - match path { - MaybeCurve::Defined(_) => { - // Path is already defined. Nothing to infer. - } - MaybeCurve::UndefinedCircle { .. } => todo!( - "Inferring undefined circles is not supported yet" - ), - MaybeCurve::UndefinedLine => { - let points_surface = [ - &half_edge.start_vertex, - &next_half_edge.read().start_vertex, - ] - .map(|vertex| { - vertex.read().position.expect( - "Can't infer curve without surface points", - ) - }); - let (line, points_curve) = - Curve::line_from_points(points_surface); - - *path = MaybeCurve::Defined(line); - for (vertex, point) in half_edge - .boundary - .each_mut_ext() - .zip_ext(points_curve) - { - *vertex = Some(point); - } - } - } - } - } - } } diff --git a/crates/fj-kernel/src/builder/shell.rs b/crates/fj-kernel/src/builder/shell.rs index 0369380af..233cc3e81 100644 --- a/crates/fj-kernel/src/builder/shell.rs +++ b/crates/fj-kernel/src/builder/shell.rs @@ -1,21 +1,9 @@ -use crate::{ - objects::Face, - partial::{Partial, PartialShell}, -}; +use crate::partial::PartialShell; /// Builder API for [`PartialShell`] pub trait ShellBuilder { - /// Add a face to the shell - /// - /// The face will not be connected to any other faces that the shell might - /// already have. - fn add_face(&mut self) -> Partial; + // No methods are currently defined. This trait serves as a placeholder, to + // make it clear where to add such methods, once necessary. } -impl ShellBuilder for PartialShell { - fn add_face(&mut self) -> Partial { - let face = Partial::default(); - self.faces.push(face.clone()); - face - } -} +impl ShellBuilder for PartialShell {} diff --git a/crates/fj-kernel/src/builder/sketch.rs b/crates/fj-kernel/src/builder/sketch.rs index c80feb4ec..2a1ccfbd2 100644 --- a/crates/fj-kernel/src/builder/sketch.rs +++ b/crates/fj-kernel/src/builder/sketch.rs @@ -1,18 +1,9 @@ -use crate::{ - objects::Face, - partial::{Partial, PartialSketch}, -}; +use crate::partial::PartialSketch; /// Builder API for [`PartialSketch`] pub trait SketchBuilder { - /// Add a face to the sketch - fn add_face(&mut self) -> Partial; + // No methods are currently defined. This trait serves as a placeholder, to + // make it clear where to add such methods, once necessary. } -impl SketchBuilder for PartialSketch { - fn add_face(&mut self) -> Partial { - let face = Partial::default(); - self.faces.extend([face.clone()]); - face - } -} +impl SketchBuilder for PartialSketch {} diff --git a/crates/fj-kernel/src/builder/surface.rs b/crates/fj-kernel/src/builder/surface.rs index a4a0181f4..7288c0baa 100644 --- a/crates/fj-kernel/src/builder/surface.rs +++ b/crates/fj-kernel/src/builder/surface.rs @@ -1,4 +1,4 @@ -use fj_math::{Point, Scalar, Vector}; +use fj_math::Vector; use crate::{ geometry::{curve::GlobalPath, surface::SurfaceGeometry}, @@ -9,12 +9,6 @@ use crate::{ pub trait SurfaceBuilder: Sized { /// Build a surface from its two axes fn from_axes(u: GlobalPath, v: impl Into>) -> Self; - - /// Construct a plane from 3 points - fn update_as_plane_from_points( - &mut self, - points: [impl Into>; 3], - ) -> ([Point<2>; 3], SurfaceGeometry); } impl SurfaceBuilder for PartialSurface { @@ -25,23 +19,4 @@ impl SurfaceBuilder for PartialSurface { geometry: Some(SurfaceGeometry { u, v }), } } - - fn update_as_plane_from_points( - &mut self, - points: [impl Into>; 3], - ) -> ([Point<2>; 3], SurfaceGeometry) { - let [a, b, c] = points.map(Into::into); - - let (u, u_coords) = GlobalPath::line_from_points([a, b]); - let v = c - a; - - let geometry = SurfaceGeometry { u, v }; - self.geometry = Some(geometry); - - let [a, b] = u_coords.map(|point| point.t); - let points = [[a, Scalar::ZERO], [b, Scalar::ZERO], [a, Scalar::ONE]] - .map(Point::from); - - (points, geometry) - } } diff --git a/crates/fj-kernel/src/builder/vertex.rs b/crates/fj-kernel/src/builder/vertex.rs index 1ff0fdcb1..299a1ff0a 100644 --- a/crates/fj-kernel/src/builder/vertex.rs +++ b/crates/fj-kernel/src/builder/vertex.rs @@ -1,17 +1,17 @@ use crate::partial::{PartialGlobalVertex, PartialSurfaceVertex}; /// Builder API for [`PartialSurfaceVertex`] -pub trait SurfaceVertexBuilder {} - -impl SurfaceVertexBuilder 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. } -/// Builder API for [`PartialGlobalVertex`] -pub trait GlobalVertexBuilder {} +impl SurfaceVertexBuilder for PartialSurfaceVertex {} -impl GlobalVertexBuilder for PartialGlobalVertex { +/// Builder API for [`PartialGlobalVertex`] +pub trait GlobalVertexBuilder { // No methods are currently defined. This trait serves as a placeholder, to // make it clear where to add such methods, once necessary. } + +impl GlobalVertexBuilder for PartialGlobalVertex {}