Skip to content

Commit

Permalink
Merge pull request #1481 from hannobraun/vertex
Browse files Browse the repository at this point in the history
Remove `Vertex::global_form`
  • Loading branch information
hannobraun authored Jan 5, 2023
2 parents b9a5e2f + 890539a commit f28205f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 20 deletions.
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Approx for &HalfEdge {

let first = ApproxPoint::new(
a.surface_form().position(),
a.global_form().position(),
a.surface_form().global_form().position(),
);
let curve_approx =
(self.curve(), range).approx_with_cache(tolerance, cache);
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/face_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ mod tests {
.half_edges()
.find(|edge| {
let [a, b] = edge.vertices();
a.global_form().position() == Point::from([0., 0., 0.])
&& b.global_form().position() == Point::from([2., 0., 0.])
a.surface_form().position() == Point::from([0., 0.])
&& b.surface_form().position() == Point::from([2., 0.])
})
.unwrap();
assert_eq!(
Expand Down Expand Up @@ -325,7 +325,7 @@ mod tests {
.half_edges()
.flat_map(|half_edge| half_edge.vertices())
.find(|vertex| {
vertex.global_form().position() == Point::from([1., 0., 0.])
vertex.surface_form().position() == Point::from([1., 0.])
})
.unwrap();
assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ mod tests {
.half_edges()
.find(|edge| {
let [a, b] = edge.vertices();
a.global_form().position() == Point::from([1., 0., 1.])
&& b.global_form().position() == Point::from([1., 0., -1.])
a.surface_form().position() == Point::from([-1., 1.])
&& b.surface_form().position() == Point::from([-1., -1.])
})
.unwrap();
assert_eq!(
Expand Down Expand Up @@ -290,7 +290,7 @@ mod tests {
.half_edges()
.flat_map(|half_edge| half_edge.vertices())
.find(|vertex| {
vertex.global_form().position() == Point::from([1., 0., 0.])
vertex.surface_form().position() == Point::from([-1., -1.])
})
.unwrap();
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Sweep for (Handle<HalfEdge>, Color) {
let surface_vertex = SurfaceVertex::new(
point_surface,
surface.clone(),
vertex.global_form().clone(),
vertex.surface_form().global_form().clone(),
)
.insert(objects);

Expand Down
1 change: 1 addition & 0 deletions crates/fj-kernel/src/algorithms/sweep/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Sweep for (Handle<Vertex>, Handle<Surface>) {
// as that is the most straight-forward part of this operations, and
// we're going to need it soon anyway.
let (edge_global, vertices_global) = vertex
.surface_form()
.global_form()
.clone()
.sweep_with_cache(path, cache, objects);
Expand Down
13 changes: 5 additions & 8 deletions crates/fj-kernel/src/objects/full/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ use crate::{

/// A vertex
///
/// `Vertex` is defined in terms of a 1-dimensional position on a curve. If you
/// need the 3D position of a vertex, you can use [`Vertex::global_form`], to
/// get access of the global form of a vertex ([`GlobalVertex`]).
/// `Vertex` is defined in terms of a 1-dimensional position on a curve. Each
/// `Vertex` has an associated [`SurfaceVertex`], which defines the 2D position
/// on the surface, and a [`GlobalVertex`] which defines the global 3D position.
///
/// Both can be accessed through [`Vertex::surface_form`].
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Vertex {
position: Point<1>,
Expand Down Expand Up @@ -47,11 +49,6 @@ impl Vertex {
pub fn surface_form(&self) -> &Handle<SurfaceVertex> {
&self.surface_form
}

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

/// A vertex, defined in surface (2D) coordinates
Expand Down
7 changes: 3 additions & 4 deletions crates/fj-kernel/src/validate/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ impl HalfEdgeValidationError {
let global_vertices_from_vertices = {
let (global_vertices_from_vertices, _) =
VerticesInNormalizedOrder::new(
half_edge
.vertices()
.each_ref_ext()
.map(|vertex| vertex.global_form().clone()),
half_edge.vertices().each_ref_ext().map(|vertex| {
vertex.surface_form().global_form().clone()
}),
);

global_vertices_from_vertices.access_in_normalized_order()
Expand Down

0 comments on commit f28205f

Please sign in to comment.