mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 01:48:28 +00:00
Simplify arguments of curve approximation impl
This commit is contained in:
parent
f392d9a807
commit
bf3b6b5b82
@ -5,7 +5,10 @@ use std::collections::BTreeMap;
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath},
|
||||
geometry::{
|
||||
CurveBoundary, GlobalPath, HalfEdgeGeometry, SurfaceGeometry,
|
||||
SurfacePath,
|
||||
},
|
||||
objects::Curve,
|
||||
storage::Handle,
|
||||
Core,
|
||||
@ -13,14 +16,7 @@ use crate::{
|
||||
|
||||
use super::{Approx, ApproxPoint, Tolerance};
|
||||
|
||||
impl Approx
|
||||
for (
|
||||
&Handle<Curve>,
|
||||
SurfacePath,
|
||||
&SurfaceGeometry,
|
||||
CurveBoundary<Point<1>>,
|
||||
)
|
||||
{
|
||||
impl Approx for (&Handle<Curve>, &HalfEdgeGeometry, &SurfaceGeometry) {
|
||||
type Approximation = CurveApprox;
|
||||
type Cache = CurveApproxCache;
|
||||
|
||||
@ -30,20 +26,20 @@ impl Approx
|
||||
cache: &mut Self::Cache,
|
||||
core: &mut Core,
|
||||
) -> Self::Approximation {
|
||||
let (curve, surface_path, surface, boundary) = self;
|
||||
let (curve, half_edge, surface) = self;
|
||||
|
||||
match cache.get(curve, boundary) {
|
||||
match cache.get(curve, half_edge.boundary) {
|
||||
Some(approx) => approx,
|
||||
None => {
|
||||
let approx = approx_curve(
|
||||
&surface_path,
|
||||
&half_edge.path,
|
||||
surface,
|
||||
boundary,
|
||||
half_edge.boundary,
|
||||
tolerance,
|
||||
core,
|
||||
);
|
||||
|
||||
cache.insert(curve.clone(), boundary, approx)
|
||||
cache.insert(curve.clone(), half_edge.boundary, approx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,7 +183,10 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
algorithms::approx::{Approx, ApproxPoint},
|
||||
geometry::{CurveBoundary, GlobalPath, SurfaceGeometry, SurfacePath},
|
||||
geometry::{
|
||||
CurveBoundary, GlobalPath, HalfEdgeGeometry, SurfaceGeometry,
|
||||
SurfacePath,
|
||||
},
|
||||
objects::Curve,
|
||||
operations::insert::Insert,
|
||||
Core,
|
||||
@ -201,11 +200,12 @@ mod tests {
|
||||
let (path, boundary) =
|
||||
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
|
||||
let boundary = CurveBoundary::from(boundary);
|
||||
let half_edge = HalfEdgeGeometry { path, boundary };
|
||||
let surface = core.layers.geometry.xz_plane();
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx =
|
||||
(&curve, path, &surface, boundary).approx(tolerance, &mut core);
|
||||
(&curve, &half_edge, &surface).approx(tolerance, &mut core);
|
||||
|
||||
assert_eq!(approx.points, vec![]);
|
||||
}
|
||||
@ -218,6 +218,7 @@ mod tests {
|
||||
let (path, boundary) =
|
||||
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
|
||||
let boundary = CurveBoundary::from(boundary);
|
||||
let half_edge = HalfEdgeGeometry { path, boundary };
|
||||
let surface = SurfaceGeometry {
|
||||
u: GlobalPath::circle_from_radius(1.),
|
||||
v: [0., 0., 1.].into(),
|
||||
@ -225,7 +226,7 @@ mod tests {
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx =
|
||||
(&curve, path, &surface, boundary).approx(tolerance, &mut core);
|
||||
(&curve, &half_edge, &surface).approx(tolerance, &mut core);
|
||||
|
||||
assert_eq!(approx.points, vec![]);
|
||||
}
|
||||
@ -241,6 +242,7 @@ mod tests {
|
||||
([TAU], [TAU, 1.]),
|
||||
]);
|
||||
let boundary = CurveBoundary::from([[0.], [TAU]]);
|
||||
let half_edge = HalfEdgeGeometry { path, boundary };
|
||||
let surface = SurfaceGeometry {
|
||||
u: global_path,
|
||||
v: [0., 0., 1.].into(),
|
||||
@ -248,7 +250,7 @@ mod tests {
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx =
|
||||
(&curve, path, &surface, boundary).approx(tolerance, &mut core);
|
||||
(&curve, &half_edge, &surface).approx(tolerance, &mut core);
|
||||
|
||||
let expected_approx = (global_path, boundary)
|
||||
.approx(tolerance, &mut core)
|
||||
@ -270,11 +272,12 @@ mod tests {
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.);
|
||||
let boundary = CurveBoundary::from([[0.], [TAU]]);
|
||||
let half_edge = HalfEdgeGeometry { path, boundary };
|
||||
let surface = core.layers.geometry.xz_plane();
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx =
|
||||
(&curve, path, &surface, boundary).approx(tolerance, &mut core);
|
||||
(&curve, &half_edge, &surface).approx(tolerance, &mut core);
|
||||
|
||||
let expected_approx = (&path, boundary)
|
||||
.approx(tolerance, &mut core)
|
||||
|
@ -50,9 +50,8 @@ impl Approx for (&Handle<HalfEdge>, &SurfaceGeometry) {
|
||||
let rest = {
|
||||
let approx = (
|
||||
half_edge.curve(),
|
||||
core.layers.geometry.of_half_edge(half_edge).path,
|
||||
&core.layers.geometry.of_half_edge(half_edge),
|
||||
surface,
|
||||
half_edge.boundary(),
|
||||
)
|
||||
.approx_with_cache(
|
||||
tolerance,
|
||||
|
Loading…
Reference in New Issue
Block a user