Skip to content

Commit

Permalink
Merge pull request #2115 from hannobraun/split
Browse files Browse the repository at this point in the history
Return more information from `SplitFace::split_face`
  • Loading branch information
hannobraun authored Nov 28, 2023
2 parents d83fa6f + 21fbc2b commit 83691f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions crates/fj-core/src/operations/split/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
};

/// Split a face into two
pub trait SplitFace {
pub trait SplitFace: Sized {
/// Split the face into two
///
/// The line that splits the face is defined by two points, each specified
Expand All @@ -40,7 +40,7 @@ pub trait SplitFace {
face: &Handle<Face>,
line: [(&Handle<HalfEdge>, impl Into<Point<1>>); 2],
services: &mut Services,
) -> Self;
) -> (Self, [Handle<Face>; 2]);
}

impl SplitFace for Shell {
Expand All @@ -49,7 +49,7 @@ impl SplitFace for Shell {
face: &Handle<Face>,
line: [(&Handle<HalfEdge>, impl Into<Point<1>>); 2],
services: &mut Services,
) -> Self {
) -> (Self, [Handle<Face>; 2]) {
// The code below might assume that the half-edges that define the line
// are part of the face's exterior. Let's make that explicit here.
//
Expand Down Expand Up @@ -163,8 +163,10 @@ impl SplitFace for Shell {
})
.insert(services);

self_.replace_face(updated_face_after_split_edges, |_| {
[split_face_a, split_face_b]
})
let faces = [split_face_a, split_face_b];
let self_ = self_
.replace_face(updated_face_after_split_edges, |_| faces.clone());

(self_, faces)
}
}
2 changes: 1 addition & 1 deletion models/split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn model(
(cycle.half_edges().nth(2).unwrap(), [split_pos]),
];

shell.split_face(face, line, services).insert(services)
shell.split_face(face, line, services).0.insert(services)
})
.insert(services)
}

0 comments on commit 83691f6

Please sign in to comment.