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

Clean up in-kernel services API #1795

Merged
merged 28 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
35a226a
Take full `Services` in `Shape::compute_brep`
hannobraun Apr 26, 2023
b593481
Take full `Services` in `Sweep::sweep`
hannobraun Apr 26, 2023
dd223fc
Inline redundant variable
hannobraun Apr 26, 2023
679cc9c
Take full `Services` in `Sweep::sweep_with_cache`
hannobraun Apr 26, 2023
8397c13
Take full `Services` in `Reverse::reverse`
hannobraun Apr 26, 2023
1a4b8ca
Take full `Services` in `TransformObject::rotate`
hannobraun Apr 26, 2023
3f06367
Take full `Services` in `translate`
hannobraun Apr 26, 2023
35b3287
Take full `Services` in `transform`
hannobraun Apr 26, 2023
0a58b78
Take full `Services` in `transform_with_cache`
hannobraun Apr 26, 2023
f5ed63d
Take full `Services` in `connect_to_edges`
hannobraun Apr 26, 2023
36f3cb6
Take full `Services` in `CycleBuilder::polygon`
hannobraun Apr 26, 2023
a7e9033
Take full `Services` in `FaceBuilder::build`
hannobraun Apr 26, 2023
184b0d2
Take full `Services` in `CycleBuilder::build`
hannobraun Apr 26, 2023
31c8572
Take full `Services` in `BuildHalfEdge::arc`
hannobraun Apr 26, 2023
5afa720
Take full `Services` in `BuildHalfEdge::circle`
hannobraun Apr 26, 2023
75e0783
Take full `Services` in `BuildShell::tetrahedron`
hannobraun Apr 26, 2023
c032d25
Take full `Services` in `BuildFace::triangle`
hannobraun Apr 26, 2023
3b10ee4
Take full `Services` in `BuildHalfEdge` method
hannobraun Apr 26, 2023
d19474c
Take full `Services` in `line_segment`
hannobraun Apr 26, 2023
d362713
Take full `Services` in `BuildHalfEdge::unjoined`
hannobraun Apr 26, 2023
b474500
Take full `Services` in `JoinCycle::join_to`
hannobraun Apr 26, 2023
dcfe94b
Take full `Services` in `Insert::insert`
hannobraun Apr 26, 2023
9e32ee3
Update formatting
hannobraun Apr 26, 2023
8ccc790
Add `Services::insert_object`
hannobraun Apr 26, 2023
4ea1495
Don't store service events
hannobraun Apr 26, 2023
f0b2008
Refactor to prepare for follow-on change
hannobraun Apr 26, 2023
e14393c
Simplify service subscription
hannobraun Apr 26, 2023
36e698d
Simplify storage of validation service
hannobraun Apr 26, 2023
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
22 changes: 8 additions & 14 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,8 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xz_plane();
let half_edge = HalfEdge::line_segment(
[[1., 1.], [2., 1.]],
None,
&mut services.objects,
);
let half_edge =
HalfEdge::line_segment([[1., 1.], [2., 1.]], None, &mut services);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand All @@ -293,12 +290,9 @@ mod tests {
u: GlobalPath::circle_from_radius(1.),
v: [0., 0., 1.].into(),
})
.insert(&mut services.objects);
let half_edge = HalfEdge::line_segment(
[[1., 1.], [2., 1.]],
None,
&mut services.objects,
);
.insert(&mut services);
let half_edge =
HalfEdge::line_segment([[1., 1.], [2., 1.]], None, &mut services);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand All @@ -317,11 +311,11 @@ mod tests {
u: path,
v: [0., 0., 1.].into(),
})
.insert(&mut services.objects);
.insert(&mut services);
let half_edge = HalfEdge::line_segment(
[[0., 1.], [TAU, 1.]],
Some(range.boundary),
&mut services.objects,
&mut services,
);

let tolerance = 1.;
Expand All @@ -346,7 +340,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xz_plane();
let half_edge = HalfEdge::circle(1., &mut services.objects);
let half_edge = HalfEdge::circle(1., &mut services);

let tolerance = 1.;
let approx = (&half_edge, surface.deref()).approx(tolerance);
Expand Down
18 changes: 6 additions & 12 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = HalfEdge::line_segment(
[[1., -1.], [1., 1.]],
None,
&mut services.objects,
);
let half_edge =
HalfEdge::line_segment([[1., -1.], [1., 1.]], None, &mut services);

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

Expand All @@ -107,7 +104,7 @@ mod tests {
let half_edge = HalfEdge::line_segment(
[[-1., -1.], [-1., 1.]],
None,
&mut services.objects,
&mut services,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -128,7 +125,7 @@ mod tests {
let half_edge = HalfEdge::line_segment(
[[-1., -1.], [1., -1.]],
None,
&mut services.objects,
&mut services,
);

let intersection = CurveEdgeIntersection::compute(&curve, &half_edge);
Expand All @@ -141,11 +138,8 @@ mod tests {
let mut services = Services::new();

let curve = Curve::u_axis();
let half_edge = HalfEdge::line_segment(
[[-1., 0.], [1., 0.]],
None,
&mut services.objects,
);
let half_edge =
HalfEdge::line_segment([[-1., 0.], [1., 0.]], None, &mut services);

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

Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
exterior_points,
&mut services.objects,
&mut services,
))
.with_interior(CycleBuilder::polygon(
interior_points,
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);

let expected =
CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]);
Expand Down
14 changes: 4 additions & 10 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,8 @@ mod tests {
]
.map(|surface| {
FaceBuilder::new(surface)
.with_exterior(CycleBuilder::polygon(
points,
&mut services.objects,
))
.build(&mut services.objects)
.with_exterior(CycleBuilder::polygon(points, &mut services))
.build(&mut services)
});

let intersection = FaceFaceIntersection::compute([&a, &b]);
Expand All @@ -115,11 +112,8 @@ mod tests {
];
let [a, b] = surfaces.clone().map(|surface| {
FaceBuilder::new(surface)
.with_exterior(CycleBuilder::polygon(
points,
&mut services.objects,
))
.build(&mut services.objects)
.with_exterior(CycleBuilder::polygon(points, &mut services))
.build(&mut services)
});

let intersection = FaceFaceIntersection::compute([&a, &b]);
Expand Down
32 changes: 16 additions & 16 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [1., 1.], [0., 2.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([2., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -165,9 +165,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [0., 2.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -184,9 +184,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[4., 2.], [0., 4.], [0., 0.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 2.]);

let intersection = (&face, &point).intersect();
Expand All @@ -203,9 +203,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -222,9 +222,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -241,9 +241,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -260,9 +260,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [2., 0.], [0., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 0.]);

let intersection = (&face, &point).intersect();
Expand All @@ -285,9 +285,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[0., 0.], [1., 0.], [0., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);
let point = Point::from([1., 0.]);

let intersection = (&face, &point).intersect();
Expand Down
40 changes: 20 additions & 20 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.yz_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([-1., 0., 0.], &mut services.objects);
.build(&mut services);
let face = face.translate([-1., 0., 0.], &mut services);

assert_eq!((&ray, &face).intersect(), None);
}
Expand All @@ -182,10 +182,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.yz_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([1., 0., 0.], &mut services.objects);
.build(&mut services);
let face = face.translate([1., 0., 0.], &mut services);

assert_eq!(
(&ray, &face).intersect(),
Expand All @@ -202,10 +202,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.yz_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([0., 0., 2.], &mut services.objects);
.build(&mut services);
let face = face.translate([0., 0., 2.], &mut services);

assert_eq!((&ray, &face).intersect(), None);
}
Expand All @@ -219,10 +219,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.yz_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([1., 1., 0.], &mut services.objects);
.build(&mut services);
let face = face.translate([1., 1., 0.], &mut services);

let edge = face
.exterior()
Expand All @@ -244,10 +244,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.yz_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([1., 1., 1.], &mut services.objects);
.build(&mut services);
let face = face.translate([1., 1., 1.], &mut services);

let vertex = face
.exterior()
Expand All @@ -272,9 +272,9 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
.build(&mut services);

assert_eq!(
(&ray, &face).intersect(),
Expand All @@ -291,10 +291,10 @@ mod tests {
let face = FaceBuilder::new(services.objects.surfaces.xy_plane())
.with_exterior(CycleBuilder::polygon(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
&mut services,
))
.build(&mut services.objects);
let face = face.translate([0., 0., 1.], &mut services.objects);
.build(&mut services);
let face = face.translate([0., 0., 1.], &mut services);

assert_eq!((&ray, &face).intersect(), None);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mod tests {
xy.clone(),
xy.clone().transform(
&Transform::translation([0., 0., 1.],),
&mut services.objects
&mut services
)
],),
None,
Expand Down
10 changes: 5 additions & 5 deletions crates/fj-kernel/src/algorithms/reverse/cycle.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use itertools::Itertools;

use crate::{
objects::{Cycle, HalfEdge, Objects},
objects::{Cycle, HalfEdge},
operations::Insert,
services::Service,
services::Services,
storage::Handle,
};

use super::Reverse;

impl Reverse for Handle<Cycle> {
fn reverse(self, objects: &mut Service<Objects>) -> Self {
fn reverse(self, services: &mut Services) -> Self {
let mut edges = self
.half_edges()
.cloned()
Expand All @@ -27,12 +27,12 @@ impl Reverse for Handle<Cycle> {
next.start_vertex().clone(),
current.global_form().clone(),
)
.insert(objects)
.insert(services)
})
.collect::<Vec<_>>();

edges.reverse();

Cycle::new(edges).insert(objects)
Cycle::new(edges).insert(services)
}
}
Loading