mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-19 13:45:51 +00:00
Rewrite tests to approximate HalfEdge
This commit is contained in:
parent
4534580c9d
commit
7c38fc2023
@ -80,13 +80,10 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
|
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
|
||||||
builder::{CurveBuilder, HalfEdgeBuilder, SurfaceBuilder},
|
builder::{HalfEdgeBuilder, SurfaceBuilder},
|
||||||
geometry::path::GlobalPath,
|
geometry::path::GlobalPath,
|
||||||
insert::Insert,
|
insert::Insert,
|
||||||
objects::GlobalCurve,
|
partial::{PartialHalfEdge, PartialObject, PartialSurface},
|
||||||
partial::{
|
|
||||||
PartialCurve, PartialHalfEdge, PartialObject, PartialSurface,
|
|
||||||
},
|
|
||||||
services::Services,
|
services::Services,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -151,29 +148,41 @@ mod tests {
|
|||||||
let surface = PartialSurface::from_axes(path, [0., 0., 1.])
|
let surface = PartialSurface::from_axes(path, [0., 0., 1.])
|
||||||
.build(&mut services.objects)
|
.build(&mut services.objects)
|
||||||
.insert(&mut services.objects);
|
.insert(&mut services.objects);
|
||||||
let mut curve = PartialCurve::default();
|
let half_edge = {
|
||||||
curve.update_as_line_from_points([[0., 1.], [1., 1.]]);
|
let mut half_edge = PartialHalfEdge::default();
|
||||||
let curve = curve
|
|
||||||
.build(&mut services.objects)
|
half_edge.update_as_line_segment_from_points([[0., 1.], [1., 1.]]);
|
||||||
.insert(&mut services.objects);
|
|
||||||
let global_curve = GlobalCurve.insert(&mut services.objects);
|
half_edge.vertices[0].0 = Some(range.boundary[0]);
|
||||||
|
half_edge.vertices[1].0 = Some(range.boundary[1]);
|
||||||
|
|
||||||
|
half_edge.infer_vertex_positions_if_necessary(&surface.geometry());
|
||||||
|
|
||||||
|
half_edge
|
||||||
|
.build(&mut services.objects)
|
||||||
|
.insert(&mut services.objects)
|
||||||
|
};
|
||||||
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx =
|
let approx = (&half_edge, surface.deref()).approx(tolerance);
|
||||||
(&curve, surface.deref(), global_curve, range).approx(tolerance);
|
|
||||||
|
|
||||||
let expected_approx = (path, range)
|
let expected_approx = (path, range)
|
||||||
.approx(tolerance)
|
.approx(tolerance)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(point_local, _)| {
|
.map(|(point_local, _)| {
|
||||||
let point_surface =
|
let point_surface = half_edge
|
||||||
curve.path().point_from_path_coords(point_local);
|
.curve()
|
||||||
|
.path()
|
||||||
|
.point_from_path_coords(point_local);
|
||||||
let point_global =
|
let point_global =
|
||||||
surface.geometry().point_from_surface_coords(point_surface);
|
surface.geometry().point_from_surface_coords(point_surface);
|
||||||
ApproxPoint::new(point_surface, point_global)
|
ApproxPoint::new(point_surface, point_global)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
assert_eq!(approx, CurveApprox::empty().with_points(expected_approx));
|
assert_eq!(
|
||||||
|
approx.curve_approx,
|
||||||
|
CurveApprox::empty().with_points(expected_approx)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -181,27 +190,34 @@ mod tests {
|
|||||||
let mut services = Services::new();
|
let mut services = Services::new();
|
||||||
|
|
||||||
let surface = services.objects.surfaces.xz_plane();
|
let surface = services.objects.surfaces.xz_plane();
|
||||||
let mut curve = PartialCurve::default();
|
let half_edge = {
|
||||||
curve.update_as_circle_from_radius(1.);
|
let mut half_edge = PartialHalfEdge::default();
|
||||||
let curve = curve
|
|
||||||
.build(&mut services.objects)
|
half_edge.update_as_circle_from_radius(1.);
|
||||||
.insert(&mut services.objects);
|
half_edge.infer_vertex_positions_if_necessary(&surface.geometry());
|
||||||
let global_curve = GlobalCurve.insert(&mut services.objects);
|
|
||||||
|
half_edge
|
||||||
|
.build(&mut services.objects)
|
||||||
|
.insert(&mut services.objects)
|
||||||
|
};
|
||||||
|
|
||||||
let range = RangeOnPath::from([[0.], [TAU]]);
|
|
||||||
let tolerance = 1.;
|
let tolerance = 1.;
|
||||||
let approx =
|
let approx = (&half_edge, surface.deref()).approx(tolerance);
|
||||||
(&curve, surface.deref(), global_curve, range).approx(tolerance);
|
|
||||||
|
|
||||||
let expected_approx = (curve.path(), range)
|
let expected_approx =
|
||||||
.approx(tolerance)
|
(half_edge.curve().path(), RangeOnPath::from([[0.], [TAU]]))
|
||||||
.into_iter()
|
.approx(tolerance)
|
||||||
.map(|(_, point_surface)| {
|
.into_iter()
|
||||||
let point_global =
|
.map(|(_, point_surface)| {
|
||||||
surface.geometry().point_from_surface_coords(point_surface);
|
let point_global = surface
|
||||||
ApproxPoint::new(point_surface, point_global)
|
.geometry()
|
||||||
})
|
.point_from_surface_coords(point_surface);
|
||||||
.collect::<Vec<_>>();
|
ApproxPoint::new(point_surface, point_global)
|
||||||
assert_eq!(approx, CurveApprox::empty().with_points(expected_approx));
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
assert_eq!(
|
||||||
|
approx.curve_approx,
|
||||||
|
CurveApprox::empty().with_points(expected_approx)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user