Inline redundant function

This commit is contained in:
Hanno Braun 2024-05-17 14:02:30 +02:00
parent ab4b2299a6
commit 105f97ed68

View File

@ -96,66 +96,46 @@ impl ShellValidationError {
continue;
}
fn compare_curve_coords(
edge_a: &Handle<HalfEdge>,
surface_a: &SurfaceGeom,
edge_b: &Handle<HalfEdge>,
surface_b: &SurfaceGeom,
geometry: &Geometry,
config: &ValidationConfig,
mismatches: &mut Vec<CurveGeometryMismatch>,
) {
// 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(