Skip to content

Commit

Permalink
Merge pull request #1682 from hannobraun/unify
Browse files Browse the repository at this point in the history
Use `Handle<Cycle>` instead of `Partial<Cycle>` for `PartialFace exterior
  • Loading branch information
hannobraun authored Mar 14, 2023
2 parents bb8069c + 6113534 commit c110b71
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 159 deletions.
28 changes: 20 additions & 8 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ mod tests {
use crate::{
builder::{CycleBuilder, FaceBuilder},
geometry::curve::Curve,
insert::Insert,
partial::{PartialFace, PartialObject},
services::Services,
};
Expand All @@ -165,14 +166,14 @@ mod tests {
let (curve, _) = Curve::line_from_points([[-3., 0.], [-2., 0.]]);

#[rustfmt::skip]
let exterior = [
let exterior_points = [
[-2., -2.],
[ 2., -2.],
[ 2., 2.],
[-2., 2.],
];
#[rustfmt::skip]
let interior = [
let interior_points = [
[-1., -1.],
[-1., 1.],
[ 1., 1.],
Expand All @@ -183,12 +184,23 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior
.write()
.update_as_polygon_from_points(exterior, &mut services.objects);
face.add_interior(&mut services.objects)
.write()
.update_as_polygon_from_points(interior, &mut services.objects);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
exterior_points,
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
{
let mut interior = face.add_interior(&mut services.objects);
let (updated, _) =
interior.read().clone().update_as_polygon_from_points(
interior_points,
&mut services.objects,
);
*interior.write() = updated;
}

face.build(&mut services.objects)
};
Expand Down
23 changes: 17 additions & 6 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ mod tests {
algorithms::intersect::CurveFaceIntersection,
builder::CycleBuilder,
geometry::curve::Curve,
insert::Insert,
partial::{PartialFace, PartialObject},
services::Services,
};
Expand All @@ -89,9 +90,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(surface);
face.exterior
.write()
.update_as_polygon_from_points(points, &mut services.objects);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
points,
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}

face.build(&mut services.objects)
});
Expand Down Expand Up @@ -120,9 +126,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(surface);
face.exterior
.write()
.update_as_polygon_from_points(points, &mut services.objects);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
points,
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}

face.build(&mut services.objects)
});
Expand Down
96 changes: 64 additions & 32 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [1., 1.], [0., 2.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [1., 1.], [0., 2.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -171,10 +175,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [0., 2.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [0., 2.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -194,10 +202,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[4., 2.], [0., 4.], [0., 0.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[4., 2.], [0., 4.], [0., 0.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -217,10 +229,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 0.], [3., 4.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -240,10 +256,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 1.], [0., 2.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -263,10 +283,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [3., 1.], [4., 0.], [4., 5.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -286,10 +310,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 0.], [0., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [2., 0.], [0., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -315,10 +343,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [1., 0.], [0., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[0., 0.], [1., 0.], [0., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand Down
84 changes: 56 additions & 28 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.yz_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand All @@ -187,10 +191,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.yz_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand All @@ -211,10 +219,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.yz_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand All @@ -232,10 +244,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.yz_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand All @@ -261,10 +277,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.yz_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand Down Expand Up @@ -293,10 +313,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -316,10 +340,14 @@ mod tests {
let mut face = PartialFace::new(&mut services.objects);

face.surface = Some(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
{
let (exterior, _) =
face.exterior.clone_object().update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.], [-1., 1.]],
&mut services.objects,
);
face.exterior = exterior.insert(&mut services.objects);
}
let face = face
.build(&mut services.objects)
.insert(&mut services.objects)
Expand Down
Loading

0 comments on commit c110b71

Please sign in to comment.