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

Rename all object's build methods to builder #1118

Merged
merged 9 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ mod tests {
let stores = Stores::new();

let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]);
let curve = Curve::build(&stores, surface)
let curve = Curve::builder(&stores, surface)
.line_from_points([[1., 1.], [2., 1.]]);
let range = RangeOnPath::from([[0.], [1.]]);

Expand All @@ -222,7 +222,7 @@ mod tests {

let surface =
Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]);
let curve = Curve::build(&stores, surface)
let curve = Curve::builder(&stores, surface)
.line_from_points([[1., 1.], [1., 2.]]);
let range = RangeOnPath::from([[0.], [1.]]);

Expand All @@ -237,7 +237,7 @@ mod tests {

let path = GlobalPath::circle_from_radius(1.);
let surface = Surface::new(path, [0., 0., 1.]);
let curve = Curve::build(&stores, surface)
let curve = Curve::builder(&stores, surface)
.line_from_points([[0., 1.], [1., 1.]]);

let range = RangeOnPath::from([[0.], [TAU]]);
Expand All @@ -264,7 +264,7 @@ mod tests {
let stores = Stores::new();

let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]);
let curve = Curve::build(&stores, surface).circle_from_radius(1.);
let curve = Curve::builder(&stores, surface).circle_from_radius(1.);

let range = RangeOnPath::from([[0.], [TAU]]);
let tolerance = 1.;
Expand Down
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let curve = Curve::build(&stores, surface).u_axis();
let half_edge = HalfEdge::build(&stores, surface)
let curve = Curve::builder(&stores, surface).u_axis();
let half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[1., -1.], [1., 1.]]);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -105,8 +105,8 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let curve = Curve::build(&stores, surface).u_axis();
let half_edge = HalfEdge::build(&stores, surface)
let curve = Curve::builder(&stores, surface).u_axis();
let half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[-1., -1.], [-1., 1.]]);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -124,8 +124,8 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let curve = Curve::build(&stores, surface).u_axis();
let half_edge = HalfEdge::build(&stores, surface)
let curve = Curve::builder(&stores, surface).u_axis();
let half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[-1., -1.], [1., -1.]]);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -138,8 +138,8 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let curve = Curve::build(&stores, surface).u_axis();
let half_edge = HalfEdge::build(&stores, surface)
let curve = Curve::builder(&stores, surface).u_axis();
let half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[-1., 0.], [1., 0.]]);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {

let surface = Surface::xy_plane();

let curve = Curve::build(&stores, surface)
let curve = Curve::builder(&stores, surface)
.line_from_points([[-3., 0.], [-2., 0.]]);

#[rustfmt::skip]
Expand All @@ -186,7 +186,7 @@ mod tests {
[-1., 1.],
];

let face = Face::build(&stores, surface)
let face = Face::builder(&stores, surface)
.polygon_from_points(exterior)
.with_hole(interior)
.into_face();
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ mod tests {
];
let surfaces = [Surface::xy_plane(), Surface::xz_plane()];
let [a, b] = surfaces.map(|surface| {
Face::build(&stores, surface)
Face::builder(&stores, surface)
.polygon_from_points(points)
.into_face()
});
Expand All @@ -106,15 +106,15 @@ mod tests {
];
let surfaces = [Surface::xy_plane(), Surface::xz_plane()];
let [a, b] = surfaces.map(|surface| {
Face::build(&stores, surface)
Face::builder(&stores, surface)
.polygon_from_points(points)
.into_face()
});

let intersection = FaceFaceIntersection::compute([&a, &b], &stores);

let expected_curves = surfaces.map(|surface| {
Curve::build(&stores, surface)
Curve::builder(&stores, surface)
.line_from_points([[0., 0.], [1., 0.]])
});
let expected_intervals =
Expand Down
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ mod tests {
fn point_is_outside_face() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [1., 1.], [0., 2.]])
.into_face();
let point = Point::from([2., 1.]);
Expand All @@ -155,7 +155,7 @@ mod tests {
fn ray_hits_vertex_while_passing_outside() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [0., 2.]])
.into_face();
let point = Point::from([1., 1.]);
Expand All @@ -171,7 +171,7 @@ mod tests {
fn ray_hits_vertex_at_cycle_seam() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[4., 2.], [0., 4.], [0., 0.]])
.into_face();
let point = Point::from([1., 2.]);
Expand All @@ -187,7 +187,7 @@ mod tests {
fn ray_hits_vertex_while_staying_inside() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [3., 0.], [3., 4.]])
.into_face();
let point = Point::from([1., 1.]);
Expand All @@ -203,7 +203,7 @@ mod tests {
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [3., 1.], [0., 2.]])
.into_face();
let point = Point::from([1., 1.]);
Expand All @@ -219,7 +219,7 @@ mod tests {
fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([
[0., 0.],
[2., 1.],
Expand All @@ -241,7 +241,7 @@ mod tests {
fn point_is_coincident_with_edge() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 0.], [0., 1.]])
.into_face();
let point = Point::from([1., 0.]);
Expand All @@ -266,7 +266,7 @@ mod tests {
fn point_is_coincident_with_vertex() {
let stores = Stores::new();

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.into_face();
let point = Point::from([1., 0.]);
Expand Down
14 changes: 7 additions & 7 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::yz_plane())
let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([-1., 0., 0.], &stores);
Expand All @@ -182,7 +182,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::yz_plane())
let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([1., 0., 0.], &stores);
Expand All @@ -199,7 +199,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::yz_plane())
let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([0., 0., 2.], &stores);
Expand All @@ -213,7 +213,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::yz_plane())
let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([1., 1., 0.], &stores);
Expand All @@ -238,7 +238,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::yz_plane())
let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([1., 1., 1.], &stores);
Expand All @@ -261,7 +261,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face();

Expand All @@ -277,7 +277,7 @@ mod tests {

let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::build(&stores, Surface::xy_plane())
let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.into_face()
.translate([0., 0., 1.], &stores);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ mod tests {
None,
);

let expected_xy = Curve::build(&stores, xy).u_axis();
let expected_xz = Curve::build(&stores, xz).u_axis();
let expected_xy = Curve::builder(&stores, xy).u_axis();
let expected_xz = Curve::builder(&stores, xz).u_axis();

assert_eq!(
SurfaceSurfaceIntersection::compute([&xy, &xz], &stores),
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ mod tests {
fn sweep() {
let stores = Stores::new();

let half_edge = HalfEdge::build(&stores, Surface::xy_plane())
let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([[0., 0.], [1., 0.]]);

let face = (half_edge, Color::default()).sweep([0., 0., 1.], &stores);

let expected_face = {
let surface = Surface::xz_plane();
let builder = HalfEdge::build(&stores, surface);
let builder = HalfEdge::builder(&stores, surface);

let bottom = builder.line_segment_from_points([[0., 0.], [1., 0.]]);
let top = builder
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 @@ -90,15 +90,15 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let solid = Sketch::build(&stores, surface)
let solid = Sketch::builder(&stores, surface)
.polygon_from_points(TRIANGLE)
.sweep(UP, &stores);

let bottom = Face::build(&stores, surface)
let bottom = Face::builder(&stores, surface)
.polygon_from_points(TRIANGLE)
.into_face()
.reverse();
let top = Face::build(&stores, surface.translate(UP, &stores))
let top = Face::builder(&stores, surface.translate(UP, &stores))
.polygon_from_points(TRIANGLE)
.into_face();

Expand All @@ -112,7 +112,7 @@ mod tests {
// https://doc.rust-lang.org/std/primitive.slice.html#method.array_windows
let [a, b] = [window[0], window[1]];

let half_edge = HalfEdge::build(&stores, Surface::xy_plane())
let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([a, b]);
(half_edge, Color::default()).sweep(UP, &stores)
});
Expand All @@ -125,15 +125,15 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let solid = Sketch::build(&stores, surface)
let solid = Sketch::builder(&stores, surface)
.polygon_from_points(TRIANGLE)
.sweep(DOWN, &stores);

let bottom = Face::build(&stores, surface.translate(DOWN, &stores))
let bottom = Face::builder(&stores, surface.translate(DOWN, &stores))
.polygon_from_points(TRIANGLE)
.into_face()
.reverse();
let top = Face::build(&stores, surface)
let top = Face::builder(&stores, surface)
.polygon_from_points(TRIANGLE)
.into_face();

Expand All @@ -147,7 +147,7 @@ mod tests {
// https://doc.rust-lang.org/std/primitive.slice.html#method.array_windows
let [a, b] = [window[0], window[1]];

let half_edge = HalfEdge::build(&stores, Surface::xy_plane())
let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([a, b])
.reverse();
(half_edge, Color::default()).sweep(DOWN, &stores)
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xz_plane();
let curve = Curve::build(&stores, surface).u_axis();
let vertex = Vertex::build(curve).from_point([0.]);
let curve = Curve::builder(&stores, surface).u_axis();
let vertex = Vertex::builder(curve).from_point([0.]);

let half_edge = (vertex, surface).sweep([0., 0., 1.], &stores);

let expected_half_edge = HalfEdge::build(&stores, surface)
let expected_half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[0., 0.], [0., 1.]]);
assert_eq!(half_edge, expected_half_edge);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
let d = [0., 1.];

let surface = Surface::xy_plane();
let face = Face::build(&stores, surface)
let face = Face::builder(&stores, surface)
.polygon_from_points([a, b, c, d])
.into_face();

Expand Down Expand Up @@ -145,7 +145,7 @@ mod tests {
let h = [1., 2.];

let surface = Surface::xy_plane();
let face = Face::build(&stores, surface)
let face = Face::builder(&stores, surface)
.polygon_from_points([a, b, c, d])
.with_hole([e, f, g, h])
.into_face();
Expand Down Expand Up @@ -198,7 +198,7 @@ mod tests {
let e = Point::from([0., 0.8]);

let surface = Surface::xy_plane();
let face = Face::build(&stores, surface)
let face = Face::builder(&stores, surface)
.polygon_from_points([a, b, c, d, e])
.into_face();

Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{

/// API for building a [`Curve`]
///
/// Also see [`Curve::build`].
/// Also see [`Curve::builder`].
pub struct CurveBuilder<'a> {
/// The stores that the created objects are put in
pub stores: &'a Stores,
Expand Down
Loading