Skip to content

Commit

Permalink
Merge pull request #1446 from hannobraun/builder
Browse files Browse the repository at this point in the history
Continue cleanup of builder API
  • Loading branch information
hannobraun authored Dec 13, 2022
2 parents bd2094b + 2174bef commit 3e8b54a
Show file tree
Hide file tree
Showing 15 changed files with 399 additions and 445 deletions.
17 changes: 13 additions & 4 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,19 @@ mod tests {
[ 1., -1.],
];

let face = PartialFace::default()
.with_exterior_polygon_from_points(surface.clone(), exterior)
.with_interior_polygon_from_points(surface, interior)
.build(&mut services.objects);
let face = {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface.clone()),
exterior,
);
face.with_interior_polygon_from_points(
Partial::from_full_entry_point(surface),
interior,
);

face.build(&mut services.objects)
};

let expected =
CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]);
Expand Down
20 changes: 14 additions & 6 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ mod tests {
services.objects.surfaces.xz_plane(),
]
.map(|surface| {
PartialFace::default()
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);

face.build(&mut services.objects)
});

let intersection =
Expand All @@ -120,9 +124,13 @@ mod tests {
services.objects.surfaces.xz_plane(),
];
let [a, b] = surfaces.clone().map(|surface| {
PartialFace::default()
.with_exterior_polygon_from_points(surface, points)
.build(&mut services.objects)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);

face.build(&mut services.objects)
});

let intersection =
Expand Down
90 changes: 49 additions & 41 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ mod tests {
builder::FaceBuilder,
insert::Insert,
iter::ObjectIters,
partial::{PartialFace, PartialObject},
partial::{Partial, PartialFace, PartialObject},
services::Services,
};

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

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 1.], [0., 2.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 1.], [0., 2.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([2., 1.]);
Expand All @@ -166,11 +167,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [0., 2.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [0., 2.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -187,11 +189,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[4., 2.], [0., 4.], [0., 0.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[4., 2.], [0., 4.], [0., 0.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 2.]);
Expand All @@ -208,11 +211,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -229,11 +233,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -250,11 +255,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 1.]);
Expand All @@ -271,11 +277,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [2., 0.], [0., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 0.], [0., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 0.]);
Expand All @@ -301,11 +308,12 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[0., 0.], [1., 0.], [0., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 0.], [0., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
let point = Point::from([1., 0.]);
Expand Down
79 changes: 43 additions & 36 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mod tests {
builder::FaceBuilder,
insert::Insert,
iter::ObjectIters,
partial::{PartialFace, PartialObject},
partial::{Partial, PartialFace, PartialObject},
services::Services,
};

Expand All @@ -166,11 +166,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([-1., 0., 0.], &mut services.objects);
Expand All @@ -185,11 +186,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 0., 0.], &mut services.objects);
Expand All @@ -207,11 +209,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([0., 0., 2.], &mut services.objects);
Expand All @@ -226,11 +229,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 1., 0.], &mut services.objects);
Expand All @@ -256,11 +260,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.yz_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([1., 1., 1.], &mut services.objects);
Expand All @@ -284,11 +289,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);

Expand All @@ -305,11 +311,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let surface = services.objects.surfaces.xy_plane();
let face = PartialFace::default()
.with_exterior_polygon_from_points(
surface,
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
)
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
.translate([0., 0., 1.], &mut services.objects);
Expand Down
Loading

0 comments on commit 3e8b54a

Please sign in to comment.