Skip to content

Commit

Permalink
Relax method argument
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Dec 13, 2022
1 parent f33ad6e commit 2174bef
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 42 deletions.
5 changes: 4 additions & 1 deletion crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ mod tests {

let face = {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface.clone(), exterior);
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,
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 @@ -94,7 +94,10 @@ mod tests {
]
.map(|surface| {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface, points);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);

face.build(&mut services.objects)
});
Expand Down Expand Up @@ -122,7 +125,10 @@ mod tests {
];
let [a, b] = surfaces.clone().map(|surface| {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface, points);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);

face.build(&mut services.objects)
});
Expand Down
18 changes: 9 additions & 9 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 @@ -150,7 +150,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 1.], [0., 2.]],
);
let face = face
Expand All @@ -169,7 +169,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [0., 2.]],
);
let face = face
Expand All @@ -191,7 +191,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[4., 2.], [0., 4.], [0., 0.]],
);
let face = face
Expand All @@ -213,7 +213,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
);
let face = face
Expand All @@ -235,7 +235,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
);
let face = face
Expand All @@ -257,7 +257,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
);
let face = face
Expand All @@ -279,7 +279,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [2., 0.], [0., 1.]],
);
let face = face
Expand Down Expand Up @@ -310,7 +310,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 0.], [0., 1.]],
);
let face = face
Expand Down
16 changes: 8 additions & 8 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 @@ -168,7 +168,7 @@ mod tests {
let surface = services.objects.surfaces.yz_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand All @@ -188,7 +188,7 @@ mod tests {
let surface = services.objects.surfaces.yz_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand All @@ -211,7 +211,7 @@ mod tests {
let surface = services.objects.surfaces.yz_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand All @@ -231,7 +231,7 @@ mod tests {
let surface = services.objects.surfaces.yz_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand Down Expand Up @@ -262,7 +262,7 @@ mod tests {
let surface = services.objects.surfaces.yz_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand Down Expand Up @@ -291,7 +291,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand All @@ -313,7 +313,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
);
let face = face
Expand Down
18 changes: 14 additions & 4 deletions crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ mod tests {
.sweep(UP, &mut services.objects);

let mut bottom = PartialFace::default();
bottom.with_exterior_polygon_from_points(surface.clone(), TRIANGLE);
bottom.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface.clone()),
TRIANGLE,
);
let bottom = bottom
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let mut top = PartialFace::default();
top.with_exterior_polygon_from_points(
surface.translate(UP, &mut services.objects),
Partial::from_full_entry_point(
surface.translate(UP, &mut services.objects),
),
TRIANGLE,
);
let top = top
Expand Down Expand Up @@ -169,15 +174,20 @@ mod tests {

let mut bottom = PartialFace::default();
bottom.with_exterior_polygon_from_points(
surface.clone().translate(DOWN, &mut services.objects),
Partial::from_full_entry_point(
surface.clone().translate(DOWN, &mut services.objects),
),
TRIANGLE,
);
let bottom = bottom
.build(&mut services.objects)
.insert(&mut services.objects)
.reverse(&mut services.objects);
let mut top = PartialFace::default();
top.with_exterior_polygon_from_points(surface, TRIANGLE);
top.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
TRIANGLE,
);
let top = top
.build(&mut services.objects)
.insert(&mut services.objects);
Expand Down
12 changes: 9 additions & 3 deletions crates/fj-kernel/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface, [a, b, c, d]);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
[a, b, c, d],
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand Down Expand Up @@ -134,7 +137,10 @@ mod tests {

let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface.clone(), [a, b, c, d]);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface.clone()),
[a, b, c, d],
);
face.with_interior_polygon_from_points(
Partial::from_full_entry_point(surface.clone()),
[e, f, g, h],
Expand Down Expand Up @@ -197,7 +203,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface.clone(),
Partial::from_full_entry_point(surface.clone()),
[a, b, c, d, e],
);
let face = face
Expand Down
10 changes: 3 additions & 7 deletions crates/fj-kernel/src/builder/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use fj_math::Point;
use crate::{
objects::Surface,
partial::{Partial, PartialCycle, PartialFace},
storage::Handle,
};

use super::CycleBuilder;
Expand All @@ -13,7 +12,7 @@ pub trait FaceBuilder {
/// Update the [`PartialFace`] with an exterior polygon
fn with_exterior_polygon_from_points(
&mut self,
surface: Handle<Surface>,
surface: Partial<Surface>,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
);

Expand All @@ -28,14 +27,11 @@ pub trait FaceBuilder {
impl FaceBuilder for PartialFace {
fn with_exterior_polygon_from_points(
&mut self,
surface: Handle<Surface>,
surface: Partial<Surface>,
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) {
let mut cycle = PartialCycle::default();
cycle.with_poly_chain_from_points(
Partial::from_full_entry_point(surface),
points,
);
cycle.with_poly_chain_from_points(surface, points);
cycle.close_with_line_segment();

self.exterior = Partial::from_partial(cycle);
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ShellBuilder {

let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[-h, -h], [h, -h], [h, h], [-h, h]],
);

Expand Down
7 changes: 5 additions & 2 deletions crates/fj-kernel/src/builder/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use fj_math::Point;
use crate::{
insert::Insert,
objects::{Face, FaceSet, Objects, Sketch, Surface},
partial::{PartialFace, PartialObject},
partial::{Partial, PartialFace, PartialObject},
services::Service,
storage::Handle,
};
Expand Down Expand Up @@ -36,7 +36,10 @@ impl SketchBuilder {
objects: &mut Service<Objects>,
) -> Self {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface, points);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);
let face = face.build(objects).insert(objects);

self.faces.extend([face]);
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut object = PartialFace::default();
object.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 0.], [0., 1.]],
);
let object = object
Expand Down Expand Up @@ -558,7 +558,7 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface,
Partial::from_full_entry_point(surface),
[[0., 0.], [1., 0.], [0., 1.]],
);
let face = face
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/validate/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod tests {
let valid = {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface.clone(),
Partial::from_full_entry_point(surface.clone()),
[[0., 0.], [3., 0.], [0., 3.]],
);
face.with_interior_polygon_from_points(
Expand Down Expand Up @@ -162,7 +162,7 @@ mod tests {
let valid = {
let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(
surface.clone(),
Partial::from_full_entry_point(surface.clone()),
[[0., 0.], [3., 0.], [0., 3.]],
);
face.with_interior_polygon_from_points(
Expand Down
5 changes: 4 additions & 1 deletion crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ impl Shape for fj::Sketch {
.map(Point::from);

let mut face = PartialFace::default();
face.with_exterior_polygon_from_points(surface, points);
face.with_exterior_polygon_from_points(
Partial::from_full_entry_point(surface),
points,
);
face.color = Some(Color(self.color()));

face.build(objects).insert(objects)
Expand Down

0 comments on commit 2174bef

Please sign in to comment.