From 249a9250b5424dd545187571afb8de637ce0d94a Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:19:57 +0200 Subject: [PATCH 01/18] Move `local` module out of obsolete `shape` module --- crates/fj-kernel/src/algorithms/reverse.rs | 2 +- crates/fj-kernel/src/algorithms/sweep.rs | 2 +- crates/fj-kernel/src/algorithms/transform.rs | 2 +- crates/fj-kernel/src/lib.rs | 2 +- crates/fj-kernel/src/{shape => }/local.rs | 2 ++ crates/fj-kernel/src/objects/cycle.rs | 2 +- crates/fj-kernel/src/objects/edge.rs | 2 +- crates/fj-kernel/src/shape/mod.rs | 7 ------- crates/fj-kernel/src/validation/mod.rs | 2 +- crates/fj-operations/src/difference_2d.rs | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-) rename crates/fj-kernel/src/{shape => }/local.rs (95%) delete mode 100644 crates/fj-kernel/src/shape/mod.rs diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index b48f74ed5..ad4c5b71e 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -1,8 +1,8 @@ use fj_math::{Circle, Line, Point, Vector}; use crate::{ + local::LocalForm, objects::{Curve, Cycle, CyclesInFace, Edge, Face}, - shape::LocalForm, }; /// Reverse the direction of a face diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index 83f017257..bff4ac69d 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -2,10 +2,10 @@ use fj_math::{Point, Scalar, Transform, Triangle, Vector}; use crate::{ iter::ObjectIters, + local::LocalForm, objects::{ Curve, Cycle, Edge, Face, GlobalVertex, Surface, Vertex, VerticesOfEdge, }, - shape::LocalForm, }; use super::{reverse_face, transform::transform_face, CycleApprox, Tolerance}; diff --git a/crates/fj-kernel/src/algorithms/transform.rs b/crates/fj-kernel/src/algorithms/transform.rs index 55974800c..560785878 100644 --- a/crates/fj-kernel/src/algorithms/transform.rs +++ b/crates/fj-kernel/src/algorithms/transform.rs @@ -1,10 +1,10 @@ use fj_math::Transform; use crate::{ + local::LocalForm, objects::{ Cycle, CyclesInFace, Edge, Face, FaceBRep, GlobalVertex, Vertex, }, - shape::LocalForm, }; /// Transform a shape diff --git a/crates/fj-kernel/src/lib.rs b/crates/fj-kernel/src/lib.rs index 4df333908..68c8f51d6 100644 --- a/crates/fj-kernel/src/lib.rs +++ b/crates/fj-kernel/src/lib.rs @@ -91,6 +91,6 @@ pub mod algorithms; pub mod builder; pub mod geometry; pub mod iter; +pub mod local; pub mod objects; -pub mod shape; pub mod validation; diff --git a/crates/fj-kernel/src/shape/local.rs b/crates/fj-kernel/src/local.rs similarity index 95% rename from crates/fj-kernel/src/shape/local.rs rename to crates/fj-kernel/src/local.rs index 753893a89..72ddfe171 100644 --- a/crates/fj-kernel/src/shape/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -1,3 +1,5 @@ +//! Infrastructure for types that have a local and a global form + /// A reference to an object, which includes a local form /// /// This type is used by topological objects to reference other objects, while diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index 88bd7ed66..715437c65 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -1,6 +1,6 @@ use fj_math::{Line, Point}; -use crate::shape::LocalForm; +use crate::local::LocalForm; use super::{Curve, Edge, Surface}; diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index e1ce164cb..ed39ecec4 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -2,7 +2,7 @@ use std::fmt; use fj_math::{Circle, Line, Point, Scalar, Vector}; -use crate::shape::LocalForm; +use crate::local::LocalForm; use super::{Curve, GlobalVertex, Surface, Vertex}; diff --git a/crates/fj-kernel/src/shape/mod.rs b/crates/fj-kernel/src/shape/mod.rs deleted file mode 100644 index 741ffdec3..000000000 --- a/crates/fj-kernel/src/shape/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -//! The API used for creating and manipulating shapes -//! -//! See [`Shape`], which is the main entry point to this API. - -mod local; - -pub use self::local::LocalForm; diff --git a/crates/fj-kernel/src/validation/mod.rs b/crates/fj-kernel/src/validation/mod.rs index ef6f574b6..ca7fef04b 100644 --- a/crates/fj-kernel/src/validation/mod.rs +++ b/crates/fj-kernel/src/validation/mod.rs @@ -141,8 +141,8 @@ mod tests { use fj_math::{Point, Scalar}; use crate::{ + local::LocalForm, objects::{Curve, Edge, GlobalVertex, Vertex, VerticesOfEdge}, - shape::LocalForm, validation::{validate, ValidationConfig, ValidationError}, }; diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index 27e6fcf74..dd2643820 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -2,8 +2,8 @@ use fj_interop::debug::DebugInfo; use fj_kernel::{ algorithms::Tolerance, iter::ObjectIters, + local::LocalForm, objects::{Cycle, Edge, Face}, - shape::LocalForm, validation::{validate, Validated, ValidationConfig, ValidationError}, }; use fj_math::Aabb; From f5af137d2b7308aad71dc00994f8ff522a7f5da6 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:20:31 +0200 Subject: [PATCH 02/18] Remove unused code --- crates/fj-kernel/src/local.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 72ddfe171..75f89608e 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -30,17 +30,3 @@ impl LocalForm { &self.canonical } } - -impl LocalForm { - /// Construct a new instance of `LocalForm` without a local form - /// - /// It's possible that an object's local and canonical forms are the same. - /// This is a convenience constructor that constructs a `LocalForm` instance - /// for such a situation. - pub fn canonical_only(canonical: Canonical) -> Self - where - Canonical: Clone, - { - Self::new(canonical.clone(), canonical) - } -} From 18d8c05e75fb3182bd104d265a4f77484b5cf568 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:21:09 +0200 Subject: [PATCH 03/18] Rename type parameter to prevent name collision --- crates/fj-kernel/src/local.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 75f89608e..d1fc1f29c 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -6,22 +6,22 @@ /// also keeping track of a local representation of that object, which is often /// more appropriate for various tasks. #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub struct LocalForm { - local: Local, +pub struct LocalForm { + local: T, canonical: Canonical, } -impl LocalForm { +impl LocalForm { /// Construct a new instance of `LocalForm` /// /// It is the caller's responsibility to make sure that the local and /// canonical forms passed to this method actually match. - pub fn new(local: Local, canonical: Canonical) -> Self { + pub fn new(local: T, canonical: Canonical) -> Self { Self { local, canonical } } /// Access the local form of the referenced object - pub fn local(&self) -> &Local { + pub fn local(&self) -> &T { &self.local } From ab6b8ce757fc549161e29a5e5d70f0ea194f2a46 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:21:44 +0200 Subject: [PATCH 04/18] Simplify name of `LocalForm` to `Local` --- crates/fj-kernel/src/algorithms/reverse.rs | 4 ++-- crates/fj-kernel/src/algorithms/sweep.rs | 4 ++-- crates/fj-kernel/src/algorithms/transform.rs | 4 ++-- crates/fj-kernel/src/local.rs | 4 ++-- crates/fj-kernel/src/objects/cycle.rs | 4 ++-- crates/fj-kernel/src/objects/edge.rs | 8 ++++---- crates/fj-kernel/src/validation/mod.rs | 4 ++-- crates/fj-operations/src/difference_2d.rs | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index ad4c5b71e..e52535336 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -1,7 +1,7 @@ use fj_math::{Circle, Line, Point, Vector}; use crate::{ - local::LocalForm, + local::Local, objects::{Curve, Cycle, CyclesInFace, Edge, Face}, }; @@ -50,7 +50,7 @@ fn reverse_local_coordinates_in_cycle( }; let canonical = *edge.curve.canonical(); - LocalForm::new(local, canonical) + Local::new(local, canonical) }; let vertices = edge.vertices.clone(); diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index bff4ac69d..87e5cce06 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -2,7 +2,7 @@ use fj_math::{Point, Scalar, Transform, Triangle, Vector}; use crate::{ iter::ObjectIters, - local::LocalForm, + local::Local, objects::{ Curve, Cycle, Edge, Face, GlobalVertex, Surface, Vertex, VerticesOfEdge, }, @@ -144,7 +144,7 @@ fn create_non_continuous_side_face( let global = [a, b].map(|vertex| vertex.1.position()); let global = Curve::line_from_points(global); - LocalForm::new(local, global) + Local::new(local, global) }; let vertices = VerticesOfEdge::from_vertices([ diff --git a/crates/fj-kernel/src/algorithms/transform.rs b/crates/fj-kernel/src/algorithms/transform.rs index 560785878..de9d685f2 100644 --- a/crates/fj-kernel/src/algorithms/transform.rs +++ b/crates/fj-kernel/src/algorithms/transform.rs @@ -1,7 +1,7 @@ use fj_math::Transform; use crate::{ - local::LocalForm, + local::Local, objects::{ Cycle, CyclesInFace, Edge, Face, FaceBRep, GlobalVertex, Vertex, }, @@ -62,7 +62,7 @@ pub fn transform_cycles( .map(|vertex| transform_vertex(&vertex, transform)); Edge { - curve: LocalForm::new(curve_local, curve_canonical), + curve: Local::new(curve_local, curve_canonical), vertices, } }) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index d1fc1f29c..9bd3726b6 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -6,12 +6,12 @@ /// also keeping track of a local representation of that object, which is often /// more appropriate for various tasks. #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub struct LocalForm { +pub struct Local { local: T, canonical: Canonical, } -impl LocalForm { +impl Local { /// Construct a new instance of `LocalForm` /// /// It is the caller's responsibility to make sure that the local and diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index 715437c65..c6675274e 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -1,6 +1,6 @@ use fj_math::{Line, Point}; -use crate::local::LocalForm; +use crate::local::Local; use super::{Curve, Edge, Surface}; @@ -40,7 +40,7 @@ impl Cycle { Edge::line_segment_from_points(surface, points); let edge_local = Edge { - curve: LocalForm::new( + curve: Local::new( Curve::Line(Line::from_points(points)), *edge_canonical.curve.canonical(), ), diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index ed39ecec4..36787dcda 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -2,7 +2,7 @@ use std::fmt; use fj_math::{Circle, Line, Point, Scalar, Vector}; -use crate::local::LocalForm; +use crate::local::Local; use super::{Curve, GlobalVertex, Surface, Vertex}; @@ -14,7 +14,7 @@ pub struct Edge { /// The edge can be a segment of the curve that is bounded by two vertices, /// or if the curve is continuous (i.e. connects to itself), the edge could /// be defined by the whole curve, and have no bounding vertices. - pub curve: LocalForm, Curve<3>>, + pub curve: Local, Curve<3>>, /// Access the vertices that bound the edge on the curve /// @@ -38,7 +38,7 @@ impl Edge { }); Edge { - curve: LocalForm::new(curve_local, curve_canonical), + curve: Local::new(curve_local, curve_canonical), vertices: VerticesOfEdge::none(), } } @@ -71,7 +71,7 @@ impl Edge { }; Self { - curve: LocalForm::new(curve_local, curve_canonical), + curve: Local::new(curve_local, curve_canonical), vertices: VerticesOfEdge::from_vertices(vertices), } } diff --git a/crates/fj-kernel/src/validation/mod.rs b/crates/fj-kernel/src/validation/mod.rs index ca7fef04b..b34a2d627 100644 --- a/crates/fj-kernel/src/validation/mod.rs +++ b/crates/fj-kernel/src/validation/mod.rs @@ -141,7 +141,7 @@ mod tests { use fj_math::{Point, Scalar}; use crate::{ - local::LocalForm, + local::Local, objects::{Curve, Edge, GlobalVertex, Vertex, VerticesOfEdge}, validation::{validate, ValidationConfig, ValidationError}, }; @@ -154,7 +154,7 @@ mod tests { let curve = { let curve_local = Curve::line_from_points([[0., 0.], [1., 0.]]); let curve_canonical = Curve::line_from_points([a, b]); - LocalForm::new(curve_local, curve_canonical) + Local::new(curve_local, curve_canonical) }; let a = GlobalVertex::from_position(a); diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index dd2643820..c7feb7ae7 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -2,7 +2,7 @@ use fj_interop::debug::DebugInfo; use fj_kernel::{ algorithms::Tolerance, iter::ObjectIters, - local::LocalForm, + local::Local, objects::{Cycle, Edge, Face}, validation::{validate, Validated, ValidationConfig, ValidationError}, }; @@ -115,7 +115,7 @@ fn add_cycle(cycle: Cycle, reverse: bool) -> Cycle { }; let edge = Edge { - curve: LocalForm::new(curve_local, curve_canonical), + curve: Local::new(curve_local, curve_canonical), vertices: vertices.clone(), }; From f6dec4fc48ecff1785f968e7d94c881a98386458 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:14:02 +0200 Subject: [PATCH 05/18] Add trait `LocalForm` I will use it to make `Local` more convenient to use. --- crates/fj-kernel/src/local.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 9bd3726b6..109200aae 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -1,5 +1,7 @@ //! Infrastructure for types that have a local and a global form +use crate::objects::Curve; + /// A reference to an object, which includes a local form /// /// This type is used by topological objects to reference other objects, while @@ -30,3 +32,15 @@ impl Local { &self.canonical } } + +/// Implemented for types that are the local form of a global type +/// +/// See [`Local`] for more information. +pub trait LocalForm { + /// The global form of the implementing type + type GlobalForm; +} + +impl LocalForm for Curve<2> { + type GlobalForm = Curve<3>; +} From 3332cc2e469f6aeb310dd30e64eb01d32247347f Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:24:51 +0200 Subject: [PATCH 06/18] Simplify use of `Local` using `LocalForm` --- crates/fj-kernel/src/local.rs | 10 +++++----- crates/fj-kernel/src/objects/edge.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 109200aae..629efc4bc 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -8,17 +8,17 @@ use crate::objects::Curve; /// also keeping track of a local representation of that object, which is often /// more appropriate for various tasks. #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub struct Local { +pub struct Local { local: T, - canonical: Canonical, + canonical: T::GlobalForm, } -impl Local { +impl Local { /// Construct a new instance of `LocalForm` /// /// It is the caller's responsibility to make sure that the local and /// canonical forms passed to this method actually match. - pub fn new(local: T, canonical: Canonical) -> Self { + pub fn new(local: T, canonical: T::GlobalForm) -> Self { Self { local, canonical } } @@ -28,7 +28,7 @@ impl Local { } /// Access the canonical form of the referenced object - pub fn canonical(&self) -> &Canonical { + pub fn canonical(&self) -> &T::GlobalForm { &self.canonical } } diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index 36787dcda..b6b658d30 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -14,7 +14,7 @@ pub struct Edge { /// The edge can be a segment of the curve that is bounded by two vertices, /// or if the curve is continuous (i.e. connects to itself), the edge could /// be defined by the whole curve, and have no bounding vertices. - pub curve: Local, Curve<3>>, + pub curve: Local>, /// Access the vertices that bound the edge on the curve /// From 9577ea00203da1e0c7aea49f64d217fe889023cc Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:28:00 +0200 Subject: [PATCH 07/18] Update name of struct field --- crates/fj-kernel/src/algorithms/reverse.rs | 2 +- crates/fj-kernel/src/local.rs | 10 +++++----- crates/fj-kernel/src/objects/cycle.rs | 2 +- crates/fj-kernel/src/objects/edge.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index e52535336..3f38d16c1 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -49,7 +49,7 @@ fn reverse_local_coordinates_in_cycle( } }; - let canonical = *edge.curve.canonical(); + let canonical = *edge.curve.global(); Local::new(local, canonical) }; let vertices = edge.vertices.clone(); diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 629efc4bc..64b256c34 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -10,7 +10,7 @@ use crate::objects::Curve; #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct Local { local: T, - canonical: T::GlobalForm, + global: T::GlobalForm, } impl Local { @@ -18,8 +18,8 @@ impl Local { /// /// It is the caller's responsibility to make sure that the local and /// canonical forms passed to this method actually match. - pub fn new(local: T, canonical: T::GlobalForm) -> Self { - Self { local, canonical } + pub fn new(local: T, global: T::GlobalForm) -> Self { + Self { local, global } } /// Access the local form of the referenced object @@ -28,8 +28,8 @@ impl Local { } /// Access the canonical form of the referenced object - pub fn canonical(&self) -> &T::GlobalForm { - &self.canonical + pub fn global(&self) -> &T::GlobalForm { + &self.global } } diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index c6675274e..c8f0084e9 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -42,7 +42,7 @@ impl Cycle { let edge_local = Edge { curve: Local::new( Curve::Line(Line::from_points(points)), - *edge_canonical.curve.canonical(), + *edge_canonical.curve.global(), ), vertices: edge_canonical.vertices.clone(), }; diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index b6b658d30..2e0609383 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -81,7 +81,7 @@ impl Edge { /// This is a convenience method that saves the caller from dealing with the /// [`Handle`]. pub fn curve(&self) -> Curve<3> { - *self.curve.canonical() + *self.curve.global() } /// Access the vertices that the edge refers to From 7df3591a8c5b1fae33fb0e272bf89a84b278b4da Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:28:43 +0200 Subject: [PATCH 08/18] Refactor --- crates/fj-kernel/src/algorithms/reverse.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index 3f38d16c1..6445f78ee 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -49,8 +49,7 @@ fn reverse_local_coordinates_in_cycle( } }; - let canonical = *edge.curve.global(); - Local::new(local, canonical) + Local::new(local, *edge.curve.global()) }; let vertices = edge.vertices.clone(); From 0d837cf064de29c7e93ad6e59ae3c7997f27ae57 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:30:07 +0200 Subject: [PATCH 09/18] Refactor --- crates/fj-kernel/src/objects/cycle.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/crates/fj-kernel/src/objects/cycle.rs b/crates/fj-kernel/src/objects/cycle.rs index c8f0084e9..bf05475c2 100644 --- a/crates/fj-kernel/src/objects/cycle.rs +++ b/crates/fj-kernel/src/objects/cycle.rs @@ -1,8 +1,6 @@ -use fj_math::{Line, Point}; +use fj_math::Point; -use crate::local::Local; - -use super::{Curve, Edge, Surface}; +use super::{Edge, Surface}; /// A cycle of connected edges /// @@ -36,18 +34,7 @@ impl Cycle { // Can be cleaned up, once `array_windows` is stable. let points = [points[0], points[1]]; - let edge_canonical = - Edge::line_segment_from_points(surface, points); - - let edge_local = Edge { - curve: Local::new( - Curve::Line(Line::from_points(points)), - *edge_canonical.curve.global(), - ), - vertices: edge_canonical.vertices.clone(), - }; - - edges.push(edge_local); + edges.push(Edge::line_segment_from_points(surface, points)); } Cycle { edges } From e9c50c8e8558433984d1e2b6506a0ef0653408a1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:30:29 +0200 Subject: [PATCH 10/18] Add `Copy` bounds to `LocalForm` --- crates/fj-kernel/src/local.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 64b256c34..f1af9ad8a 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -36,9 +36,9 @@ impl Local { /// Implemented for types that are the local form of a global type /// /// See [`Local`] for more information. -pub trait LocalForm { +pub trait LocalForm: Copy { /// The global form of the implementing type - type GlobalForm; + type GlobalForm: Copy; } impl LocalForm for Curve<2> { From 9ebdfcb32b1c5b64b639e07c9443ddf8d45824e2 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:31:37 +0200 Subject: [PATCH 11/18] Simplify `Local` accessors --- crates/fj-kernel/src/algorithms/reverse.rs | 4 ++-- crates/fj-kernel/src/algorithms/transform.rs | 2 +- crates/fj-kernel/src/local.rs | 8 ++++---- crates/fj-kernel/src/objects/edge.rs | 2 +- crates/fj-operations/src/difference_2d.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/reverse.rs b/crates/fj-kernel/src/algorithms/reverse.rs index 6445f78ee..e06d9eeff 100644 --- a/crates/fj-kernel/src/algorithms/reverse.rs +++ b/crates/fj-kernel/src/algorithms/reverse.rs @@ -31,7 +31,7 @@ fn reverse_local_coordinates_in_cycle( .iter() .map(|edge| { let curve = { - let local = match *edge.curve.local() { + let local = match edge.curve.local() { Curve::Circle(Circle { center, a, b }) => { let center = Point::from([center.u, -center.v]); @@ -49,7 +49,7 @@ fn reverse_local_coordinates_in_cycle( } }; - Local::new(local, *edge.curve.global()) + Local::new(local, edge.curve.global()) }; let vertices = edge.vertices.clone(); diff --git a/crates/fj-kernel/src/algorithms/transform.rs b/crates/fj-kernel/src/algorithms/transform.rs index de9d685f2..41a9dd28d 100644 --- a/crates/fj-kernel/src/algorithms/transform.rs +++ b/crates/fj-kernel/src/algorithms/transform.rs @@ -53,7 +53,7 @@ pub fn transform_cycles( .edges .iter() .map(|edge| { - let curve_local = *edge.curve.local(); + let curve_local = edge.curve.local(); let curve_canonical = edge.curve().transform(transform); let vertices = edge diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index f1af9ad8a..a0252509c 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -23,13 +23,13 @@ impl Local { } /// Access the local form of the referenced object - pub fn local(&self) -> &T { - &self.local + pub fn local(&self) -> T { + self.local } /// Access the canonical form of the referenced object - pub fn global(&self) -> &T::GlobalForm { - &self.global + pub fn global(&self) -> T::GlobalForm { + self.global } } diff --git a/crates/fj-kernel/src/objects/edge.rs b/crates/fj-kernel/src/objects/edge.rs index 2e0609383..c3f95c37a 100644 --- a/crates/fj-kernel/src/objects/edge.rs +++ b/crates/fj-kernel/src/objects/edge.rs @@ -81,7 +81,7 @@ impl Edge { /// This is a convenience method that saves the caller from dealing with the /// [`Handle`]. pub fn curve(&self) -> Curve<3> { - *self.curve.global() + self.curve.global() } /// Access the vertices that the edge refers to diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index c7feb7ae7..a65a9e989 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -94,7 +94,7 @@ impl ToShape for fj::Difference2d { fn add_cycle(cycle: Cycle, reverse: bool) -> Cycle { let mut edges = Vec::new(); for edge in cycle.edges { - let curve_local = *edge.curve.local(); + let curve_local = edge.curve.local(); let curve_local = if reverse { curve_local.reverse() } else { From 5ecf133bf9205ff9c5d2cfcc43598c84ff6559da Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:37:48 +0200 Subject: [PATCH 12/18] Update documentation of `Local` --- crates/fj-kernel/src/local.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index a0252509c..7ffc33b45 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -2,11 +2,15 @@ use crate::objects::Curve; -/// A reference to an object, which includes a local form +/// A wrapper around the local and global forms of a type /// -/// This type is used by topological objects to reference other objects, while -/// also keeping track of a local representation of that object, which is often -/// more appropriate for various tasks. +/// The local form is whatever representation of the value that is most +/// appropriate in a given local context, which might be a curve or surface. The +/// global form is the global 3D form of the same value. +/// +/// The purpose of storing both forms is to be able to losslessly convert +/// between them. Even if this conversion can be computed on the fly, it might +/// be lossy due to floating point accuracy issues. #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct Local { local: T, @@ -14,20 +18,20 @@ pub struct Local { } impl Local { - /// Construct a new instance of `LocalForm` + /// Construct a new instance /// - /// It is the caller's responsibility to make sure that the local and - /// canonical forms passed to this method actually match. + /// It is the caller's responsibility to make sure that the local and global + /// forms passed into this constructor match. pub fn new(local: T, global: T::GlobalForm) -> Self { Self { local, global } } - /// Access the local form of the referenced object + /// Access the local form of the value pub fn local(&self) -> T { self.local } - /// Access the canonical form of the referenced object + /// Access the global form of the value pub fn global(&self) -> T::GlobalForm { self.global } From 880760676f0b3068f1dac495610f1be5b931ca58 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:44:23 +0200 Subject: [PATCH 13/18] Derive `Copy` for `Local` --- crates/fj-kernel/src/algorithms/sweep.rs | 2 +- crates/fj-kernel/src/local.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/sweep.rs b/crates/fj-kernel/src/algorithms/sweep.rs index 87e5cce06..63373fa2a 100644 --- a/crates/fj-kernel/src/algorithms/sweep.rs +++ b/crates/fj-kernel/src/algorithms/sweep.rs @@ -153,7 +153,7 @@ fn create_non_continuous_side_face( ]); let edge = Edge { - curve: curve.clone(), + curve, vertices: vertices.clone(), }; diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 7ffc33b45..8b8abfa04 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -11,7 +11,7 @@ use crate::objects::Curve; /// The purpose of storing both forms is to be able to losslessly convert /// between them. Even if this conversion can be computed on the fly, it might /// be lossy due to floating point accuracy issues. -#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] pub struct Local { local: T, global: T::GlobalForm, From d77a08141e92a0a08b0bf5344cdf2265d3bf9623 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:45:01 +0200 Subject: [PATCH 14/18] Make `Local::new` easier to call --- crates/fj-kernel/src/local.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 8b8abfa04..212c91359 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -22,8 +22,11 @@ impl Local { /// /// It is the caller's responsibility to make sure that the local and global /// forms passed into this constructor match. - pub fn new(local: T, global: T::GlobalForm) -> Self { - Self { local, global } + pub fn new(local: impl Into, global: impl Into) -> Self { + Self { + local: local.into(), + global: global.into(), + } } /// Access the local form of the value From c5ea86ffdf26925cf9e81349f131bc7810c002cf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:45:28 +0200 Subject: [PATCH 15/18] Use `Local` to replace `LocalPoint<1>` --- .../fj-kernel/src/algorithms/approx/curves.rs | 10 ++++----- .../fj-kernel/src/algorithms/approx/edges.rs | 21 ++++++++++++------- crates/fj-kernel/src/local.rs | 6 ++++++ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/curves.rs b/crates/fj-kernel/src/algorithms/approx/curves.rs index b2e95d2bb..11b0c6e29 100644 --- a/crates/fj-kernel/src/algorithms/approx/curves.rs +++ b/crates/fj-kernel/src/algorithms/approx/curves.rs @@ -1,8 +1,8 @@ use std::cmp::max; -use fj_math::{Circle, Scalar}; +use fj_math::{Circle, Point, Scalar}; -use crate::{geometry::LocalPoint, objects::Curve}; +use crate::{local::Local, objects::Curve}; use super::Tolerance; @@ -23,7 +23,7 @@ use super::Tolerance; pub fn approx_curve( curve: &Curve<3>, tolerance: Tolerance, - out: &mut Vec>, + out: &mut Vec>>, ) { match curve { Curve::Circle(curve) => approx_circle(curve, tolerance, out), @@ -38,7 +38,7 @@ pub fn approx_curve( pub fn approx_circle( circle: &Circle<3>, tolerance: Tolerance, - out: &mut Vec>, + out: &mut Vec>>, ) { let radius = circle.a.magnitude(); @@ -53,7 +53,7 @@ pub fn approx_circle( for i in 0..n { let angle = Scalar::PI * 2. / n as f64 * i as f64; let point = circle.point_from_circle_coords([angle]); - out.push(LocalPoint::new([angle], point)); + out.push(Local::new([angle], point)); } } diff --git a/crates/fj-kernel/src/algorithms/approx/edges.rs b/crates/fj-kernel/src/algorithms/approx/edges.rs index 29e0b9de6..e0a290f49 100644 --- a/crates/fj-kernel/src/algorithms/approx/edges.rs +++ b/crates/fj-kernel/src/algorithms/approx/edges.rs @@ -1,6 +1,11 @@ -use crate::{geometry::LocalPoint, objects::VerticesOfEdge}; +use fj_math::Point; -pub fn approx_edge(vertices: VerticesOfEdge, points: &mut Vec>) { +use crate::{local::Local, objects::VerticesOfEdge}; + +pub fn approx_edge( + vertices: VerticesOfEdge, + points: &mut Vec>>, +) { // Insert the exact vertices of this edge into the approximation. This means // we don't rely on the curve approximation to deliver accurate // representations of these vertices, which they might not be able to do. @@ -10,7 +15,7 @@ pub fn approx_edge(vertices: VerticesOfEdge, points: &mut Vec>) { // the same vertex would be understood to refer to very close, but distinct // vertices. let vertices = vertices.convert(|vertex| { - LocalPoint::new(vertex.position(), vertex.global().position()) + Local::new(vertex.position(), vertex.global().position()) }); if let Some([a, b]) = vertices { points.insert(0, a); @@ -32,7 +37,7 @@ mod test { use fj_math::Point; use crate::{ - geometry::LocalPoint, + local::Local, objects::{GlobalVertex, Vertex, VerticesOfEdge}, }; @@ -51,10 +56,10 @@ mod test { Vertex::new(Point::from([1.]), v2), ]); - let a = LocalPoint::new([0.0], a); - let b = LocalPoint::new([0.25], b); - let c = LocalPoint::new([0.75], c); - let d = LocalPoint::new([1.0], d); + let a = Local::new([0.0], a); + let b = Local::new([0.25], b); + let c = Local::new([0.75], c); + let d = Local::new([1.0], d); // Regular edge let mut points = vec![b, c]; diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index 212c91359..d2f823eaf 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -1,5 +1,7 @@ //! Infrastructure for types that have a local and a global form +use fj_math::Point; + use crate::objects::Curve; /// A wrapper around the local and global forms of a type @@ -51,3 +53,7 @@ pub trait LocalForm: Copy { impl LocalForm for Curve<2> { type GlobalForm = Curve<3>; } + +impl LocalForm for Point<1> { + type GlobalForm = Point<3>; +} From 685ddd4e587a03567f1db115e7045d0c47711900 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:48:26 +0200 Subject: [PATCH 16/18] Remove unnecessary use of `LocalPoint` --- .../fj-kernel/src/algorithms/approx/cycles.rs | 13 +++++------- .../fj-kernel/src/algorithms/approx/faces.rs | 20 +++++-------------- .../src/algorithms/triangulate/mod.rs | 10 +++------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/approx/cycles.rs b/crates/fj-kernel/src/algorithms/approx/cycles.rs index c28150c3f..1b1b5b139 100644 --- a/crates/fj-kernel/src/algorithms/approx/cycles.rs +++ b/crates/fj-kernel/src/algorithms/approx/cycles.rs @@ -1,6 +1,6 @@ -use fj_math::Segment; +use fj_math::{Point, Segment}; -use crate::{geometry::LocalPoint, objects::Cycle}; +use crate::objects::Cycle; use super::{curves::approx_curve, edges::approx_edge, Tolerance}; @@ -8,7 +8,7 @@ use super::{curves::approx_curve, edges::approx_edge, Tolerance}; #[derive(Debug, Eq, PartialEq, Hash)] pub struct CycleApprox { /// The points that approximate the cycle - pub points: Vec>, + pub points: Vec>, } impl CycleApprox { @@ -27,10 +27,8 @@ impl CycleApprox { points.extend(edge_points); } - let mut points: Vec<_> = points - .into_iter() - .map(|point| LocalPoint::new(point.global(), point.global())) - .collect(); + let mut points: Vec<_> = + points.into_iter().map(|point| point.global()).collect(); points.dedup(); @@ -46,7 +44,6 @@ impl CycleApprox { // up, once `array_windows` is stable. let segment = [segment[0], segment[1]]; - let segment = segment.map(|point| point.global()); segments.push(Segment::from(segment)); } diff --git a/crates/fj-kernel/src/algorithms/approx/faces.rs b/crates/fj-kernel/src/algorithms/approx/faces.rs index 12b8be775..7f6664c24 100644 --- a/crates/fj-kernel/src/algorithms/approx/faces.rs +++ b/crates/fj-kernel/src/algorithms/approx/faces.rs @@ -1,6 +1,8 @@ use std::collections::HashSet; -use crate::{geometry::LocalPoint, objects::Face}; +use fj_math::Point; + +use crate::objects::Face; use super::{CycleApprox, Tolerance}; @@ -11,7 +13,7 @@ pub struct FaceApprox { /// /// These could be actual vertices from the model, points that approximate /// an edge, or points that approximate a face. - pub points: HashSet>, + pub points: HashSet>, /// Approximation of the exterior cycle pub exterior: CycleApprox, @@ -81,10 +83,7 @@ mod tests { use fj_math::{Point, Scalar}; use map_macro::set; - use crate::{ - geometry::LocalPoint, - objects::{Face, Surface}, - }; + use crate::objects::{Face, Surface}; use super::{CycleApprox, FaceApprox, Tolerance}; @@ -118,15 +117,6 @@ mod tests { let g = g.to_xyz(); let h = h.to_xyz(); - let a = LocalPoint::new(a, a); - let b = LocalPoint::new(b, b); - let c = LocalPoint::new(c, c); - let d = LocalPoint::new(d, d); - let e = LocalPoint::new(e, e); - let f = LocalPoint::new(f, f); - let g = LocalPoint::new(g, g); - let h = LocalPoint::new(h, h); - let approx = FaceApprox::new(&face, tolerance); let expected = FaceApprox { points: set![a, b, c, d, e, f, g, h], diff --git a/crates/fj-kernel/src/algorithms/triangulate/mod.rs b/crates/fj-kernel/src/algorithms/triangulate/mod.rs index 997add704..6e4fb012a 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/mod.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/mod.rs @@ -31,7 +31,7 @@ pub fn triangulate( .map(|vertex| { // Can't panic, unless the approximation wrongfully // generates points that are not in the surface. - surface.point_to_surface_coords(vertex.global()) + surface.point_to_surface_coords(vertex) }) .collect(); let face_as_polygon = Polygon::new(surface) @@ -39,9 +39,7 @@ pub fn triangulate( |point| { // Can't panic, unless the approximation wrongfully // generates points that are not in the surface. - surface - .point_to_surface_coords(point.global()) - .local() + surface.point_to_surface_coords(point).local() }, )) .with_interiors(approx.interiors.into_iter().map( @@ -50,9 +48,7 @@ pub fn triangulate( // Can't panic, unless the approximation // wrongfully generates points that are not in // the surface. - surface - .point_to_surface_coords(point.global()) - .local() + surface.point_to_surface_coords(point).local() }) }, )); From 75366e3cdb769d3168b74ccd3fb74056306bb785 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:50:41 +0200 Subject: [PATCH 17/18] Use `Local` to replace `LocalPoint<2>` --- crates/fj-kernel/src/algorithms/triangulate/delaunay.rs | 8 ++++---- crates/fj-kernel/src/local.rs | 4 ++++ crates/fj-kernel/src/objects/surface.rs | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/triangulate/delaunay.rs b/crates/fj-kernel/src/algorithms/triangulate/delaunay.rs index 06d3dcc8c..5e39cb1b5 100644 --- a/crates/fj-kernel/src/algorithms/triangulate/delaunay.rs +++ b/crates/fj-kernel/src/algorithms/triangulate/delaunay.rs @@ -1,10 +1,10 @@ -use fj_math::{Scalar, Triangle, Winding}; +use fj_math::{Point, Scalar, Triangle, Winding}; use spade::HasPosition; -use crate::geometry::LocalPoint; +use crate::local::Local; /// Create a Delaunay triangulation of all points -pub fn triangulate(points: Vec>) -> Vec<[LocalPoint<2>; 3]> { +pub fn triangulate(points: Vec>>) -> Vec<[Local>; 3]> { use spade::Triangulation as _; let triangulation = spade::DelaunayTriangulation::<_>::bulk_load(points) @@ -29,7 +29,7 @@ pub fn triangulate(points: Vec>) -> Vec<[LocalPoint<2>; 3]> { } // Enables the use of `LocalPoint` in the triangulation. -impl HasPosition for LocalPoint<2> { +impl HasPosition for Local> { type Scalar = Scalar; fn position(&self) -> spade::Point2 { diff --git a/crates/fj-kernel/src/local.rs b/crates/fj-kernel/src/local.rs index d2f823eaf..234cbe0c4 100644 --- a/crates/fj-kernel/src/local.rs +++ b/crates/fj-kernel/src/local.rs @@ -57,3 +57,7 @@ impl LocalForm for Curve<2> { impl LocalForm for Point<1> { type GlobalForm = Point<3>; } + +impl LocalForm for Point<2> { + type GlobalForm = Point<3>; +} diff --git a/crates/fj-kernel/src/objects/surface.rs b/crates/fj-kernel/src/objects/surface.rs index 47af01c92..ae5f90d99 100644 --- a/crates/fj-kernel/src/objects/surface.rs +++ b/crates/fj-kernel/src/objects/surface.rs @@ -1,6 +1,6 @@ use fj_math::{Line, Point, Transform, Vector}; -use crate::geometry::LocalPoint; +use crate::local::Local; use super::Curve; @@ -68,7 +68,7 @@ impl Surface { pub fn point_to_surface_coords( &self, point_3d: impl Into>, - ) -> LocalPoint<2> { + ) -> Local> { let point_3d = point_3d.into(); let point_2d = match self { @@ -77,7 +77,7 @@ impl Surface { } }; - LocalPoint::new(point_2d, point_3d) + Local::new(point_2d, point_3d) } /// Convert a point in surface coordinates to model coordinates From e850cd937c3d8f91ec43a1e402e956f6a5182eab Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 1 Jul 2022 17:51:43 +0200 Subject: [PATCH 18/18] Remove unused code --- crates/fj-kernel/src/geometry/mod.rs | 5 --- crates/fj-kernel/src/geometry/points.rs | 55 ------------------------- crates/fj-kernel/src/lib.rs | 1 - 3 files changed, 61 deletions(-) delete mode 100644 crates/fj-kernel/src/geometry/mod.rs delete mode 100644 crates/fj-kernel/src/geometry/points.rs diff --git a/crates/fj-kernel/src/geometry/mod.rs b/crates/fj-kernel/src/geometry/mod.rs deleted file mode 100644 index 4cfa74e4a..000000000 --- a/crates/fj-kernel/src/geometry/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! Miscellaneous geometry code - -mod points; - -pub use self::points::LocalPoint; diff --git a/crates/fj-kernel/src/geometry/points.rs b/crates/fj-kernel/src/geometry/points.rs deleted file mode 100644 index 56abca198..000000000 --- a/crates/fj-kernel/src/geometry/points.rs +++ /dev/null @@ -1,55 +0,0 @@ -/// A point that stores a local and a global form -/// -/// The local form of a point is whatever representation is most appropriate in -/// the current context, which might be a curve or surface. The global form is -/// the global 3D form of the same point. -/// -/// The purpose of storing both forms is to be able to losslessly convert the -/// point back to its global form. Even if this conversion can be computed on -/// the fly, such a conversion might not result in the original global form, due -/// to floating point accuracy issues. Hence, such a conversion would not be -/// lossless, which could result in bugs. -/// -/// The `D` parameter defines the dimensionality of the local form. -/// -/// # `LocalPoint` and [`Vertex`] -/// -/// `LocalPoint` is similar to `Vertex`, but there is a key differences: -/// `Vertex` is an object in the boundary representation of a shape, while -/// `LocalPoint` can refer to any point. This distinction is important in the -/// case of approximation, for example, as points might be generated to -/// approximate a curve or surface, without those generated points referring to -/// any vertices. -/// -/// [`Vertex`]: crate::objects::Vertex -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub struct LocalPoint { - local: fj_math::Point, - global: fj_math::Point<3>, -} - -impl LocalPoint { - /// Construct a new instance - /// - /// Both the local and the global form must be provided. The caller must - /// guarantee that both of them match, i.e. define the same point. - pub fn new( - local: impl Into>, - global: impl Into>, - ) -> Self { - Self { - local: local.into(), - global: global.into(), - } - } - - /// Access the point's local form - pub fn local(&self) -> fj_math::Point { - self.local - } - - /// Access the point's global form - pub fn global(&self) -> fj_math::Point<3> { - self.global - } -} diff --git a/crates/fj-kernel/src/lib.rs b/crates/fj-kernel/src/lib.rs index 68c8f51d6..fed8991f1 100644 --- a/crates/fj-kernel/src/lib.rs +++ b/crates/fj-kernel/src/lib.rs @@ -89,7 +89,6 @@ pub mod algorithms; pub mod builder; -pub mod geometry; pub mod iter; pub mod local; pub mod objects;