Skip to content

Commit

Permalink
Make builder method argument more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Mar 2, 2023
1 parent 7e5d58c commit 7bd721d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
11 changes: 8 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ impl Sweep for (Handle<HalfEdge>, &Handle<GlobalVertex>, &Surface, Color) {
.circular_tuple_windows()
{
half_edge.write().update_as_line_segment(start, end);
half_edge
.write()
.infer_global_form(next_half_edge.read().start_vertex.clone());
half_edge.write().infer_global_form(
next_half_edge
.read()
.start_vertex
.read()
.global_form
.clone(),
);
}

// Finally, we can make sure that all edges refer to the correct global
Expand Down
10 changes: 7 additions & 3 deletions crates/fj-kernel/src/builder/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ impl CycleBuilder for PartialCycle {

{
let shared_surface_vertex =
new_half_edge.read().start_vertex.clone();
new_half_edge.read().start_vertex.read().global_form.clone();
last_half_edge
.write()
.infer_global_form(shared_surface_vertex);
}

{
let shared_surface_vertex =
first_half_edge.read().start_vertex.clone();
let shared_surface_vertex = first_half_edge
.read()
.start_vertex
.read()
.global_form
.clone();
new_half_edge
.write()
.infer_global_form(shared_surface_vertex);
Expand Down
13 changes: 7 additions & 6 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
curve::{Curve, GlobalPath},
surface::SurfaceGeometry,
},
objects::{GlobalEdge, GlobalVertex, HalfEdge, SurfaceVertex},
objects::{GlobalEdge, GlobalVertex, HalfEdge},
partial::{MaybeCurve, Partial, PartialGlobalEdge, PartialHalfEdge},
};

Expand Down Expand Up @@ -44,7 +44,7 @@ pub trait HalfEdgeBuilder {
/// it.
fn infer_global_form(
&mut self,
next_vertex: Partial<SurfaceVertex>,
next_vertex: Partial<GlobalVertex>,
) -> Partial<GlobalEdge>;

/// Infer the vertex positions (surface and global), if not already set
Expand Down Expand Up @@ -88,7 +88,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
*point_boundary = Some(point_curve);
}

let next_vertex = self.start_vertex.clone();
let next_vertex = self.start_vertex.read().global_form.clone();
self.infer_global_form(next_vertex);

path
Expand Down Expand Up @@ -153,10 +153,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {

fn infer_global_form(
&mut self,
next_vertex: Partial<SurfaceVertex>,
next_vertex: Partial<GlobalVertex>,
) -> Partial<GlobalEdge> {
self.global_form.write().vertices = [&self.start_vertex, &next_vertex]
.map(|vertex| vertex.read().global_form.clone());
self.global_form.write().vertices =
[&self.start_vertex.read().global_form, &next_vertex]
.map(|vertex| vertex.clone());

self.global_form.clone()
}
Expand Down

0 comments on commit 7bd721d

Please sign in to comment.