Skip to content

Commit

Permalink
Merge pull request #2094 from hannobraun/split
Browse files Browse the repository at this point in the history
Return more information from `SplitEdge::split_edge`
  • Loading branch information
hannobraun authored Nov 15, 2023
2 parents bac487b + 65cc9cd commit 0989937
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
28 changes: 17 additions & 11 deletions crates/fj-core/src/operations/split/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
};

/// Split a pair of [`HalfEdge`]s into two
pub trait SplitEdge {
pub trait SplitEdge: Sized {
/// Split the provided [`HalfEdge`], as well as its sibling, into two
///
/// # Panics
Expand All @@ -24,7 +24,7 @@ pub trait SplitEdge {
half_edge: &Handle<HalfEdge>,
point: impl Into<Point<1>>,
services: &mut Services,
) -> Self;
) -> (Self, [[Handle<HalfEdge>; 2]; 2]);
}

impl SplitEdge for Shell {
Expand All @@ -33,7 +33,7 @@ impl SplitEdge for Shell {
half_edge: &Handle<HalfEdge>,
point: impl Into<Point<1>>,
services: &mut Services,
) -> Self {
) -> (Self, [[Handle<HalfEdge>; 2]; 2]) {
let point = point.into();

let sibling = self
Expand All @@ -44,18 +44,24 @@ impl SplitEdge for Shell {
.split_half_edge(point, services)
.map(|half_edge| half_edge.insert(services));

let [sibling_a, sibling_b] = sibling.split_half_edge(point, services);
let sibling_b = sibling_b
.update_start_vertex(|_| half_edge_b.start_vertex().clone());
let siblings = {
let [sibling_a, sibling_b] =
sibling.split_half_edge(point, services);
let sibling_b = sibling_b
.update_start_vertex(|_| half_edge_b.start_vertex().clone());
[sibling_a, sibling_b].map(|half_edge| half_edge.insert(services))
};

self.replace_half_edge(half_edge, [half_edge_a, half_edge_b], services)
.into_inner()
let shell = self
.replace_half_edge(
&sibling,
[sibling_a, sibling_b]
.map(|half_edge| half_edge.insert(services)),
half_edge,
[half_edge_a.clone(), half_edge_b.clone()],
services,
)
.into_inner()
.replace_half_edge(&sibling, siblings.clone(), services)
.into_inner();

(shell, [[half_edge_a, half_edge_b], siblings])
}
}
1 change: 1 addition & 0 deletions models/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn model(
[split_pos],
services,
)
.0
.insert(services)
})
.insert(services)
Expand Down

0 comments on commit 0989937

Please sign in to comment.