Skip to content

Commit

Permalink
Remove redundant constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jun 14, 2022
1 parent a723d38 commit a4c6a71
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
22 changes: 12 additions & 10 deletions crates/fj-kernel/src/shape/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ mod tests {
assert!(shape.get_handle(&surface.get()).as_ref() == Some(&surface));

let vertex = Vertex { point };
let edge =
Edge::new(LocalForm::canonical_only(curve), VerticesOfEdge::none());
let edge = Edge {
curve: LocalForm::canonical_only(curve),
vertices: VerticesOfEdge::none(),
};

assert!(shape.get_handle(&vertex).is_none());
assert!(shape.get_handle(&edge).is_none());
Expand Down Expand Up @@ -376,10 +378,10 @@ mod tests {

// Shouldn't work. Nothing has been added to `shape`.
let err = shape
.insert(Edge::new(
LocalForm::canonical_only(curve.clone()),
VerticesOfEdge::from_vertices([a.clone(), b.clone()]),
))
.insert(Edge {
curve: LocalForm::canonical_only(curve.clone()),
vertices: VerticesOfEdge::from_vertices([a.clone(), b.clone()]),
})
.unwrap_err();
assert!(err.missing_curve(&curve));
assert!(err.missing_vertex(&a.canonical()));
Expand All @@ -393,10 +395,10 @@ mod tests {
let b = LocalForm::new(Point::from([2.]), b);

// Everything has been added to `shape` now. Should work!
shape.insert(Edge::new(
LocalForm::canonical_only(curve),
VerticesOfEdge::from_vertices([a, b]),
))?;
shape.insert(Edge {
curve: LocalForm::canonical_only(curve),
vertices: VerticesOfEdge::from_vertices([a, b]),
})?;

Ok(())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/shape/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ impl Object for Edge<3> {
Ok(LocalForm::new(*vertex.local(), canonical))
})?;

let merged = shape.get_handle_or_insert(Edge::new(
LocalForm::canonical_only(curve),
VerticesOfEdge::new(vertices),
))?;
let merged = shape.get_handle_or_insert(Edge {
curve: LocalForm::canonical_only(curve),
vertices: VerticesOfEdge::new(vertices),
})?;

if let Some(handle) = handle {
mapping.edges.insert(handle, merged.clone());
Expand Down
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/topology/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ impl<'r> EdgeBuilder<'r> {
curve: LocalForm::new(curve_local, curve_canonical.clone()),
vertices: VerticesOfEdge::none(),
};
let edge_canonical = self.shape.insert(Edge::new(
LocalForm::canonical_only(curve_canonical),
VerticesOfEdge::none(),
))?;
let edge_canonical = self.shape.insert(Edge {
curve: LocalForm::canonical_only(curve_canonical),
vertices: VerticesOfEdge::none(),
})?;

Ok(LocalForm::new(edge_local, edge_canonical))
}
Expand Down Expand Up @@ -109,10 +109,10 @@ impl<'r> EdgeBuilder<'r> {
LocalForm::new(Point::from([1.]), b),
];

let edge = self.shape.insert(Edge::new(
LocalForm::canonical_only(curve),
VerticesOfEdge::from_vertices(vertices),
))?;
let edge = self.shape.insert(Edge {
curve: LocalForm::canonical_only(curve),
vertices: VerticesOfEdge::from_vertices(vertices),
})?;

Ok(edge)
}
Expand Down
8 changes: 0 additions & 8 deletions crates/fj-kernel/src/topology/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ pub struct Edge<const D: usize> {
}

impl<const D: usize> Edge<D> {
/// Construct an instance of `Edge`
pub fn new(
curve: LocalForm<Curve<D>, Curve<3>>,
vertices: VerticesOfEdge,
) -> Self {
Self { curve, vertices }
}

/// Access the curve that the edge refers to
///
/// This is a convenience method that saves the caller from dealing with the
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-operations/src/difference_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ fn add_cycle(
curve: LocalForm::new(curve_local, curve_canonical.clone()),
vertices: vertices.clone(),
};
let edge_canonical = shape.merge(Edge::new(
LocalForm::canonical_only(curve_canonical),
let edge_canonical = shape.merge(Edge {
curve: LocalForm::canonical_only(curve_canonical),
vertices,
))?;
})?;

edges.push(LocalForm::new(edge_local, edge_canonical));
}
Expand Down

0 comments on commit a4c6a71

Please sign in to comment.