Skip to content

Commit

Permalink
Merge pull request #2205 from hannobraun/update
Browse files Browse the repository at this point in the history
Make `update_*` methods of `update` operation more convenient to call
  • Loading branch information
hannobraun authored Feb 12, 2024
2 parents 5d31f95 + e7a6143 commit 1b2d9d6
Show file tree
Hide file tree
Showing 26 changed files with 899 additions and 642 deletions.
28 changes: 15 additions & 13 deletions crates/fj-core/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,21 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(exterior_points, &mut core)
.insert(&mut core.services)
})
.add_interiors([Cycle::polygon(
interior_points,
&mut core,
)
.insert(&mut core.services)])
.insert(&mut core.services)
});
.update_region(
|region, core| {
region
.update_exterior(
|_, core| Cycle::polygon(exterior_points, core),
core,
)
.add_interiors([Cycle::polygon(
interior_points,
core,
)
.insert(&mut core.services)])
},
&mut core,
);

let expected =
CurveFaceIntersection::from_intervals([[[1.], [2.]], [[4.], [5.]]]);
Expand Down
35 changes: 18 additions & 17 deletions crates/fj-core/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ mod tests {
objects::{Cycle, Face},
operations::{
build::{BuildCycle, BuildFace},
insert::Insert,
update::{UpdateFace, UpdateRegion},
},
Instance,
Expand All @@ -90,14 +89,15 @@ mod tests {
core.services.objects.surfaces.xz_plane(),
]
.map(|surface| {
Face::unbound(surface, &mut core).update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(points, &mut core)
.insert(&mut core.services)
})
.insert(&mut core.services)
})
Face::unbound(surface, &mut core).update_region(
|region, core| {
region.update_exterior(
|_, core| Cycle::polygon(points, core),
core,
)
},
&mut core,
)
});

let intersection = FaceFaceIntersection::compute([&a, &b]);
Expand All @@ -120,14 +120,15 @@ mod tests {
core.services.objects.surfaces.xz_plane(),
];
let [a, b] = surfaces.clone().map(|surface| {
Face::unbound(surface, &mut core).update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(points, &mut core)
.insert(&mut core.services)
})
.insert(&mut core.services)
})
Face::unbound(surface, &mut core).update_region(
|region, core| {
region.update_exterior(
|_, core| Cycle::polygon(points, core),
core,
)
},
&mut core,
)
});

let intersection = FaceFaceIntersection::compute([&a, &b]);
Expand Down
213 changes: 118 additions & 95 deletions crates/fj-core/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ mod tests {
objects::{Cycle, Face},
operations::{
build::{BuildCycle, BuildFace},
insert::Insert,
update::{UpdateFace, UpdateRegion},
},
Instance,
Expand All @@ -150,17 +149,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [1., 1.], [0., 2.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [1., 1.], [0., 2.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([2., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -173,17 +175,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [2., 1.], [0., 2.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [2., 1.], [0., 2.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -199,17 +204,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[4., 2.], [0., 4.], [0., 0.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[4., 2.], [0., 4.], [0., 0.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 2.]);

let intersection = (&face, &point).intersect();
Expand All @@ -225,17 +233,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -251,17 +262,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -277,23 +291,26 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[
[0., 0.],
[2., 1.],
[3., 1.],
[4., 0.],
[4., 5.],
],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[
[0., 0.],
[2., 1.],
[3., 1.],
[4., 0.],
[4., 5.],
],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 1.]);

let intersection = (&face, &point).intersect();
Expand All @@ -309,17 +326,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [2., 0.], [0., 1.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [2., 0.], [0., 1.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 0.]);

let intersection = (&face, &point).intersect();
Expand All @@ -343,17 +363,20 @@ mod tests {

let face =
Face::unbound(core.services.objects.surfaces.xy_plane(), &mut core)
.update_region(|region| {
region
.update_exterior(|_| {
Cycle::polygon(
[[0., 0.], [1., 0.], [0., 1.]],
&mut core,
)
.insert(&mut core.services)
})
.insert(&mut core.services)
});
.update_region(
|region, core| {
region.update_exterior(
|_, core| {
Cycle::polygon(
[[0., 0.], [1., 0.], [0., 1.]],
core,
)
},
core,
)
},
&mut core,
);
let point = Point::from([1., 0.]);

let intersection = (&face, &point).intersect();
Expand Down
Loading

0 comments on commit 1b2d9d6

Please sign in to comment.