From a18583d8614a93c1a71ed148bc4ac0b493df2ca4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:23:28 +0200 Subject: [PATCH 01/11] Remove `GlobalEdge`-based validation code The validation checks that contains this code already have redundant code that does the same validation based on `Curve`. This was part of the transition from `GlobalEdge` to `Curve`, which is about to conclude. --- crates/fj-core/src/validate/shell.rs | 61 +--------------------------- 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index eb1f1f328..2f90fe469 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -1,4 +1,4 @@ -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use fj_math::{Point, Scalar}; @@ -6,7 +6,7 @@ use crate::{ geometry::SurfaceGeometry, objects::{HalfEdge, Shell, Surface}, queries::{AllEdgesWithSurface, BoundingVerticesOfEdge}, - storage::{Handle, HandleWrapper, ObjectId}, + storage::{Handle, HandleWrapper}, }; use super::{Validate, ValidationConfig, ValidationError}; @@ -222,9 +222,6 @@ impl ShellValidationError { continue; } - let identical_according_to_global_form = - edge_a.global_form().id() == edge_b.global_form().id(); - let identical_according_to_curve = { let on_same_curve = edge_a.curve().id() == edge_b.curve().id(); @@ -244,11 +241,6 @@ impl ShellValidationError { on_same_curve && have_same_boundary }; - assert_eq!( - identical_according_to_curve, - identical_according_to_global_form, - ); - match identical_according_to_curve { true => { // All points on identical curves should be within @@ -328,61 +320,12 @@ impl ShellValidationError { if num_edges.into_values().any(|num| num != 2) { errors.push(Self::NotWatertight.into()); } - - let mut global_edge_to_faces: HashMap = HashMap::new(); - - for face in shell.faces() { - for cycle in face.region().all_cycles() { - for half_edge in cycle.half_edges() { - let id = half_edge.global_form().id(); - let entry = global_edge_to_faces.entry(id); - *entry.or_insert(0) += 1; - } - } - } - - // Each global edge should have exactly two half edges that are part of - // the shell - if global_edge_to_faces.iter().any(|(_, c)| *c != 2) { - errors.push(Self::NotWatertight.into()) - } } fn validate_same_orientation( shell: &Shell, errors: &mut Vec, ) { - let mut global_to_half: HashMap> = HashMap::new(); - - for face in shell.faces() { - for cycle in face.region().all_cycles() { - for half_edge in cycle.half_edges() { - let id = half_edge.global_form().id(); - global_to_half - .entry(id) - .or_insert(Vec::new()) - .push(half_edge.clone()); - } - } - } - - // In order for the faces to all have the same outside winding global - // edge should have two half edges in opposite directions. - for (_, halfs) in global_to_half { - if let (Some(a), Some(b)) = (halfs.get(0), halfs.get(1)) { - // Check if a is reverse of b - if a.boundary().reverse() != b.boundary() { - errors.push(Self::MixedOrientations.into()); - return; - } - } - } - - // Here's the same check again a second time, except using `Curve` - // instead of `GlobalEdge`. This redundancy can be fixed once the - // transition from `Curve` to `GlobalEdge` is finished, and `GlobalEdge` - // can be removed. - let mut edges_by_coincidence = BTreeMap::new(); for face in shell.faces() { From 3dc62a7ad92d6f5692b3260797d6f79dbf7ee9c7 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:24:56 +0200 Subject: [PATCH 02/11] Simplify variable name --- crates/fj-core/src/validate/shell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 2f90fe469..e0bcec210 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -222,7 +222,7 @@ impl ShellValidationError { continue; } - let identical_according_to_curve = { + let identical = { let on_same_curve = edge_a.curve().id() == edge_b.curve().id(); @@ -241,7 +241,7 @@ impl ShellValidationError { on_same_curve && have_same_boundary }; - match identical_according_to_curve { + match identical { true => { // All points on identical curves should be within // identical_max_distance, so we shouldn't have any From 576bb58283411446d044f9348b1d84d0f1e4f056 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:26:07 +0200 Subject: [PATCH 03/11] Remove `UpdateHalfEdge::replace_global_form` Replacing the global form is no longer necessary, as `GlobalEdge` no longer fulfills any role. --- crates/fj-core/src/algorithms/sweep/edge.rs | 57 ++++++++------------ crates/fj-core/src/operations/join/cycle.rs | 2 - crates/fj-core/src/operations/update/edge.rs | 16 +----- crates/fj-core/src/validate/shell.rs | 5 +- 4 files changed, 25 insertions(+), 55 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/edge.rs b/crates/fj-core/src/algorithms/sweep/edge.rs index 0d0c74125..93ec97a49 100644 --- a/crates/fj-core/src/algorithms/sweep/edge.rs +++ b/crates/fj-core/src/algorithms/sweep/edge.rs @@ -86,44 +86,33 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { .zip_ext(vertices) .zip_ext(curves) .zip_ext(global_edges) - .map( - |( - ((((boundary, start), end), start_vertex), curve), - global_edge, - )| { - let half_edge = { - let half_edge = HalfEdge::line_segment( - [start, end], - Some(boundary), - services, - ) - .replace_start_vertex(start_vertex); + .map(|(((((boundary, start), end), start_vertex), curve), _)| { + let half_edge = { + let half_edge = HalfEdge::line_segment( + [start, end], + Some(boundary), + services, + ) + .replace_start_vertex(start_vertex); - let half_edge = if let Some(curve) = curve { - half_edge.replace_curve(curve) - } else { - half_edge - }; - - let half_edge = if let Some(global_edge) = global_edge { - half_edge.replace_global_form(global_edge) - } else { - half_edge - }; - - half_edge.insert(services) + let half_edge = if let Some(curve) = curve { + half_edge.replace_curve(curve) + } else { + half_edge }; - exterior = Some( - exterior - .take() - .unwrap() - .add_half_edges([half_edge.clone()]), - ); + half_edge.insert(services) + }; - half_edge - }, - ); + exterior = Some( + exterior + .take() + .unwrap() + .add_half_edges([half_edge.clone()]), + ); + + half_edge + }); let region = Region::new(exterior.unwrap().insert(services), [], color) .insert(services); diff --git a/crates/fj-core/src/operations/join/cycle.rs b/crates/fj-core/src/operations/join/cycle.rs index c7320dc85..af83d8306 100644 --- a/crates/fj-core/src/operations/join/cycle.rs +++ b/crates/fj-core/src/operations/join/cycle.rs @@ -86,7 +86,6 @@ impl JoinCycle for Cycle { HalfEdge::unjoined(curve, boundary, services) .replace_curve(half_edge.curve().clone()) .replace_start_vertex(prev.start_vertex().clone()) - .replace_global_form(half_edge.global_form().clone()) .insert(services) }, )) @@ -132,7 +131,6 @@ impl JoinCycle for Cycle { let this_joined = half_edge .replace_curve(half_edge_other.curve().clone()) .replace_start_vertex(vertex_a) - .replace_global_form(half_edge_other.global_form().clone()) .insert(services); let next_joined = next_edge.replace_start_vertex(vertex_b).insert(services); diff --git a/crates/fj-core/src/operations/update/edge.rs b/crates/fj-core/src/operations/update/edge.rs index 3a415897d..999b932db 100644 --- a/crates/fj-core/src/operations/update/edge.rs +++ b/crates/fj-core/src/operations/update/edge.rs @@ -2,7 +2,7 @@ use fj_math::Point; use crate::{ geometry::{CurveBoundary, SurfacePath}, - objects::{Curve, GlobalEdge, HalfEdge, Vertex}, + objects::{Curve, HalfEdge, Vertex}, storage::Handle, }; @@ -23,10 +23,6 @@ pub trait UpdateHalfEdge { /// Replace the start vertex of the half-edge #[must_use] fn replace_start_vertex(&self, start_vertex: Handle) -> Self; - - /// Replace the global form of the half-edge - #[must_use] - fn replace_global_form(&self, global_form: Handle) -> Self; } impl UpdateHalfEdge for HalfEdge { @@ -69,14 +65,4 @@ impl UpdateHalfEdge for HalfEdge { self.global_form().clone(), ) } - - fn replace_global_form(&self, global_form: Handle) -> Self { - HalfEdge::new( - self.path(), - self.boundary(), - self.curve().clone(), - self.start_vertex().clone(), - global_form, - ) - } } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index e0bcec210..e9635e45e 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -377,7 +377,7 @@ pub struct CurveCoordinateSystemMismatch { mod tests { use crate::{ assert_contains_err, - objects::{Curve, GlobalEdge, Shell}, + objects::{Curve, Shell}, operations::{ BuildShell, Insert, Reverse, UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion, UpdateShell, @@ -451,12 +451,9 @@ mod tests { .update_nth_half_edge(0, |half_edge| { let curve = Curve::new().insert(&mut services); - let global_form = - GlobalEdge::new().insert(&mut services); half_edge .replace_curve(curve) - .replace_global_form(global_form) .insert(&mut services) }) .insert(&mut services) From e7982aab71f1a23726a8c88787bafcb4ae426858 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:27:58 +0200 Subject: [PATCH 04/11] Remove unused argument --- crates/fj-core/src/algorithms/sweep/edge.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/edge.rs b/crates/fj-core/src/algorithms/sweep/edge.rs index 93ec97a49..dc6c23b66 100644 --- a/crates/fj-core/src/algorithms/sweep/edge.rs +++ b/crates/fj-core/src/algorithms/sweep/edge.rs @@ -27,7 +27,7 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { // Next, we need to define the boundaries of the face. Let's start with // the global vertices and edges. - let (vertices, global_edges, curves) = { + let (vertices, _, curves) = { let [a, b] = [edge.start_vertex(), next_vertex].map(Clone::clone); let (curve_up, edge_up, [_, c]) = b.clone().sweep_with_cache(path, cache, services); @@ -85,8 +85,7 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { .zip_ext(surface_points_next) .zip_ext(vertices) .zip_ext(curves) - .zip_ext(global_edges) - .map(|(((((boundary, start), end), start_vertex), curve), _)| { + .map(|((((boundary, start), end), start_vertex), curve)| { let half_edge = { let half_edge = HalfEdge::line_segment( [start, end], From c6736274ccfb20d24940dbf956a8c70124f1085a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:28:48 +0200 Subject: [PATCH 05/11] Remove unused code --- crates/fj-core/src/algorithms/sweep/edge.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/edge.rs b/crates/fj-core/src/algorithms/sweep/edge.rs index dc6c23b66..111e1cf49 100644 --- a/crates/fj-core/src/algorithms/sweep/edge.rs +++ b/crates/fj-core/src/algorithms/sweep/edge.rs @@ -27,21 +27,15 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { // Next, we need to define the boundaries of the face. Let's start with // the global vertices and edges. - let (vertices, _, curves) = { + let (vertices, curves) = { let [a, b] = [edge.start_vertex(), next_vertex].map(Clone::clone); - let (curve_up, edge_up, [_, c]) = + let (curve_up, _, [_, c]) = b.clone().sweep_with_cache(path, cache, services); - let (curve_down, edge_down, [_, d]) = + let (curve_down, _, [_, d]) = a.clone().sweep_with_cache(path, cache, services); ( [a, b, c, d], - [ - Some(edge.global_form().clone()), - Some(edge_up), - None, - Some(edge_down), - ], [ Some(edge.curve().clone()), Some(curve_up), From a83d3ca579188d69417b2cd2b95893331729a18f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:29:56 +0200 Subject: [PATCH 06/11] Remove unused return value --- crates/fj-core/src/algorithms/sweep/edge.rs | 4 ++-- crates/fj-core/src/algorithms/sweep/vertex.rs | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/edge.rs b/crates/fj-core/src/algorithms/sweep/edge.rs index 111e1cf49..f1a10d35a 100644 --- a/crates/fj-core/src/algorithms/sweep/edge.rs +++ b/crates/fj-core/src/algorithms/sweep/edge.rs @@ -29,9 +29,9 @@ impl Sweep for (&HalfEdge, &Handle, &Surface, Option) { // the global vertices and edges. let (vertices, curves) = { let [a, b] = [edge.start_vertex(), next_vertex].map(Clone::clone); - let (curve_up, _, [_, c]) = + let (curve_up, [_, c]) = b.clone().sweep_with_cache(path, cache, services); - let (curve_down, _, [_, d]) = + let (curve_down, [_, d]) = a.clone().sweep_with_cache(path, cache, services); ( diff --git a/crates/fj-core/src/algorithms/sweep/vertex.rs b/crates/fj-core/src/algorithms/sweep/vertex.rs index e61982bd3..91cdb7767 100644 --- a/crates/fj-core/src/algorithms/sweep/vertex.rs +++ b/crates/fj-core/src/algorithms/sweep/vertex.rs @@ -1,7 +1,7 @@ use fj_math::Vector; use crate::{ - objects::{Curve, GlobalEdge, Vertex}, + objects::{Curve, Vertex}, operations::Insert, services::Services, storage::Handle, @@ -10,7 +10,7 @@ use crate::{ use super::{Sweep, SweepCache}; impl Sweep for Handle { - type Swept = (Handle, Handle, [Self; 2]); + type Swept = (Handle, [Self; 2]); fn sweep_with_cache( self, @@ -32,12 +32,6 @@ impl Sweep for Handle { .clone(); let vertices = [a, b]; - let global_edge = cache - .global_edges - .entry(self.id()) - .or_insert_with(|| GlobalEdge::new().insert(services)) - .clone(); - - (curve, global_edge, vertices) + (curve, vertices) } } From 98ff9b60713671cfeb075bd6c1ee0d06be3df2c4 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:30:48 +0200 Subject: [PATCH 07/11] Remove unused struct field --- crates/fj-core/src/algorithms/sweep/mod.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/fj-core/src/algorithms/sweep/mod.rs b/crates/fj-core/src/algorithms/sweep/mod.rs index 3f759e9e5..04d808895 100644 --- a/crates/fj-core/src/algorithms/sweep/mod.rs +++ b/crates/fj-core/src/algorithms/sweep/mod.rs @@ -11,7 +11,7 @@ use std::collections::BTreeMap; use fj_math::Vector; use crate::{ - objects::{Curve, GlobalEdge, Vertex}, + objects::{Curve, Vertex}, services::Services, storage::{Handle, ObjectId}, }; @@ -50,7 +50,4 @@ pub struct SweepCache { /// Cache for vertices pub vertices: BTreeMap>, - - /// Cache for global edges - pub global_edges: BTreeMap>, } From 01b8c2c23076efade763ff3c1c54b66bc9b7c53d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:46:36 +0200 Subject: [PATCH 08/11] Update doc comment --- crates/fj-core/src/objects/kinds/edge.rs | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index 419e2b2b6..3411e17a1 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -8,30 +8,21 @@ use crate::{ /// A directed edge, defined in a surface's 2D space /// -/// The concept of an "edge" in Fornjot is represented by two structs, -/// `HalfEdge` and [`GlobalEdge`]. `HalfEdge` has two attributes that make it -/// distinct from [`GlobalEdge`]: -/// -/// - `HalfEdge` is directed, meaning it has a defined start and end vertex. -/// - `HalfEdge` is defined in the 2-dimensional space of a surface. -/// /// When multiple faces, which are bound by edges, are combined to form a solid, /// the `HalfEdge`s that bound the face on the surface are then coincident with /// the `HalfEdge`s of other faces, where those faces touch. Those coincident -/// `HalfEdge`s are different representations of the same edge. This edge is -/// represented by an instance of [`GlobalEdge`]. +/// `HalfEdge`s are different representations of the same edge, and this fact +/// must be represented in the following way: /// -/// There are some requirements that a `HalfEdge` needs to uphold to be valid: +/// - The coincident `HalfEdge`s must refer to the same `Curve`. +/// - The coincident `HalfEdge`s must have the same boundary. /// -/// 1. Coincident `HalfEdge`s *must* refer to the same [`GlobalEdge`]. -/// 2. `HalfEdge`s that are coincident, i.e. located in the same space, must -/// always be congruent. This means they must coincide *exactly*. The overlap -/// must be complete. None of the coincident `HalfEdge`s must overlap with -/// just a section of another. +/// There is another, implicit requirement hidden here: /// -/// That second requirement means that a `HalfEdge` might need to be split into -/// multiple smaller `HalfEdge`s that are each coincident with a `HalfEdge` in -/// another face. +/// `HalfEdge`s that are coincident, i.e. located in the same space, must always +/// be congruent. This means they must coincide *exactly*. The overlap must be +/// complete. None of the coincident `HalfEdge`s must overlap with just a +/// section of another. /// /// # Implementation Note /// From 9a672630dd334ff7fcb00c47f82dd0035998e9ef Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:47:14 +0200 Subject: [PATCH 09/11] Update implementation note --- crates/fj-core/src/objects/kinds/edge.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index 3411e17a1..66de90fb9 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -26,9 +26,9 @@ use crate::{ /// /// # Implementation Note /// -/// There is currently no validation code to verify that coincident `HalfEdge`s -/// are congruent: -/// +/// The limitation that coincident `HalfEdge`s must be congruent is currently +/// being lifted: +/// #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct HalfEdge { path: SurfacePath, From f24abc989de9b234b0356f3556a5a9adb2136803 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:32:05 +0200 Subject: [PATCH 10/11] Remove reference to `GlobalEdge` from `HalfEdge` --- crates/fj-core/src/algorithms/transform/edge.rs | 6 +----- crates/fj-core/src/objects/kinds/edge.rs | 8 -------- crates/fj-core/src/objects/set.rs | 3 --- crates/fj-core/src/operations/build/edge.rs | 5 ++--- crates/fj-core/src/operations/reverse/cycle.rs | 1 - crates/fj-core/src/operations/reverse/edge.rs | 1 - crates/fj-core/src/operations/update/edge.rs | 4 ---- crates/fj-core/src/validate/edge.rs | 1 - 8 files changed, 3 insertions(+), 26 deletions(-) diff --git a/crates/fj-core/src/algorithms/transform/edge.rs b/crates/fj-core/src/algorithms/transform/edge.rs index b690751d1..6b312f648 100644 --- a/crates/fj-core/src/algorithms/transform/edge.rs +++ b/crates/fj-core/src/algorithms/transform/edge.rs @@ -26,12 +26,8 @@ impl TransformObject for HalfEdge { .start_vertex() .clone() .transform_with_cache(transform, services, cache); - let global_form = self - .global_form() - .clone() - .transform_with_cache(transform, services, cache); - Self::new(path, boundary, curve, start_vertex, global_form) + Self::new(path, boundary, curve, start_vertex) } } diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index 66de90fb9..561a49a82 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -35,7 +35,6 @@ pub struct HalfEdge { boundary: CurveBoundary>, curve: HandleWrapper, start_vertex: HandleWrapper, - global_form: HandleWrapper, } impl HalfEdge { @@ -45,14 +44,12 @@ impl HalfEdge { boundary: impl Into>>, curve: Handle, start_vertex: Handle, - global_form: Handle, ) -> Self { Self { path, boundary: boundary.into(), curve: curve.into(), start_vertex: start_vertex.into(), - global_form: global_form.into(), } } @@ -85,11 +82,6 @@ impl HalfEdge { pub fn start_vertex(&self) -> &Handle { &self.start_vertex } - - /// Access the global form of the half-edge - pub fn global_form(&self) -> &Handle { - &self.global_form - } } /// An undirected edge, defined in global (3D) coordinates diff --git a/crates/fj-core/src/objects/set.rs b/crates/fj-core/src/objects/set.rs index 54957b3d9..c2659c40c 100644 --- a/crates/fj-core/src/objects/set.rs +++ b/crates/fj-core/src/objects/set.rs @@ -101,9 +101,6 @@ impl InsertIntoSet for HalfEdge { objects.inner.insert(self.start_vertex().clone().into()); self.start_vertex().insert_into_set(objects); - - objects.inner.insert(self.global_form().clone().into()); - self.global_form().insert_into_set(objects); } } diff --git a/crates/fj-core/src/operations/build/edge.rs b/crates/fj-core/src/operations/build/edge.rs index 0ffe35cff..e017d78ae 100644 --- a/crates/fj-core/src/operations/build/edge.rs +++ b/crates/fj-core/src/operations/build/edge.rs @@ -3,7 +3,7 @@ use fj_math::{Arc, Point, Scalar}; use crate::{ geometry::{CurveBoundary, SurfacePath}, - objects::{Curve, GlobalEdge, HalfEdge, Vertex}, + objects::{Curve, HalfEdge, Vertex}, operations::Insert, services::Services, }; @@ -18,9 +18,8 @@ pub trait BuildHalfEdge { ) -> HalfEdge { let curve = Curve::new().insert(services); let start_vertex = Vertex::new().insert(services); - let global_form = GlobalEdge::new().insert(services); - HalfEdge::new(path, boundary, curve, start_vertex, global_form) + HalfEdge::new(path, boundary, curve, start_vertex) } /// Create an arc diff --git a/crates/fj-core/src/operations/reverse/cycle.rs b/crates/fj-core/src/operations/reverse/cycle.rs index e998dde11..32421c724 100644 --- a/crates/fj-core/src/operations/reverse/cycle.rs +++ b/crates/fj-core/src/operations/reverse/cycle.rs @@ -16,7 +16,6 @@ impl Reverse for Cycle { current.boundary().reverse(), current.curve().clone(), next.start_vertex().clone(), - current.global_form().clone(), ) .insert(services) }) diff --git a/crates/fj-core/src/operations/reverse/edge.rs b/crates/fj-core/src/operations/reverse/edge.rs index 7d53ee4c9..3820d0422 100644 --- a/crates/fj-core/src/operations/reverse/edge.rs +++ b/crates/fj-core/src/operations/reverse/edge.rs @@ -12,7 +12,6 @@ impl ReverseCurveCoordinateSystems for HalfEdge { boundary, self.curve().clone(), self.start_vertex().clone(), - self.global_form().clone(), ) } } diff --git a/crates/fj-core/src/operations/update/edge.rs b/crates/fj-core/src/operations/update/edge.rs index 999b932db..48c12fe68 100644 --- a/crates/fj-core/src/operations/update/edge.rs +++ b/crates/fj-core/src/operations/update/edge.rs @@ -32,7 +32,6 @@ impl UpdateHalfEdge for HalfEdge { self.boundary(), self.curve().clone(), self.start_vertex().clone(), - self.global_form().clone(), ) } @@ -42,7 +41,6 @@ impl UpdateHalfEdge for HalfEdge { boundary, self.curve().clone(), self.start_vertex().clone(), - self.global_form().clone(), ) } @@ -52,7 +50,6 @@ impl UpdateHalfEdge for HalfEdge { self.boundary(), curve, self.start_vertex().clone(), - self.global_form().clone(), ) } @@ -62,7 +59,6 @@ impl UpdateHalfEdge for HalfEdge { self.boundary(), self.curve().clone(), start_vertex, - self.global_form().clone(), ) } } diff --git a/crates/fj-core/src/validate/edge.rs b/crates/fj-core/src/validate/edge.rs index 899a33b7b..aa2301720 100644 --- a/crates/fj-core/src/validate/edge.rs +++ b/crates/fj-core/src/validate/edge.rs @@ -97,7 +97,6 @@ mod tests { boundary, valid.curve().clone(), valid.start_vertex().clone(), - valid.global_form().clone(), ) }; From b63cdec936c8c8cbfbee64fd21eba8e807949ffd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 18 Aug 2023 11:33:41 +0200 Subject: [PATCH 11/11] Remove `GlobalEdge` --- .../fj-core/src/algorithms/transform/edge.rs | 19 +---------- crates/fj-core/src/objects/kinds/edge.rs | 32 ------------------- crates/fj-core/src/objects/mod.rs | 2 +- crates/fj-core/src/objects/object.rs | 5 ++- crates/fj-core/src/objects/set.rs | 7 +--- crates/fj-core/src/objects/stores.rs | 6 +--- .../src/operations/insert/insert_trait.rs | 5 ++- crates/fj-core/src/validate/edge.rs | 11 +------ 8 files changed, 9 insertions(+), 78 deletions(-) diff --git a/crates/fj-core/src/algorithms/transform/edge.rs b/crates/fj-core/src/algorithms/transform/edge.rs index 6b312f648..11526bff0 100644 --- a/crates/fj-core/src/algorithms/transform/edge.rs +++ b/crates/fj-core/src/algorithms/transform/edge.rs @@ -1,9 +1,6 @@ use fj_math::Transform; -use crate::{ - objects::{GlobalEdge, HalfEdge}, - services::Services, -}; +use crate::{objects::HalfEdge, services::Services}; use super::{TransformCache, TransformObject}; @@ -30,17 +27,3 @@ impl TransformObject for HalfEdge { Self::new(path, boundary, curve, start_vertex) } } - -impl TransformObject for GlobalEdge { - fn transform_with_cache( - self, - _: &Transform, - _: &mut Services, - _: &mut TransformCache, - ) -> Self { - // There's nothing to actually transform here, as `GlobalEdge` holds no - // data. We still need this implementation though, as a new `GlobalEdge` - // object must be created to represent the new and transformed edge. - Self::new() - } -} diff --git a/crates/fj-core/src/objects/kinds/edge.rs b/crates/fj-core/src/objects/kinds/edge.rs index 561a49a82..321d6c210 100644 --- a/crates/fj-core/src/objects/kinds/edge.rs +++ b/crates/fj-core/src/objects/kinds/edge.rs @@ -83,35 +83,3 @@ impl HalfEdge { &self.start_vertex } } - -/// An undirected edge, defined in global (3D) coordinates -/// -/// In contrast to [`HalfEdge`], `GlobalEdge` is undirected, meaning it has no -/// defined direction. This means it can be used to determine whether two -/// [`HalfEdge`]s map to the same `GlobalEdge`, regardless of their direction. -/// -/// See [`HalfEdge`]'s documentation for more information on the relationship -/// between [`HalfEdge`] and `GlobalEdge`. -/// -/// # Equality -/// -/// `GlobalEdge` contains no data and exists purely to be used within a -/// `Handle`, where `Handle::id` can be used to compare different instances of -/// `GlobalEdge`. -/// -/// If `GlobalEdge` had `Eq`/`PartialEq` implementations, it containing no data -/// would mean that all instances of `GlobalEdge` would be considered equal. -/// This would be very error-prone. -/// -/// If you need to reference a `GlobalEdge` from a struct that needs to derive -/// `Eq`/`Ord`/..., you can use `HandleWrapper` to do that. It will -/// use `Handle::id` to provide those `Eq`/`Ord`/... implementations. -#[derive(Clone, Debug, Default, Hash)] -pub struct GlobalEdge {} - -impl GlobalEdge { - /// Create a new instance - pub fn new() -> Self { - Self::default() - } -} diff --git a/crates/fj-core/src/objects/mod.rs b/crates/fj-core/src/objects/mod.rs index a91b79fcf..e14dab884 100644 --- a/crates/fj-core/src/objects/mod.rs +++ b/crates/fj-core/src/objects/mod.rs @@ -48,7 +48,7 @@ pub use self::{ kinds::{ curve::Curve, cycle::{Cycle, HalfEdgesOfCycle}, - edge::{GlobalEdge, HalfEdge}, + edge::HalfEdge, face::{Face, FaceSet, Handedness}, region::Region, shell::Shell, diff --git a/crates/fj-core/src/objects/object.rs b/crates/fj-core/src/objects/object.rs index e05685034..3cddf3f7a 100644 --- a/crates/fj-core/src/objects/object.rs +++ b/crates/fj-core/src/objects/object.rs @@ -1,7 +1,7 @@ use crate::{ objects::{ - Curve, Cycle, Face, GlobalEdge, HalfEdge, Objects, Region, Shell, - Sketch, Solid, Surface, Vertex, + Curve, Cycle, Face, HalfEdge, Objects, Region, Shell, Sketch, Solid, + Surface, Vertex, }, storage::{Handle, HandleWrapper, ObjectId}, validate::{Validate, ValidationError}, @@ -94,7 +94,6 @@ object!( Curve, "curve", curves; Cycle, "cycle", cycles; Face, "face", faces; - GlobalEdge, "global edge", global_edges; HalfEdge, "half-edge", half_edges; Region, "region", regions; Shell, "shell", shells; diff --git a/crates/fj-core/src/objects/set.rs b/crates/fj-core/src/objects/set.rs index c2659c40c..8eebffc49 100644 --- a/crates/fj-core/src/objects/set.rs +++ b/crates/fj-core/src/objects/set.rs @@ -1,8 +1,7 @@ use std::collections::{btree_set, BTreeSet}; use super::{ - BehindHandle, Curve, Cycle, Face, GlobalEdge, HalfEdge, Object, Surface, - Vertex, + BehindHandle, Curve, Cycle, Face, HalfEdge, Object, Surface, Vertex, }; /// A graph of objects and their relationships @@ -90,10 +89,6 @@ impl InsertIntoSet for Face { } } -impl InsertIntoSet for GlobalEdge { - fn insert_into_set(&self, _: &mut ObjectSet) {} -} - impl InsertIntoSet for HalfEdge { fn insert_into_set(&self, objects: &mut ObjectSet) { objects.inner.insert(self.curve().clone().into()); diff --git a/crates/fj-core/src/objects/stores.rs b/crates/fj-core/src/objects/stores.rs index 620d42598..c9811c6a3 100644 --- a/crates/fj-core/src/objects/stores.rs +++ b/crates/fj-core/src/objects/stores.rs @@ -6,8 +6,7 @@ use crate::{ }; use super::{ - Curve, Cycle, Face, GlobalEdge, HalfEdge, Region, Shell, Sketch, Solid, - Surface, Vertex, + Curve, Cycle, Face, HalfEdge, Region, Shell, Sketch, Solid, Surface, Vertex, }; /// The available object stores @@ -22,9 +21,6 @@ pub struct Objects { /// Store for [`Face`]s pub faces: Store, - /// Store for [`GlobalEdge`]s - pub global_edges: Store, - /// Store for [`HalfEdge`]s pub half_edges: Store, diff --git a/crates/fj-core/src/operations/insert/insert_trait.rs b/crates/fj-core/src/operations/insert/insert_trait.rs index cd19325c2..efa60ea9e 100644 --- a/crates/fj-core/src/operations/insert/insert_trait.rs +++ b/crates/fj-core/src/operations/insert/insert_trait.rs @@ -1,7 +1,7 @@ use crate::{ objects::{ - Curve, Cycle, Face, GlobalEdge, HalfEdge, Region, Shell, Sketch, Solid, - Surface, Vertex, + Curve, Cycle, Face, HalfEdge, Region, Shell, Sketch, Solid, Surface, + Vertex, }, operations::{Polygon, TetrahedronShell}, services::Services, @@ -47,7 +47,6 @@ impl_insert!( Curve, curves; Cycle, cycles; Face, faces; - GlobalEdge, global_edges; HalfEdge, half_edges; Region, regions; Shell, shells; diff --git a/crates/fj-core/src/validate/edge.rs b/crates/fj-core/src/validate/edge.rs index aa2301720..9ec705368 100644 --- a/crates/fj-core/src/validate/edge.rs +++ b/crates/fj-core/src/validate/edge.rs @@ -1,6 +1,6 @@ use fj_math::{Point, Scalar}; -use crate::objects::{GlobalEdge, HalfEdge}; +use crate::objects::HalfEdge; use super::{Validate, ValidationConfig, ValidationError}; @@ -14,15 +14,6 @@ impl Validate for HalfEdge { } } -impl Validate for GlobalEdge { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } -} - /// [`HalfEdge`] validation failed #[derive(Clone, Debug, thiserror::Error)] pub enum HalfEdgeValidationError {