diff --git a/crates/fj-kernel/src/shape/api.rs b/crates/fj-kernel/src/shape/api.rs index 2608577fd..eb02f3242 100644 --- a/crates/fj-kernel/src/shape/api.rs +++ b/crates/fj-kernel/src/shape/api.rs @@ -319,7 +319,10 @@ mod tests { assert!(shape.get_handle(&surface.get()).as_ref() == Some(&surface)); let vertex = Vertex { point }; - let edge = Edge::new(curve, VerticesOfEdge::none()); + let edge = Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::none(), + }; assert!(shape.get_handle(&vertex).is_none()); assert!(shape.get_handle(&edge).is_none()); @@ -375,10 +378,10 @@ mod tests { // Shouldn't work. Nothing has been added to `shape`. let err = shape - .insert(Edge::new( - curve.clone(), - VerticesOfEdge::from_vertices([a.clone(), b.clone()]), - )) + .insert(Edge { + curve: LocalForm::canonical_only(curve.clone()), + vertices: VerticesOfEdge::from_vertices([a.clone(), b.clone()]), + }) .unwrap_err(); assert!(err.missing_curve(&curve)); assert!(err.missing_vertex(&a.canonical())); @@ -392,8 +395,10 @@ mod tests { let b = LocalForm::new(Point::from([2.]), b); // Everything has been added to `shape` now. Should work! - shape - .insert(Edge::new(curve, VerticesOfEdge::from_vertices([a, b])))?; + shape.insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::from_vertices([a, b]), + })?; Ok(()) } diff --git a/crates/fj-kernel/src/shape/object.rs b/crates/fj-kernel/src/shape/object.rs index 265f7f416..29142939f 100644 --- a/crates/fj-kernel/src/shape/object.rs +++ b/crates/fj-kernel/src/shape/object.rs @@ -108,10 +108,10 @@ impl Object for Edge<3> { Ok(LocalForm::new(*vertex.local(), canonical)) })?; - let merged = shape.get_handle_or_insert(Edge::new( - curve, - VerticesOfEdge::new(vertices), - ))?; + let merged = shape.get_handle_or_insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::new(vertices), + })?; if let Some(handle) = handle { mapping.edges.insert(handle, merged.clone()); diff --git a/crates/fj-kernel/src/topology/builder.rs b/crates/fj-kernel/src/topology/builder.rs index 09b6d5bf8..d52832f31 100644 --- a/crates/fj-kernel/src/topology/builder.rs +++ b/crates/fj-kernel/src/topology/builder.rs @@ -66,9 +66,10 @@ impl<'r> EdgeBuilder<'r> { curve: LocalForm::new(curve_local, curve_canonical.clone()), vertices: VerticesOfEdge::none(), }; - let edge_canonical = self - .shape - .insert(Edge::new(curve_canonical, VerticesOfEdge::none()))?; + let edge_canonical = self.shape.insert(Edge { + curve: LocalForm::canonical_only(curve_canonical), + vertices: VerticesOfEdge::none(), + })?; Ok(LocalForm::new(edge_local, edge_canonical)) } @@ -108,10 +109,10 @@ impl<'r> EdgeBuilder<'r> { LocalForm::new(Point::from([1.]), b), ]; - let edge = self.shape.insert(Edge::new( - curve, - VerticesOfEdge::from_vertices(vertices), - ))?; + let edge = self.shape.insert(Edge { + curve: LocalForm::canonical_only(curve), + vertices: VerticesOfEdge::from_vertices(vertices), + })?; Ok(edge) } diff --git a/crates/fj-kernel/src/topology/edge.rs b/crates/fj-kernel/src/topology/edge.rs index 153a079a3..cf0446af8 100644 --- a/crates/fj-kernel/src/topology/edge.rs +++ b/crates/fj-kernel/src/topology/edge.rs @@ -4,7 +4,7 @@ use fj_math::Point; use crate::{ geometry::Curve, - shape::{Handle, LocalForm, Shape}, + shape::{LocalForm, Shape}, }; use super::{EdgeBuilder, Vertex}; @@ -37,19 +37,6 @@ pub struct Edge { pub vertices: VerticesOfEdge, } -impl Edge<3> { - /// Construct an instance of `Edge` - pub fn new(curve: Handle>, vertices: VerticesOfEdge) -> Self { - let curve = LocalForm::canonical_only(curve); - Self { curve, vertices } - } - - /// Build an edge using the [`EdgeBuilder`] API - pub fn builder(shape: &mut Shape) -> EdgeBuilder { - EdgeBuilder::new(shape) - } -} - impl Edge { /// Access the curve that the edge refers to /// @@ -71,6 +58,13 @@ impl Edge { } } +impl Edge<3> { + /// Build an edge using the [`EdgeBuilder`] API + pub fn builder(shape: &mut Shape) -> EdgeBuilder { + EdgeBuilder::new(shape) + } +} + impl fmt::Display for Edge { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.vertices() { diff --git a/crates/fj-operations/src/difference_2d.rs b/crates/fj-operations/src/difference_2d.rs index a134441c1..5a36d1120 100644 --- a/crates/fj-operations/src/difference_2d.rs +++ b/crates/fj-operations/src/difference_2d.rs @@ -121,8 +121,10 @@ fn add_cycle( curve: LocalForm::new(curve_local, curve_canonical.clone()), vertices: vertices.clone(), }; - let edge_canonical = - shape.merge(Edge::new(curve_canonical, vertices))?; + let edge_canonical = shape.merge(Edge { + curve: LocalForm::canonical_only(curve_canonical), + vertices, + })?; edges.push(LocalForm::new(edge_local, edge_canonical)); }