From 19642f55be3c9ed28379aff0b3aed36cf6b8108d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 21 Jun 2024 21:26:35 +0200 Subject: [PATCH] Consolidate vertex approximation code --- crates/fj-core/src/algorithms/approx/half_edge.rs | 13 +++---------- crates/fj-core/src/algorithms/approx/vertex.rs | 13 +++++++++++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/fj-core/src/algorithms/approx/half_edge.rs b/crates/fj-core/src/algorithms/approx/half_edge.rs index 92253a941..2f0467c9f 100644 --- a/crates/fj-core/src/algorithms/approx/half_edge.rs +++ b/crates/fj-core/src/algorithms/approx/half_edge.rs @@ -28,20 +28,13 @@ impl Approx for (&Handle, &Handle) { let tolerance = tolerance.into(); let boundary = geometry.of_half_edge(half_edge).boundary; + let [start_position_curve, _] = boundary.inner; - let start_position_surface = - geometry.of_half_edge(half_edge).start_position( - &geometry - .of_curve(half_edge.curve()) - .unwrap() - .local_on(surface) - .unwrap() - .path, - ); let first = approx_vertex( half_edge.start_vertex().clone(), + half_edge.curve(), surface, - start_position_surface, + start_position_curve, &mut cache.start_position, geometry, ); diff --git a/crates/fj-core/src/algorithms/approx/vertex.rs b/crates/fj-core/src/algorithms/approx/vertex.rs index 2f54e7250..756ee2e39 100644 --- a/crates/fj-core/src/algorithms/approx/vertex.rs +++ b/crates/fj-core/src/algorithms/approx/vertex.rs @@ -5,7 +5,7 @@ use fj_math::Point; use crate::{ geometry::Geometry, storage::Handle, - topology::{Surface, Vertex}, + topology::{Curve, Surface, Vertex}, }; use super::ApproxPoint; @@ -13,11 +13,20 @@ use super::ApproxPoint; /// # Approximate a vertex position pub fn approx_vertex( vertex: Handle, + curve: &Handle, surface: &Handle, - position_surface: Point<2>, + position_curve: Point<1>, cache: &mut VertexApproxCache, geometry: &Geometry, ) -> ApproxPoint<2> { + let position_surface = geometry + .of_curve(curve) + .unwrap() + .local_on(surface) + .unwrap() + .path + .point_from_path_coords(position_curve); + let position_global = match cache.get(&vertex) { Some(position) => position, None => {