mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-09 12:28:29 +00:00
Simplify argument for curve approximation
This commit is contained in:
parent
5c3be8d63a
commit
a6ccd52b81
@ -5,17 +5,14 @@ use std::collections::BTreeMap;
|
|||||||
use fj_math::Point;
|
use fj_math::Point;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{
|
geometry::{CurveBoundary, Geometry, GlobalPath, SurfaceGeom, SurfacePath},
|
||||||
CurveBoundary, Geometry, GlobalPath, HalfEdgeGeom, SurfaceGeom,
|
|
||||||
SurfacePath,
|
|
||||||
},
|
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
topology::{Curve, Surface},
|
topology::{Curve, Surface},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Approx, ApproxPoint, Tolerance};
|
use super::{Approx, ApproxPoint, Tolerance};
|
||||||
|
|
||||||
impl Approx for (&Handle<Curve>, &Handle<Surface>, &HalfEdgeGeom) {
|
impl Approx for (&Handle<Curve>, &Handle<Surface>, CurveBoundary<Point<1>>) {
|
||||||
type Approximation = CurveApprox;
|
type Approximation = CurveApprox;
|
||||||
type Cache = CurveApproxCache;
|
type Cache = CurveApproxCache;
|
||||||
|
|
||||||
@ -25,9 +22,9 @@ impl Approx for (&Handle<Curve>, &Handle<Surface>, &HalfEdgeGeom) {
|
|||||||
cache: &mut Self::Cache,
|
cache: &mut Self::Cache,
|
||||||
geometry: &Geometry,
|
geometry: &Geometry,
|
||||||
) -> Self::Approximation {
|
) -> Self::Approximation {
|
||||||
let (curve, surface, half_edge) = self;
|
let (curve, surface, boundary) = self;
|
||||||
|
|
||||||
match cache.get(curve, half_edge.boundary) {
|
match cache.get(curve, boundary) {
|
||||||
Some(approx) => approx,
|
Some(approx) => approx,
|
||||||
None => {
|
None => {
|
||||||
let approx = approx_curve(
|
let approx = approx_curve(
|
||||||
@ -38,12 +35,12 @@ impl Approx for (&Handle<Curve>, &Handle<Surface>, &HalfEdgeGeom) {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.path,
|
.path,
|
||||||
geometry.of_surface(surface),
|
geometry.of_surface(surface),
|
||||||
half_edge.boundary,
|
boundary,
|
||||||
tolerance,
|
tolerance,
|
||||||
geometry,
|
geometry,
|
||||||
);
|
);
|
||||||
|
|
||||||
cache.insert(curve.clone(), half_edge.boundary, approx)
|
cache.insert(curve.clone(), boundary, approx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,7 +203,7 @@ mod tests {
|
|||||||
let half_edge = HalfEdgeGeom { boundary };
|
let half_edge = HalfEdgeGeom { boundary };
|
||||||
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx = (&curve, &surface, &half_edge)
|
let approx = (&curve, &surface, half_edge.boundary)
|
||||||
.approx(tolerance, &core.layers.geometry);
|
.approx(tolerance, &core.layers.geometry);
|
||||||
|
|
||||||
assert_eq!(approx.points, vec![]);
|
assert_eq!(approx.points, vec![]);
|
||||||
@ -229,7 +226,7 @@ mod tests {
|
|||||||
let half_edge = HalfEdgeGeom { boundary };
|
let half_edge = HalfEdgeGeom { boundary };
|
||||||
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx = (&curve, &surface, &half_edge)
|
let approx = (&curve, &surface, half_edge.boundary)
|
||||||
.approx(tolerance, &core.layers.geometry);
|
.approx(tolerance, &core.layers.geometry);
|
||||||
|
|
||||||
assert_eq!(approx.points, vec![]);
|
assert_eq!(approx.points, vec![]);
|
||||||
@ -251,7 +248,7 @@ mod tests {
|
|||||||
let half_edge = HalfEdgeGeom { boundary };
|
let half_edge = HalfEdgeGeom { boundary };
|
||||||
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx = (&curve, &surface, &half_edge)
|
let approx = (&curve, &surface, half_edge.boundary)
|
||||||
.approx(tolerance, &core.layers.geometry);
|
.approx(tolerance, &core.layers.geometry);
|
||||||
|
|
||||||
let expected_approx = (global_path, boundary)
|
let expected_approx = (global_path, boundary)
|
||||||
@ -282,7 +279,7 @@ mod tests {
|
|||||||
let half_edge = HalfEdgeGeom { boundary };
|
let half_edge = HalfEdgeGeom { boundary };
|
||||||
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx = (&curve, &surface, &half_edge)
|
let approx = (&curve, &surface, half_edge.boundary)
|
||||||
.approx(tolerance, &core.layers.geometry);
|
.approx(tolerance, &core.layers.geometry);
|
||||||
|
|
||||||
let expected_approx = (&path, boundary)
|
let expected_approx = (&path, boundary)
|
||||||
|
@ -55,9 +55,16 @@ impl Approx for (&Handle<HalfEdge>, &Handle<Surface>) {
|
|||||||
let first = ApproxPoint::new(start_position_surface, start_position);
|
let first = ApproxPoint::new(start_position_surface, start_position);
|
||||||
|
|
||||||
let rest = {
|
let rest = {
|
||||||
let approx =
|
let approx = (
|
||||||
(half_edge.curve(), surface, geometry.of_half_edge(half_edge))
|
half_edge.curve(),
|
||||||
.approx_with_cache(tolerance, &mut cache.curve, geometry);
|
surface,
|
||||||
|
geometry.of_half_edge(half_edge).boundary,
|
||||||
|
)
|
||||||
|
.approx_with_cache(
|
||||||
|
tolerance,
|
||||||
|
&mut cache.curve,
|
||||||
|
geometry,
|
||||||
|
);
|
||||||
|
|
||||||
approx.points.into_iter().map(|point| {
|
approx.points.into_iter().map(|point| {
|
||||||
let point_surface = geometry
|
let point_surface = geometry
|
||||||
|
Loading…
Reference in New Issue
Block a user