diff --git a/crates/fj-kernel/src/algorithms/approx/edge.rs b/crates/fj-kernel/src/algorithms/approx/edge.rs index 58f6204a2..41376dac7 100644 --- a/crates/fj-kernel/src/algorithms/approx/edge.rs +++ b/crates/fj-kernel/src/algorithms/approx/edge.rs @@ -5,7 +5,7 @@ //! approximations are usually used to build cycle approximations, and this way, //! the caller doesn't have to call with duplicate vertices. -use crate::objects::HalfEdge; +use crate::{objects::HalfEdge, storage::Handle}; use super::{ curve::{CurveApprox, CurveCache}, @@ -13,7 +13,7 @@ use super::{ Approx, ApproxPoint, Tolerance, }; -impl Approx for &HalfEdge { +impl Approx for &Handle { type Approximation = HalfEdgeApprox; type Cache = CurveCache; @@ -28,7 +28,8 @@ impl Approx for &HalfEdge { let first = ApproxPoint::new( self.start_vertex().position(), self.start_vertex().global_form().position(), - ); + ) + .with_source((self.clone(), self.boundary()[0])); let curve_approx = (self.curve(), range).approx_with_cache(tolerance, cache); diff --git a/crates/fj-kernel/src/algorithms/approx/face.rs b/crates/fj-kernel/src/algorithms/approx/face.rs index 7a5d71ee4..6ee5c7080 100644 --- a/crates/fj-kernel/src/algorithms/approx/face.rs +++ b/crates/fj-kernel/src/algorithms/approx/face.rs @@ -38,17 +38,12 @@ impl Approx for &FaceSet { for approx in &approx { let approx: &FaceApprox = approx; - for point in &approx.points() { - for p in &all_points { - let distance = - (p.global_form - point.global_form).magnitude(); + for a in &approx.points() { + for b in &all_points { + let distance = (b.global_form - a.global_form).magnitude(); - if p.global_form != point.global_form - && distance < min_distance + if b.global_form != a.global_form && distance < min_distance { - let a = p; - let b = point; - panic!( "Invalid approximation: \ Distinct points are too close \ @@ -60,7 +55,7 @@ impl Approx for &FaceSet { } } - all_points.insert(point.clone()); + all_points.insert(a.clone()); } } diff --git a/crates/fj-kernel/src/algorithms/approx/mod.rs b/crates/fj-kernel/src/algorithms/approx/mod.rs index acedb5665..85dcb1d0a 100644 --- a/crates/fj-kernel/src/algorithms/approx/mod.rs +++ b/crates/fj-kernel/src/algorithms/approx/mod.rs @@ -20,7 +20,10 @@ use std::{ use fj_math::Point; -use crate::{objects::Curve, storage::Handle}; +use crate::{ + objects::{Curve, HalfEdge}, + storage::Handle, +}; pub use self::tolerance::{InvalidTolerance, Tolerance}; @@ -120,3 +123,4 @@ impl PartialOrd for ApproxPoint { pub trait Source: Any + Debug {} impl Source for (Handle, Point<1>) {} +impl Source for (Handle, Point<1>) {}