Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant struct fields in partial object API #1407

Merged
merged 11 commits into from
Nov 30, 2022
5 changes: 2 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,8 @@ mod tests {
];

let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points(exterior)
.with_interior_polygon_from_points(interior)
.with_exterior_polygon_from_points(surface.clone(), exterior)
.with_interior_polygon_from_points(surface, interior)
.build(&mut services.objects);

let expected =
Expand Down
6 changes: 2 additions & 4 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ mod tests {
]
.map(|surface| {
Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points(points)
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
});

Expand All @@ -123,8 +122,7 @@ mod tests {
];
let [a, b] = surfaces.clone().map(|surface| {
Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points(points)
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
});

Expand Down
64 changes: 32 additions & 32 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 1.], [0., 2.]])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 1.], [0., 2.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([2., 1.]);
Expand All @@ -166,8 +168,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[0., 0.], [2., 1.], [0., 2.]])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [0., 2.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -185,8 +189,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[4., 2.], [0., 4.], [0., 0.]])
.with_exterior_polygon_from_points(
surface,
[[4., 2.], [0., 4.], [0., 0.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 2.]);
Expand All @@ -204,13 +210,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 0.],
[3., 4.],
])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -228,13 +231,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 1.],
[0., 2.],
])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -252,14 +252,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 1.],
[4., 0.],
[4., 5.],
])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -277,8 +273,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[0., 0.], [2., 0.], [0., 1.]])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 0.], [0., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 0.]);
Expand All @@ -305,8 +303,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 0.], [0., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 0.]);
Expand Down
77 changes: 28 additions & 49 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,10 @@ mod tests {

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([-1., 0., 0.], &mut services.objects);
Expand All @@ -190,13 +187,10 @@ mod tests {

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 0., 0.], &mut services.objects);
Expand All @@ -215,13 +209,10 @@ mod tests {

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([0., 0., 2.], &mut services.objects);
Expand All @@ -237,13 +228,10 @@ mod tests {

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 1., 0.], &mut services.objects);
Expand All @@ -270,13 +258,10 @@ mod tests {

let surface = services.objects.surfaces.yz_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 1., 1.], &mut services.objects);
Expand All @@ -301,13 +286,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects);

Expand All @@ -325,13 +307,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([0., 0., 1.], &mut services.objects);
Expand Down
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ mod tests {
.sweep(UP, &mut services.objects);

let bottom = Face::partial()
.with_surface(surface.clone())
.with_exterior_polygon_from_points(TRIANGLE)
.with_exterior_polygon_from_points(surface.clone(), TRIANGLE)
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let top = Face::partial()
.with_surface(surface.translate(UP, &mut services.objects))
.with_exterior_polygon_from_points(TRIANGLE)
.with_exterior_polygon_from_points(
surface.translate(UP, &mut services.objects),
TRIANGLE,
)
.build(&mut services.objects)
.insert(&mut services.objects);

Expand Down Expand Up @@ -153,16 +154,15 @@ mod tests {
.sweep(DOWN, &mut services.objects);

let bottom = Face::partial()
.with_surface(
.with_exterior_polygon_from_points(
surface.clone().translate(DOWN, &mut services.objects),
TRIANGLE,
)
.with_exterior_polygon_from_points(TRIANGLE)
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let top = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points(TRIANGLE)
.with_exterior_polygon_from_points(surface, TRIANGLE)
.build(&mut services.objects)
.insert(&mut services.objects);

Expand Down
11 changes: 4 additions & 7 deletions crates/fj-kernel/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface)
.with_exterior_polygon_from_points([a, b, c, d])
.with_exterior_polygon_from_points(surface, [a, b, c, d])
.build(&mut services.objects)
.insert(&mut services.objects);

Expand Down Expand Up @@ -134,9 +133,8 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface.clone())
.with_exterior_polygon_from_points([a, b, c, d])
.with_interior_polygon_from_points([e, f, g, h])
.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d])
.with_interior_polygon_from_points(surface.clone(), [e, f, g, h])
.build(&mut services.objects)
.insert(&mut services.objects);

Expand Down Expand Up @@ -193,8 +191,7 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let face = Face::partial()
.with_surface(surface.clone())
.with_exterior_polygon_from_points([a, b, c, d, e])
.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d, e])
.build(&mut services.objects)
.insert(&mut services.objects);

Expand Down
1 change: 0 additions & 1 deletion crates/fj-kernel/src/builder/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl CycleBuilder for PartialCycle {
);

half_edges.push(PartialHalfEdge {
curve: curve.into(),
vertices: vertices.map(Into::into),
..Default::default()
});
Expand Down
Loading