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. /// This is done recursively.
pub fn merge<T: Object>(&mut self, object: T) -> Handle<T> { 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 /// Merge the provided shape into this one
@ -125,22 +125,22 @@ impl Shape {
/// merged objects in this shape. /// merged objects in this shape.
pub fn merge_shape(&mut self, other: &Shape) { pub fn merge_shape(&mut self, other: &Shape) {
for object in other.curves() { for object in other.curves() {
object.get().merge_into(Some(object), self); object.get().merge_into(self);
} }
for object in other.surfaces() { for object in other.surfaces() {
object.get().merge_into(Some(object), self); object.get().merge_into(self);
} }
for object in other.vertices() { for object in other.vertices() {
object.get().merge_into(Some(object), self); object.get().merge_into(self);
} }
for object in other.edges() { for object in other.edges() {
object.get().merge_into(Some(object), self); object.get().merge_into(self);
} }
for object in other.cycles() { for object in other.cycles() {
object.get().merge_into(Some(object), self); object.get().merge_into(self);
} }
for object in other.faces() { 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 /// Internal function
/// ///
/// Please consider using [`Shape::merge`] instead. /// Please consider using [`Shape::merge`] instead.
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self>;
self,
handle: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self>;
} }
impl private::Sealed for Curve<3> {} impl private::Sealed for Curve<3> {}
@ -25,47 +21,30 @@ impl private::Sealed for Cycle<3> {}
impl private::Sealed for Face {} impl private::Sealed for Face {}
impl Object for Curve<3> { impl Object for Curve<3> {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
shape.get_handle_or_insert(self) shape.get_handle_or_insert(self)
} }
} }
impl Object for Surface { impl Object for Surface {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
shape.get_handle_or_insert(self) shape.get_handle_or_insert(self)
} }
} }
impl Object for Vertex { impl Object for Vertex {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
shape.get_handle_or_insert(Vertex { point: self.point }) shape.get_handle_or_insert(Vertex { point: self.point })
} }
} }
impl Object for Edge<3> { impl Object for Edge<3> {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self, let curve = self.curve().merge_into(shape);
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
let curve =
self.curve().merge_into(Some(self.curve.canonical()), shape);
let vertices = self.vertices.convert(|vertex| { let vertices = self.vertices.convert(|vertex| {
let canonical = vertex.canonical(); 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) LocalForm::new(*vertex.local(), canonical)
}); });
@ -77,15 +56,11 @@ impl Object for Edge<3> {
} }
impl Object for Cycle<3> { impl Object for Cycle<3> {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
let mut edges = Vec::new(); let mut edges = Vec::new();
for edge in self.edges { for edge in self.edges {
let edge = edge.canonical(); let edge = edge.canonical();
let edge = edge.get().merge_into(Some(edge), shape); let edge = edge.get().merge_into(shape);
edges.push(edge); edges.push(edge);
} }
@ -94,31 +69,20 @@ impl Object for Cycle<3> {
} }
impl Object for Face { impl Object for Face {
fn merge_into( fn merge_into(self, shape: &mut Shape) -> Handle<Self> {
self,
_: Option<Handle<Self>>,
shape: &mut Shape,
) -> Handle<Self> {
match self { match self {
Face::Face(face) => { Face::Face(face) => {
let surface = let surface = face.surface.get().merge_into(shape);
face.surface.get().merge_into(Some(face.surface), shape);
let mut exts = Vec::new(); let mut exts = Vec::new();
for cycle in face.exteriors.as_local_form() { for cycle in face.exteriors.as_local_form() {
let merged = cycle let merged = cycle.canonical().get().merge_into(shape);
.canonical()
.get()
.merge_into(Some(cycle.canonical()), shape);
exts.push(LocalForm::new(cycle.local().clone(), merged)); exts.push(LocalForm::new(cycle.local().clone(), merged));
} }
let mut ints = Vec::new(); let mut ints = Vec::new();
for cycle in face.interiors.as_local_form() { for cycle in face.interiors.as_local_form() {
let merged = cycle let merged = cycle.canonical().get().merge_into(shape);
.canonical()
.get()
.merge_into(Some(cycle.canonical()), shape);
ints.push(LocalForm::new(cycle.local().clone(), merged)); ints.push(LocalForm::new(cycle.local().clone(), merged));
} }