Skip to content

Commit

Permalink
Merge pull request #1738 from hannobraun/operations
Browse files Browse the repository at this point in the history
Expand operations API; replace `HalfEdgeBuilder`
  • Loading branch information
hannobraun authored Mar 30, 2023
2 parents 96278e8 + da6cc2e commit e4ccc84
Show file tree
Hide file tree
Showing 22 changed files with 291 additions and 260 deletions.
30 changes: 16 additions & 14 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,9 @@ mod tests {

use crate::{
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
builder::HalfEdgeBuilder,
geometry::{curve::GlobalPath, surface::SurfaceGeometry},
objects::Surface,
operations::Insert,
objects::{HalfEdge, Surface},
operations::{BuildHalfEdge, Insert},
services::Services,
};

Expand All @@ -274,9 +273,11 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xz_plane();
let half_edge =
HalfEdgeBuilder::line_segment([[1., 1.], [2., 1.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[1., 1.], [2., 1.]],
None,
&mut services.objects,
);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand All @@ -293,9 +294,11 @@ mod tests {
v: [0., 0., 1.].into(),
})
.insert(&mut services.objects);
let half_edge =
HalfEdgeBuilder::line_segment([[1., 1.], [2., 1.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[1., 1.], [2., 1.]],
None,
&mut services.objects,
);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand All @@ -315,11 +318,11 @@ mod tests {
v: [0., 0., 1.].into(),
})
.insert(&mut services.objects);
let half_edge = HalfEdgeBuilder::line_segment(
let half_edge = HalfEdge::line_segment(
[[0., 1.], [TAU, 1.]],
Some(range.boundary),
)
.build(&mut services.objects);
&mut services.objects,
);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand All @@ -343,8 +346,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xz_plane();
let half_edge =
HalfEdgeBuilder::circle(1.).build(&mut services.objects);
let half_edge = HalfEdge::circle(1., &mut services.objects);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand Down
35 changes: 22 additions & 13 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ mod tests {
use fj_math::Point;

use crate::{
builder::HalfEdgeBuilder, geometry::curve::Curve, services::Services,
geometry::curve::Curve, objects::HalfEdge, operations::BuildHalfEdge,
services::Services,
};

use super::CurveEdgeIntersection;
Expand All @@ -82,9 +83,11 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge =
HalfEdgeBuilder::line_segment([[1., -1.], [1., 1.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[1., -1.], [1., 1.]],
None,
&mut services.objects,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -101,9 +104,11 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge =
HalfEdgeBuilder::line_segment([[-1., -1.], [-1., 1.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[-1., -1.], [-1., 1.]],
None,
&mut services.objects,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -120,9 +125,11 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge =
HalfEdgeBuilder::line_segment([[-1., -1.], [1., -1.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[-1., -1.], [1., -1.]],
None,
&mut services.objects,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand All @@ -134,9 +141,11 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge =
HalfEdgeBuilder::line_segment([[-1., 0.], [1., 0.]], None)
.build(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[-1., 0.], [1., 0.]],
None,
&mut services.objects,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);

Expand Down
10 changes: 8 additions & 2 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ mod tests {
];

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(exterior_points))
.with_interior(CycleBuilder::polygon(interior_points))
.with_exterior(CycleBuilder::polygon(
exterior_points,
&mut services.objects,
))
.with_interior(CycleBuilder::polygon(
interior_points,
&mut services.objects,
))
.build(&mut services.objects);

let expected =
Expand Down
10 changes: 8 additions & 2 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ mod tests {
]
.map(|surface| {
FaceBuilder::new(surface)
.with_exterior(CycleBuilder::polygon(points))
.with_exterior(CycleBuilder::polygon(
points,
&mut services.objects,
))
.build(&mut services.objects)
});

Expand All @@ -112,7 +115,10 @@ mod tests {
];
let [a, b] = surfaces.clone().map(|surface| {
FaceBuilder::new(surface)
.with_exterior(CycleBuilder::polygon(points))
.with_exterior(CycleBuilder::polygon(
points,
&mut services.objects,
))
.build(&mut services.objects)
});

Expand Down
76 changes: 32 additions & 44 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[1., 1.],
[0., 2.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [1., 1.], [0., 2.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([2., 1.]);

Expand All @@ -164,11 +163,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[2., 1.],
[0., 2.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [0., 2.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 1.]);

Expand All @@ -184,11 +182,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[4., 2.],
[0., 4.],
[0., 0.],
]))
.with_exterior(CycleBuilder::polygon(
[[4., 2.], [0., 4.], [0., 0.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 2.]);

Expand All @@ -204,12 +201,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[2., 1.],
[3., 0.],
[3., 4.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 1.]);

Expand All @@ -225,12 +220,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[2., 1.],
[3., 1.],
[0., 2.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 1.]);

Expand All @@ -246,13 +239,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[2., 1.],
[3., 1.],
[4., 0.],
[4., 5.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 1.]);

Expand All @@ -268,11 +258,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[2., 0.],
[0., 1.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 0.], [0., 1.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 0.]);

Expand All @@ -294,11 +283,10 @@ mod tests {
let mut services = Services::new();

let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon([
[0., 0.],
[1., 0.],
[0., 1.],
]))
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [1., 0.], [0., 1.]],
&mut services.objects,
))
.build(&mut services.objects);
let point = Point::from([1., 0.]);

Expand Down
Loading

0 comments on commit e4ccc84

Please sign in to comment.