Consolidate vertex approximation code

This commit is contained in:
Hanno Braun 2024-06-21 21:26:35 +02:00
parent 63aa5c59f2
commit 19642f55be
2 changed files with 14 additions and 12 deletions

View File

@ -28,20 +28,13 @@ impl Approx for (&Handle<HalfEdge>, &Handle<Surface>) {
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,
);

View File

@ -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<Vertex>,
curve: &Handle<Curve>,
surface: &Handle<Surface>,
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 => {