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