From 71fa07a0d9b5b32b00c9fc22b7854eed02923722 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 13 Mar 2023 13:48:56 +0100 Subject: [PATCH 1/2] Simplify tests --- .../src/algorithms/intersect/curve_edge.rs | 57 +++++-------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs index 62c6961af..f63cd17af 100644 --- a/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs +++ b/crates/fj-kernel/src/algorithms/intersect/curve_edge.rs @@ -72,10 +72,7 @@ mod tests { use fj_math::Point; use crate::{ - builder::CycleBuilder, - geometry::curve::Curve, - partial::{PartialCycle, PartialObject}, - services::Services, + builder::HalfEdgeBuilder, geometry::curve::Curve, services::Services, }; use super::CurveEdgeIntersection; @@ -85,16 +82,9 @@ mod tests { let mut services = Services::new(); let curve = Curve::u_axis(); - let half_edge = { - let mut cycle = PartialCycle::new(&mut services.objects); - - let [half_edge, _, _] = cycle.update_as_polygon_from_points( - [[1., -1.], [1., 1.], [0., 1.]], - &mut services.objects, - ); - - half_edge - }; + let half_edge = + HalfEdgeBuilder::line_segment([[1., -1.], [1., 1.]], None) + .build(&mut services.objects); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); @@ -111,16 +101,9 @@ mod tests { let mut services = Services::new(); let curve = Curve::u_axis(); - let half_edge = { - let mut cycle = PartialCycle::new(&mut services.objects); - - let [half_edge, _, _] = cycle.update_as_polygon_from_points( - [[-1., -1.], [-1., 1.], [0., 1.]], - &mut services.objects, - ); - - half_edge - }; + let half_edge = + HalfEdgeBuilder::line_segment([[-1., -1.], [-1., 1.]], None) + .build(&mut services.objects); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); @@ -137,16 +120,9 @@ mod tests { let mut services = Services::new(); let curve = Curve::u_axis(); - let half_edge = { - let mut cycle = PartialCycle::new(&mut services.objects); - - let [half_edge, _, _] = cycle.update_as_polygon_from_points( - [[-1., -1.], [1., -1.], [1., 1.]], - &mut services.objects, - ); - - half_edge - }; + let half_edge = + HalfEdgeBuilder::line_segment([[-1., -1.], [1., -1.]], None) + .build(&mut services.objects); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); @@ -158,16 +134,9 @@ mod tests { let mut services = Services::new(); let curve = Curve::u_axis(); - let half_edge = { - let mut cycle = PartialCycle::new(&mut services.objects); - - let [half_edge, _, _] = cycle.update_as_polygon_from_points( - [[-1., 0.], [1., 0.], [1., 1.]], - &mut services.objects, - ); - - half_edge - }; + let half_edge = + HalfEdgeBuilder::line_segment([[-1., 0.], [1., 0.]], None) + .build(&mut services.objects); let intersection = CurveEdgeIntersection::compute(&curve, &half_edge); From 85ebe50514e8638f6b72bacc47a3dbb64c72a7d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 13 Mar 2023 13:56:26 +0100 Subject: [PATCH 2/2] Simplify test --- crates/fj-kernel/src/validate/edge.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/crates/fj-kernel/src/validate/edge.rs b/crates/fj-kernel/src/validate/edge.rs index 5df0d80ac..0f41f6629 100644 --- a/crates/fj-kernel/src/validate/edge.rs +++ b/crates/fj-kernel/src/validate/edge.rs @@ -76,9 +76,8 @@ mod tests { use fj_math::Point; use crate::{ - builder::CycleBuilder, + builder::HalfEdgeBuilder, objects::HalfEdge, - partial::{PartialCycle, PartialObject}, services::Services, validate::{HalfEdgeValidationError, Validate, ValidationError}, }; @@ -87,16 +86,8 @@ mod tests { fn half_edge_vertices_are_coincident() -> anyhow::Result<()> { let mut services = Services::new(); - let valid = { - let mut cycle = PartialCycle::new(&mut services.objects); - - let [half_edge, _, _] = cycle.update_as_polygon_from_points( - [[0., 0.], [1., 0.], [1., 1.]], - &mut services.objects, - ); - - half_edge - }; + let valid = HalfEdgeBuilder::line_segment([[0., 0.], [1., 0.]], None) + .build(&mut services.objects); let invalid = { let boundary = [Point::from([0.]); 2];