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

Simplify Vertex #1178

Merged
merged 6 commits into from
Oct 7, 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
14 changes: 4 additions & 10 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl Sweep for (HalfEdge, Color) {
vertex.position(),
curve.clone(),
surface_vertex,
*vertex.global_form(),
)
})
};
Expand Down Expand Up @@ -134,18 +133,13 @@ impl Sweep for (HalfEdge, Color) {
(b_vertex, b_surface, b_global),
];

vertices.map(|(vertex, point_surface, vertex_global)| {
let vertex_surface = SurfaceVertex::new(
vertices.map(|(vertex, point_surface, global_form)| {
let surface_form = SurfaceVertex::new(
point_surface,
surface.clone(),
vertex_global,
global_form,
);
Vertex::new(
vertex.position(),
curve.clone(),
vertex_surface,
vertex_global,
)
Vertex::new(vertex.position(), curve.clone(), surface_form)
})
};

Expand Down
13 changes: 3 additions & 10 deletions crates/fj-kernel/src/algorithms/sweep/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,11 @@ impl Sweep for (Vertex, Handle<Surface>) {
},
);

// Can be cleaned up, once `zip` is stable:
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
let [a_surface, b_surface] = vertices_surface;
let [a_global, b_global] = vertices_global;
let vertices = [(a_surface, a_global), (b_surface, b_global)];

vertices.map(|(vertex_surface, vertex_global)| {
vertices_surface.map(|surface_form| {
Vertex::new(
[vertex_surface.position().v],
[surface_form.position().v],
curve.clone(),
vertex_surface,
vertex_global,
surface_form,
)
})
};
Expand Down
9 changes: 2 additions & 7 deletions crates/fj-kernel/src/algorithms/validate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,9 @@ mod tests {
Point::from([Scalar::ZERO + deviation]),
curve.clone(),
a_surface,
a_global,
);
let b = Vertex::new(
Point::from([Scalar::ONE]),
curve.clone(),
b_surface,
b_global,
);
let b =
Vertex::new(Point::from([Scalar::ONE]), curve.clone(), b_surface);
let vertices = [a, b];

let global_edge = GlobalEdge::partial()
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ mod tests {
let global_vertex = GlobalVertex::from_position([0., 0., 0.]);
let surface_vertex =
SurfaceVertex::new([0., 0.], surface, global_vertex);
let object = Vertex::new([0.], curve, surface_vertex, global_vertex);
let object = Vertex::new([0.], curve, surface_vertex);

assert_eq!(1, object.curve_iter().count());
assert_eq!(0, object.cycle_iter().count());
Expand Down
10 changes: 1 addition & 9 deletions crates/fj-kernel/src/objects/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub struct Vertex {
position: Point<1>,
curve: Handle<Curve>,
surface_form: SurfaceVertex,
global_form: GlobalVertex,
}

impl Vertex {
Expand All @@ -27,7 +26,6 @@ impl Vertex {
position: impl Into<Point<1>>,
curve: Handle<Curve>,
surface_form: SurfaceVertex,
global_form: GlobalVertex,
) -> Self {
let position = position.into();

Expand All @@ -36,17 +34,11 @@ impl Vertex {
surface_form.surface().id(),
"Surface form of vertex must be defined on same surface as curve",
);
assert_eq!(
surface_form.global_form(),
&global_form,
"Vertex and its surface form must have same global form",
);

Self {
position,
curve,
surface_form,
global_form,
}
}

Expand All @@ -67,7 +59,7 @@ impl Vertex {

/// Access the global form of this vertex
pub fn global_form(&self) -> &GlobalVertex {
&self.global_form
self.surface_form.global_form()
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/fj-kernel/src/partial/objects/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ impl PartialVertex {
})
.into_full(stores);

let global_form = *surface_form.global_form();

Vertex::new(position, curve, surface_form, global_form)
Vertex::new(position, curve, surface_form)
}
}

Expand Down