Remove unused trait method argument

This commit is contained in:
Hanno Braun 2022-06-28 14:27:41 +02:00
parent 763e1ee8d8
commit 45877ee802
2 changed files with 20 additions and 56 deletions

View File

@ -116,7 +116,7 @@ impl Shape {
///
/// This is done recursively.
pub fn merge<T: Object>(&mut self, object: T) -> Handle<T> {
object.merge_into(None, self)
object.merge_into(self)
}
/// Merge the provided shape into this one
@ -125,22 +125,22 @@ impl Shape {
/// merged objects in this shape.
pub fn merge_shape(&mut self, other: &Shape) {
for object in other.curves() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
for object in other.surfaces() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
for object in other.vertices() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
for object in other.edges() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
for object in other.cycles() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
for object in other.faces() {
object.get().merge_into(Some(object), self);
object.get().merge_into(self);
}
}

View File

@ -9,11 +9,7 @@ pub trait Object: 'static + Clone + PartialEq + private::Sealed {
/// Internal function
///
/// Please consider using [`Shape::merge`] instead.
fn merge_into(
self,
handle: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self>;
fn merge_into(self, shape: &mut Shape) -> Handle<Self>;
}
impl private::Sealed for Curve<3> {}
@ -25,47 +21,30 @@ impl private::Sealed for Cycle<3> {}
impl private::Sealed for Face {}
impl Object for Curve<3> {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
shape.get_handle_or_insert(self)
}
}
impl Object for Surface {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
shape.get_handle_or_insert(self)
}
}
impl Object for Vertex {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
shape.get_handle_or_insert(Vertex { point: self.point })
}
}
impl Object for Edge<3> {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
let curve =
self.curve().merge_into(Some(self.curve.canonical()), shape);
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
let curve = self.curve().merge_into(shape);
let vertices = self.vertices.convert(|vertex| {
let canonical = vertex.canonical();
let canonical = canonical.get().merge_into(Some(canonical), shape);
let canonical = canonical.get().merge_into(shape);
LocalForm::new(*vertex.local(), canonical)
});
@ -77,15 +56,11 @@ impl Object for Edge<3> {
}
impl Object for Cycle<3> {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
let mut edges = Vec::new();
for edge in self.edges {
let edge = edge.canonical();
let edge = edge.get().merge_into(Some(edge), shape);
let edge = edge.get().merge_into(shape);
edges.push(edge);
}
@ -94,31 +69,20 @@ impl Object for Cycle<3> {
}
impl Object for Face {
fn merge_into(
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
match self {
Face::Face(face) => {
let surface =
face.surface.get().merge_into(Some(face.surface), shape);
let surface = face.surface.get().merge_into(shape);
let mut exts = Vec::new();
for cycle in face.exteriors.as_local_form() {
let merged = cycle
.canonical()
.get()
.merge_into(Some(cycle.canonical()), shape);
let merged = cycle.canonical().get().merge_into(shape);
exts.push(LocalForm::new(cycle.local().clone(), merged));
}
let mut ints = Vec::new();
for cycle in face.interiors.as_local_form() {
let merged = cycle
.canonical()
.get()
.merge_into(Some(cycle.canonical()), shape);
let merged = cycle.canonical().get().merge_into(shape);
ints.push(LocalForm::new(cycle.local().clone(), merged));
}