Simplify intersection test result

This commit is contained in:
Hanno Braun 2023-02-24 13:59:53 +01:00
parent 29a91d050f
commit 550360c070

View File

@ -2,9 +2,9 @@ use fj_interop::ext::ArrayExt;
use iter_fixed::IntoIteratorFixed; use iter_fixed::IntoIteratorFixed;
use crate::{ use crate::{
objects::{Curve, Face, Objects}, geometry::path::SurfacePath,
objects::{Face, Objects},
services::Service, services::Service,
storage::Handle,
}; };
use super::{CurveFaceIntersection, SurfaceSurfaceIntersection}; use super::{CurveFaceIntersection, SurfaceSurfaceIntersection};
@ -18,7 +18,7 @@ pub struct FaceFaceIntersection {
/// representation of the intersection on the respective face's surface. /// representation of the intersection on the respective face's surface.
/// ///
/// They both represent the same global curve. /// They both represent the same global curve.
pub intersection_curves: [Handle<Curve>; 2], pub intersection_curves: [SurfacePath; 2],
/// The interval of this intersection, in curve coordinates /// The interval of this intersection, in curve coordinates
/// ///
@ -36,7 +36,9 @@ impl FaceFaceIntersection {
let intersection_curves = let intersection_curves =
match SurfaceSurfaceIntersection::compute(surfaces, objects) { match SurfaceSurfaceIntersection::compute(surfaces, objects) {
Some(intersection) => intersection.intersection_curves, Some(intersection) => {
intersection.intersection_curves.map(|curve| curve.path())
}
None => return None, None => return None,
}; };
@ -44,9 +46,7 @@ impl FaceFaceIntersection {
.each_ref_ext() .each_ref_ext()
.into_iter_fixed() .into_iter_fixed()
.zip(faces) .zip(faces)
.map(|(curve, face)| { .map(|(curve, face)| CurveFaceIntersection::compute(curve, face))
CurveFaceIntersection::compute(&curve.path(), face)
})
.collect::<[_; 2]>(); .collect::<[_; 2]>();
let intersection_intervals = { let intersection_intervals = {
@ -71,9 +71,9 @@ mod tests {
use crate::{ use crate::{
algorithms::intersect::CurveFaceIntersection, algorithms::intersect::CurveFaceIntersection,
builder::{CurveBuilder, CycleBuilder}, builder::CycleBuilder,
insert::Insert, geometry::path::SurfacePath,
partial::{Partial, PartialCurve, PartialFace, PartialObject}, partial::{Partial, PartialFace, PartialObject},
services::Services, services::Services,
}; };
@ -139,11 +139,8 @@ mod tests {
FaceFaceIntersection::compute([&a, &b], &mut services.objects); FaceFaceIntersection::compute([&a, &b], &mut services.objects);
let expected_curves = surfaces.map(|_| { let expected_curves = surfaces.map(|_| {
let mut curve = PartialCurve::default(); let (path, _) = SurfacePath::line_from_points([[0., 0.], [1., 0.]]);
curve.update_as_line_from_points([[0., 0.], [1., 0.]]); path
curve
.build(&mut services.objects)
.insert(&mut services.objects)
}); });
let expected_intervals = let expected_intervals =
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]); CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);