Circumvent redundant abstraction layer

This commit is contained in:
Hanno Braun 2024-06-21 20:02:40 +02:00
parent fc8db4353f
commit e0262026c5

View File

@ -10,7 +10,10 @@ use crate::{
topology::{Curve, Surface}, topology::{Curve, Surface},
}; };
use super::{path::approx_circle, Approx, ApproxPoint, Tolerance}; use super::{
path::{approx_circle, approx_line},
Approx, ApproxPoint, Tolerance,
};
impl Approx for (&Handle<Curve>, &Handle<Surface>, CurveBoundary<Point<1>>) { impl Approx for (&Handle<Curve>, &Handle<Surface>, CurveBoundary<Point<1>>) {
type Approximation = CurveApprox; type Approximation = CurveApprox;
@ -51,7 +54,7 @@ fn approx_curve(
surface: &SurfaceGeom, surface: &SurfaceGeom,
boundary: CurveBoundary<Point<1>>, boundary: CurveBoundary<Point<1>>,
tolerance: impl Into<Tolerance>, tolerance: impl Into<Tolerance>,
geometry: &Geometry, _: &Geometry,
) -> CurveApprox { ) -> CurveApprox {
// There are different cases of varying complexity. Circles are the hard // There are different cases of varying complexity. Circles are the hard
// part here, as they need to be approximated, while lines don't need to be. // part here, as they need to be approximated, while lines don't need to be.
@ -97,11 +100,12 @@ fn approx_curve(
[path.point_from_path_coords(point_curve).u] [path.point_from_path_coords(point_curve).u]
})); }));
let approx_u = (surface.u, range_u).approx_with_cache( let approx_u = match surface.u {
tolerance, GlobalPath::Circle(circle) => {
&mut (), approx_circle(&circle, range_u, tolerance)
geometry, }
); GlobalPath::Line(line) => approx_line(&line),
};
let mut points = Vec::new(); let mut points = Vec::new();
for (u, _) in approx_u { for (u, _) in approx_u {