diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 4c0cc4c2d..1b0617ac1 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -96,66 +96,46 @@ impl ShellValidationError { continue; } - fn compare_curve_coords( - edge_a: &Handle, - surface_a: &SurfaceGeom, - edge_b: &Handle, - surface_b: &SurfaceGeom, - geometry: &Geometry, - config: &ValidationConfig, - mismatches: &mut Vec, - ) { - // Let's check 4 points. Given that the most complex curves - // we have right now are circles, 3 would be enough to check - // for coincidence. But the first and last might be - // identical, so let's add an extra one. - let [a, d] = geometry.of_half_edge(edge_a).boundary.inner; - let b = a + (d - a) * 1. / 3.; - let c = a + (d - a) * 2. / 3.; - - for point_curve in [a, b, c, d] { - let a_surface = geometry - .of_half_edge(edge_a) - .path - .point_from_path_coords(point_curve); - let b_surface = geometry - .of_half_edge(edge_b) - .path - .point_from_path_coords(point_curve); - - let a_global = - surface_a.point_from_surface_coords(a_surface); - let b_global = - surface_b.point_from_surface_coords(b_surface); - - let distance = (a_global - b_global).magnitude(); - - if distance > config.identical_max_distance { - mismatches.push(CurveGeometryMismatch { - half_edge_a: edge_a.clone(), - half_edge_b: edge_b.clone(), - point_curve, - point_a: a_global, - point_b: b_global, - distance, - }); - } - } - } - let mut mismatches = Vec::new(); let surface_a = geometry.of_surface(surface_a); let surface_b = geometry.of_surface(surface_b); - compare_curve_coords( - edge_a, - surface_a, - edge_b, - surface_b, - geometry, - config, - &mut mismatches, - ); + // Let's check 4 points. Given that the most complex curves we + // have right now are circles, 3 would be enough to check for + // coincidence. But the first and last might be identical, so + // let's add an extra one. + let [a, d] = geometry.of_half_edge(edge_a).boundary.inner; + let b = a + (d - a) * 1. / 3.; + let c = a + (d - a) * 2. / 3.; + + for point_curve in [a, b, c, d] { + let a_surface = geometry + .of_half_edge(edge_a) + .path + .point_from_path_coords(point_curve); + let b_surface = geometry + .of_half_edge(edge_b) + .path + .point_from_path_coords(point_curve); + + let a_global = + surface_a.point_from_surface_coords(a_surface); + let b_global = + surface_b.point_from_surface_coords(b_surface); + + let distance = (a_global - b_global).magnitude(); + + if distance > config.identical_max_distance { + mismatches.push(CurveGeometryMismatch { + half_edge_a: edge_a.clone(), + half_edge_b: edge_b.clone(), + point_curve, + point_a: a_global, + point_b: b_global, + distance, + }); + } + } for mismatch in mismatches { errors.push(