Skip to content

Commit

Permalink
Prepare code for follow-on change
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 1, 2023
1 parent 6c4f02f commit 3fd82aa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ impl Sweep for (Handle<HalfEdge>, &Handle<SurfaceVertex>, &Surface, Color) {
.into_iter()
.circular_tuple_windows()
{
edge.write()
.update_as_line_segment(next.read().start_vertex.clone());
edge.write().update_as_line_segment(next.clone());
}

// Finally, we can make sure that all edges refer to the correct global
Expand Down
4 changes: 1 addition & 3 deletions crates/fj-kernel/src/builder/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ impl CycleBuilder for PartialCycle {
for (mut half_edge, next) in
self.half_edges.iter().cloned().circular_tuple_windows()
{
half_edge
.write()
.update_as_line_segment(next.read().start_vertex.clone());
half_edge.write().update_as_line_segment(next.clone());
}
}

Expand Down
20 changes: 11 additions & 9 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait HalfEdgeBuilder {
/// Update partial half-edge to be a line segment
fn update_as_line_segment(
&mut self,
next_vertex: Partial<SurfaceVertex>,
next_half_edge: Partial<HalfEdge>,
) -> Curve;

/// Infer the global form of the half-edge
Expand Down Expand Up @@ -138,15 +138,17 @@ impl HalfEdgeBuilder for PartialHalfEdge {

fn update_as_line_segment(
&mut self,
next_vertex: Partial<SurfaceVertex>,
next_half_edge: Partial<HalfEdge>,
) -> Curve {
let boundary = self.boundary;
let points_surface = [&self.start_vertex, &next_vertex].map(|vertex| {
vertex
.read()
.position
.expect("Can't infer line segment without surface position")
});
let points_surface =
[&self.start_vertex, &next_half_edge.read().start_vertex].map(
|vertex| {
vertex.read().position.expect(
"Can't infer line segment without surface position",
)
},
);

let path = if let [Some(start), Some(end)] = boundary {
let points = [start, end].zip_ext(points_surface);
Expand All @@ -168,7 +170,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
path
};

self.infer_global_form(next_vertex);
self.infer_global_form(next_half_edge.read().start_vertex.clone());

path
}
Expand Down
5 changes: 1 addition & 4 deletions crates/fj-operations/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@ impl Shape for fj::Sketch {
for ((mut half_edge, route), (next_half_edge, _)) in
half_edges.into_iter().circular_tuple_windows()
{
let next_vertex =
next_half_edge.read().start_vertex.clone();

match route {
fj::SketchSegmentRoute::Direct => {
half_edge
.write()
.update_as_line_segment(next_vertex);
.update_as_line_segment(next_half_edge);
}
fj::SketchSegmentRoute::Arc { angle } => {
half_edge
Expand Down

0 comments on commit 3fd82aa

Please sign in to comment.