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

Return references to objects, where appropriate #858

Merged
merged 6 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 7 additions & 5 deletions crates/fj-kernel/src/algorithms/approx/cycles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ impl CycleApprox {

for edge in &cycle.edges {
let mut edge_points = Vec::new();
approx_curve(&edge.curve().global(), tolerance, &mut edge_points);
approx_curve(edge.curve().global(), tolerance, &mut edge_points);
approx_edge(*edge.vertices(), &mut edge_points);

points.extend(edge_points.into_iter().map(|point| {
let local =
edge.curve().local().point_from_curve_coords(point.local());
Local::new(local, point.global())
let local = edge
.curve()
.local()
.point_from_curve_coords(*point.local());
Local::new(local, *point.global())
}));
}

Expand All @@ -47,7 +49,7 @@ impl CycleApprox {
// up, once `array_windows` is stable.
let segment = [segment[0], segment[1]];

segments.push(Segment::from(segment.map(|point| point.global())));
segments.push(Segment::from(segment.map(|point| *point.global())));
}

segments
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/intersection/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl CurveFaceIntersectionList {
.exteriors()
.chain(face.interiors())
.flat_map(|cycle| {
let edges: Vec<_> = cycle.edges().collect();
let edges: Vec<_> = cycle.edges().cloned().collect();
edges
})
.map(|edge| {
Expand All @@ -55,7 +55,7 @@ impl CurveFaceIntersectionList {
),
};

(line, vertices)
(*line, vertices)
});

let mut intersections = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn reverse_local_coordinates_in_cycle<'r>(
}
};

Local::new(local, edge.curve().global())
Local::new(local, *edge.curve().global())
};

Edge::new(curve, *edge.vertices())
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn sweep(

for face in source.face_iter() {
create_bottom_faces(
&face,
face,
is_sweep_along_negative_direction,
&mut target,
);
Expand All @@ -44,7 +44,7 @@ pub fn sweep(
create_non_continuous_side_face(
path,
is_sweep_along_negative_direction,
vertices.map(|vertex| vertex.global()),
vertices.map(|vertex| *vertex.global()),
color,
&mut target,
);
Expand Down Expand Up @@ -314,7 +314,7 @@ mod tests {
});

for face in faces {
assert!(solid.face_iter().any(|f| f == face));
assert!(solid.face_iter().any(|f| f == &face));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl TransformObject for Cycle {
impl TransformObject for Edge {
fn transform(self, transform: &Transform) -> Self {
let curve = Local::new(
self.curve().local(),
*self.curve().local(),
self.curve().global().transform(transform),
);

Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/triangulate/delaunay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn triangulate(points: Vec<Local<Point<2>>>) -> Vec<[Local<Point<2>>; 3]> {
for triangle in triangulation.inner_faces() {
let [v0, v1, v2] = triangle.vertices().map(|vertex| *vertex.data());
let orientation =
Triangle::<2>::from_points([v0.local(), v1.local(), v2.local()])
Triangle::<2>::from_points([*v0.local(), *v1.local(), *v2.local()])
.winding_direction();

let triangle = match orientation {
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/triangulate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ pub fn triangulate(
.exterior
.points
.into_iter()
.map(|point| point.local()),
.map(|point| *point.local()),
)
.with_interiors(approx.interiors.into_iter().map(|interior| {
interior.points.into_iter().map(|point| point.local())
interior.points.into_iter().map(|point| *point.local())
}));

let mut triangles = delaunay::triangulate(points);
triangles.retain(|triangle| {
face_as_polygon.contains_triangle(
triangle.map(|point| point.local()),
triangle.map(|point| *point.local()),
debug_info,
)
});

for triangle in triangles {
let points = triangle.map(|point| point.global());
let points = triangle.map(|point| *point.global());
mesh.push_triangle(points, face.color());
}
}
Expand Down
Loading