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

Unify GlobalEdge and PartialGlobalEdge #1645

Merged
merged 37 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fe78f72
Add `PartialObject::new`
hannobraun Mar 3, 2023
33c1b52
Make use `PartialObject::new`
hannobraun Mar 3, 2023
7a6a5ee
Remove unused trait bound
hannobraun Mar 3, 2023
613f64d
Replace uses of `PartialCycle::default`
hannobraun Mar 3, 2023
e2725c6
Un-derive `Default` from `PartialCycle`
hannobraun Mar 3, 2023
ad6561d
Move `PartialHalfEdge` construction code to `new`
hannobraun Mar 3, 2023
f8e8f80
Replace uses of `PartialHalfEdge::default`
hannobraun Mar 3, 2023
8e18d59
Remove `Default` impl of `PartialHalfEdge`
hannobraun Mar 3, 2023
01a2b60
Simplify `PartialGlobalEdge` constructor
hannobraun Mar 3, 2023
13a36c1
Un-derive `Default` from `PartialGlobalEdge`
hannobraun Mar 3, 2023
591c1a6
Avoid using `Default` impl of `PartialFace`
hannobraun Mar 3, 2023
969a396
Un-derive `Default` from `PartialFace`
hannobraun Mar 3, 2023
2792bdd
Avoid using `Default` impl of `PartialShell`
hannobraun Mar 3, 2023
933f559
Un-derive `Default` from `PartialShell`
hannobraun Mar 3, 2023
d433261
Avoid using `Default` impl of `PartialSketch`
hannobraun Mar 3, 2023
1e349d6
Un-derive `Default` from `PartialSketch`
hannobraun Mar 3, 2023
78d8b3c
Avoid using `Default` impl of `PartialSolid`
hannobraun Mar 3, 2023
793af9c
Un-derive `Default` from `PartialSolid`
hannobraun Mar 3, 2023
7253b6c
Avoid using `Default` impl of `PartialSurface`
hannobraun Mar 3, 2023
25bac88
Un-derive `Default` from `PartialSurface`
hannobraun Mar 3, 2023
8a386d3
Avoid using `Default` impl of `PartialVertex`
hannobraun Mar 3, 2023
7651a63
Un-derive `Default` from `PartialVertex`
hannobraun Mar 3, 2023
6c0c491
Avoid using `Default` impl of `Partial`
hannobraun Mar 3, 2023
66bb2f2
Remove `Default` implementation of `Partial`
hannobraun Mar 3, 2023
857c36f
Clean up `PartialFace` construction
hannobraun Mar 3, 2023
30da534
Make object service available in builder method
hannobraun Mar 3, 2023
ce9f27b
Make object service available in builder method
hannobraun Mar 3, 2023
90e2619
Make object service available in builder method
hannobraun Mar 3, 2023
9f7a58a
Make object service available in builder method
hannobraun Mar 3, 2023
1f6c5c2
Clean up `PartialFace` construction
hannobraun Mar 3, 2023
a137c2b
Require objects in partial object constructors
hannobraun Mar 3, 2023
2114d8c
Use `GlobalEdge` in `PartialHalfEdge`
hannobraun Mar 3, 2023
85ec189
Inline variables
hannobraun Mar 3, 2023
a04d7ee
Inline variable
hannobraun Mar 3, 2023
95ba176
Remove `GlobalEdgeBuilder`
hannobraun Mar 3, 2023
566c3d3
Remove `PartialGlobalEdge`
hannobraun Mar 3, 2023
d8b3d70
Remove unused `allow`
hannobraun Mar 3, 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
23 changes: 16 additions & 7 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,13 @@ mod tests {

let surface = services.objects.surfaces.xz_plane();
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]);
.update_as_polygon_from_points(
[[1., 1.], [2., 1.], [1., 2.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand Down Expand Up @@ -278,10 +281,13 @@ mod tests {
.build(&mut services.objects)
.insert(&mut services.objects);
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([[1., 1.], [2., 1.], [1., 2.]]);
.update_as_polygon_from_points(
[[1., 1.], [2., 1.], [1., 2.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand Down Expand Up @@ -310,10 +316,13 @@ mod tests {
.build(&mut services.objects)
.insert(&mut services.objects);
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([[0., 1.], [1., 1.], [1., 2.]]);
.update_as_polygon_from_points(
[[0., 1.], [1., 1.], [1., 2.]],
&mut services.objects,
);

half_edge.write().boundary[0] = Some(range.boundary[0]);
half_edge.write().boundary[1] = Some(range.boundary[1]);
Expand Down Expand Up @@ -352,7 +361,7 @@ mod tests {

let surface = services.objects.surfaces.xz_plane();
let half_edge = {
let mut half_edge = PartialHalfEdge::default();
let mut half_edge = PartialHalfEdge::new(&mut services.objects);

half_edge.update_as_circle_from_radius(1.);
let next_vertex = half_edge.start_vertex.clone();
Expand Down
38 changes: 21 additions & 17 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ mod tests {
use crate::{
builder::{CycleBuilder, HalfEdgeBuilder},
geometry::curve::Curve,
partial::PartialCycle,
partial::{PartialCycle, PartialObject},
services::Services,
};

Expand All @@ -87,10 +87,13 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([[1., -1.], [1., 1.], [0., 1.]]);
.update_as_polygon_from_points(
[[1., -1.], [1., 1.], [0., 1.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand All @@ -116,14 +119,13 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([
[-1., -1.],
[-1., 1.],
[0., 1.],
]);
.update_as_polygon_from_points(
[[-1., -1.], [-1., 1.], [0., 1.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand All @@ -149,14 +151,13 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([
[-1., -1.],
[1., -1.],
[1., 1.],
]);
.update_as_polygon_from_points(
[[-1., -1.], [1., -1.], [1., 1.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand All @@ -177,10 +178,13 @@ mod tests {
let surface = services.objects.surfaces.xy_plane();
let curve = Curve::u_axis();
let half_edge = {
let mut cycle = PartialCycle::default();
let mut cycle = PartialCycle::new(&mut services.objects);

let [mut half_edge, next_half_edge, _] = cycle
.update_as_polygon_from_points([[-1., 0.], [1., 0.], [1., 1.]]);
.update_as_polygon_from_points(
[[-1., 0.], [1., 0.], [1., 1.]],
&mut services.objects,
);
half_edge.write().infer_vertex_positions_if_necessary(
&surface.geometry(),
next_half_edge.read().start_vertex.clone(),
Expand Down
13 changes: 6 additions & 7 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,15 @@ mod tests {
];

let face = {
let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior
.write()
.update_as_polygon_from_points(exterior);
face.add_interior()
.update_as_polygon_from_points(exterior, &mut services.objects);
face.add_interior(&mut services.objects)
.write()
.update_as_polygon_from_points(interior);
.update_as_polygon_from_points(interior, &mut services.objects);

face.build(&mut services.objects)
};
Expand Down
22 changes: 12 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,12 @@ mod tests {
services.objects.surfaces.xz_plane(),
]
.map(|surface| {
let mut face = PartialFace {
surface: Partial::from(surface),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points(points);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(surface);
face.exterior
.write()
.update_as_polygon_from_points(points, &mut services.objects);

face.build(&mut services.objects)
});
Expand All @@ -116,11 +117,12 @@ mod tests {
services.objects.surfaces.xz_plane(),
];
let [a, b] = surfaces.clone().map(|surface| {
let mut face = PartialFace {
surface: Partial::from(surface),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points(points);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(surface);
face.exterior
.write()
.update_as_polygon_from_points(points, &mut services.objects);

face.build(&mut services.objects)
});
Expand Down
132 changes: 56 additions & 76 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,13 @@ mod tests {
fn point_is_outside_face() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[1., 1.],
[0., 2.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [1., 1.], [0., 2.]],
&mut services.objects,
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -170,15 +168,13 @@ mod tests {
fn ray_hits_vertex_while_passing_outside() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[2., 1.],
[0., 2.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 1.], [0., 2.]],
&mut services.objects,
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -195,15 +191,13 @@ mod tests {
fn ray_hits_vertex_at_cycle_seam() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[4., 2.],
[0., 4.],
[0., 0.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[4., 2.], [0., 4.], [0., 0.]],
&mut services.objects,
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -220,16 +214,13 @@ mod tests {
fn ray_hits_vertex_while_staying_inside() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 0.],
[3., 4.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(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 face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -246,16 +237,13 @@ mod tests {
fn ray_hits_parallel_edge_and_leaves_face_at_vertex() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 1.],
[0., 2.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(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 face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -272,17 +260,13 @@ mod tests {
fn ray_hits_parallel_edge_and_does_not_leave_face_there() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[2., 1.],
[3., 1.],
[4., 0.],
[4., 5.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(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 face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -299,15 +283,13 @@ mod tests {
fn point_is_coincident_with_edge() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[2., 0.],
[0., 1.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [2., 0.], [0., 1.]],
&mut services.objects,
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand All @@ -330,15 +312,13 @@ mod tests {
fn point_is_coincident_with_vertex() {
let mut services = Services::new();

let mut face = PartialFace {
surface: Partial::from(services.objects.surfaces.xy_plane()),
..Default::default()
};
face.exterior.write().update_as_polygon_from_points([
[0., 0.],
[1., 0.],
[0., 1.],
]);
let mut face = PartialFace::new(&mut services.objects);

face.surface = Partial::from(services.objects.surfaces.xy_plane());
face.exterior.write().update_as_polygon_from_points(
[[0., 0.], [1., 0.], [0., 1.]],
&mut services.objects,
);
let face = face
.build(&mut services.objects)
.insert(&mut services.objects);
Expand Down
Loading