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

Change naming convention of builder methods #1123

Merged
merged 12 commits into from
Sep 21, 2022
9 changes: 5 additions & 4 deletions crates/fj-kernel/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod tests {

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

let approx = (&curve, range).approx(1.);
Expand All @@ -225,7 +225,7 @@ mod tests {
let surface =
Surface::new(GlobalPath::circle_from_radius(1.), [0., 0., 1.]);
let curve = Curve::builder(&stores, surface)
.line_from_points([[1., 1.], [1., 2.]]);
.build_line_from_points([[1., 1.], [1., 2.]]);
let range = RangeOnPath::from([[0.], [1.]]);

let approx = (&curve, range).approx(1.);
Expand All @@ -240,7 +240,7 @@ mod tests {
let path = GlobalPath::circle_from_radius(1.);
let surface = Surface::new(path, [0., 0., 1.]);
let curve = Curve::builder(&stores, surface)
.line_from_points([[0., 1.], [1., 1.]]);
.build_line_from_points([[0., 1.], [1., 1.]]);

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

let surface = Surface::new(GlobalPath::x_axis(), [0., 0., 1.]);
let curve = Curve::builder(&stores, surface).circle_from_radius(1.);
let curve =
Curve::builder(&stores, surface).build_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,9 +86,9 @@ mod tests {
let stores = Stores::new();

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

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

Expand All @@ -105,9 +105,9 @@ mod tests {
let stores = Stores::new();

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

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

Expand All @@ -124,9 +124,9 @@ mod tests {
let stores = Stores::new();

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

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

Expand All @@ -138,9 +138,9 @@ mod tests {
let stores = Stores::new();

let surface = Surface::xy_plane();
let curve = Curve::builder(&stores, surface).u_axis();
let curve = Curve::builder(&stores, surface).build_u_axis();
let half_edge = HalfEdge::builder(&stores, surface)
.line_segment_from_points([[-1., 0.], [1., 0.]]);
.build_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 @@ -169,7 +169,7 @@ mod tests {
let surface = Surface::xy_plane();

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

#[rustfmt::skip]
let exterior = [
Expand All @@ -187,7 +187,7 @@ mod tests {
];

let face = Face::builder(&stores, surface)
.polygon_from_points(exterior)
.build_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 @@ -84,7 +84,7 @@ mod tests {
let surfaces = [Surface::xy_plane(), Surface::xz_plane()];
let [a, b] = surfaces.map(|surface| {
Face::builder(&stores, surface)
.polygon_from_points(points)
.build_polygon_from_points(points)
.into_face()
});

Expand All @@ -107,15 +107,15 @@ mod tests {
let surfaces = [Surface::xy_plane(), Surface::xz_plane()];
let [a, b] = surfaces.map(|surface| {
Face::builder(&stores, surface)
.polygon_from_points(points)
.build_polygon_from_points(points)
.into_face()
});

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

let expected_curves = surfaces.map(|surface| {
Curve::builder(&stores, surface)
.line_from_points([[0., 0.], [1., 0.]])
.build_line_from_points([[0., 0.], [1., 0.]])
});
let expected_intervals =
CurveFaceIntersection::from_intervals([[[-1.], [1.]]]);
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 @@ -143,7 +143,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [1., 1.], [0., 2.]])
.build_polygon_from_points([[0., 0.], [1., 1.], [0., 2.]])
.into_face();
let point = Point::from([2., 1.]);

Expand All @@ -156,7 +156,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [0., 2.]])
.build_polygon_from_points([[0., 0.], [2., 1.], [0., 2.]])
.into_face();
let point = Point::from([1., 1.]);

Expand All @@ -172,7 +172,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[4., 2.], [0., 4.], [0., 0.]])
.build_polygon_from_points([[4., 2.], [0., 4.], [0., 0.]])
.into_face();
let point = Point::from([1., 2.]);

Expand All @@ -188,7 +188,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [3., 0.], [3., 4.]])
.build_polygon_from_points([[0., 0.], [2., 1.], [3., 0.], [3., 4.]])
.into_face();
let point = Point::from([1., 1.]);

Expand All @@ -204,7 +204,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 1.], [3., 1.], [0., 2.]])
.build_polygon_from_points([[0., 0.], [2., 1.], [3., 1.], [0., 2.]])
.into_face();
let point = Point::from([1., 1.]);

Expand All @@ -220,7 +220,7 @@ mod tests {
let stores = Stores::new();

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

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [2., 0.], [0., 1.]])
.build_polygon_from_points([[0., 0.], [2., 0.], [0., 1.]])
.into_face();
let point = Point::from([1., 0.]);

Expand All @@ -267,7 +267,7 @@ mod tests {
let stores = Stores::new();

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.build_polygon_from_points([[0., 0.], [1., 0.], [0., 1.]])
.into_face();
let point = Point::from([1., 0.]);

Expand Down
49 changes: 42 additions & 7 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.build_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.into_face()
.translate([-1., 0., 0.], &stores);

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

let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.build_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.into_face()
.translate([1., 0., 0.], &stores);

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

let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.build_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.into_face()
.translate([0., 0., 2.], &stores);

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

let face = Face::builder(&stores, Surface::yz_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.build_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
[-1., 1.],
])
.into_face()
.translate([1., 1., 0.], &stores);

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

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

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

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

assert_eq!(
Expand All @@ -278,7 +308,12 @@ mod tests {
let ray = HorizontalRayToTheRight::from([0., 0., 0.]);

let face = Face::builder(&stores, Surface::xy_plane())
.polygon_from_points([[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]])
.build_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::builder(&stores, xy).u_axis();
let expected_xz = Curve::builder(&stores, xz).u_axis();
let expected_xy = Curve::builder(&stores, xy).build_u_axis();
let expected_xz = Curve::builder(&stores, xz).build_u_axis();

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

let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([[0., 0.], [1., 0.]]);
.build_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::builder(&stores, surface);

let bottom = builder.line_segment_from_points([[0., 0.], [1., 0.]]);
let bottom =
builder.build_line_segment_from_points([[0., 0.], [1., 0.]]);
let top = builder
.line_segment_from_points([[0., 1.], [1., 1.]])
.build_line_segment_from_points([[0., 1.], [1., 1.]])
.reverse();
let left = builder
.line_segment_from_points([[0., 0.], [0., 1.]])
.build_line_segment_from_points([[0., 0.], [0., 1.]])
.reverse();
let right = builder.line_segment_from_points([[1., 0.], [1., 1.]]);
let right =
builder.build_line_segment_from_points([[1., 0.], [1., 1.]]);

let cycle = Cycle::new(surface, [bottom, right, top, left]);

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 @@ -91,15 +91,15 @@ mod tests {

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

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

assert!(solid.find_face(&bottom).is_some());
Expand All @@ -113,7 +113,7 @@ mod tests {
let [a, b] = [window[0], window[1]];

let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([a, b]);
.build_line_segment_from_points([a, b]);
(half_edge, Color::default()).sweep(UP, &stores)
});

Expand All @@ -126,15 +126,15 @@ mod tests {

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

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

assert!(solid.find_face(&bottom).is_some());
Expand All @@ -148,7 +148,7 @@ mod tests {
let [a, b] = [window[0], window[1]];

let half_edge = HalfEdge::builder(&stores, Surface::xy_plane())
.line_segment_from_points([a, b])
.build_line_segment_from_points([a, b])
.reverse();
(half_edge, Color::default()).sweep(DOWN, &stores)
});
Expand Down
Loading