Merge pull request #2400 from hannobraun/sweep

Clean up in sweep code
This commit is contained in:
Hanno Braun 2024-06-26 20:22:06 +02:00 committed by GitHub
commit 605001938a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 10 deletions

View File

@ -60,13 +60,13 @@ impl SweepCycle for Cycle {
let path = path.into();
let mut faces = Vec::new();
let mut top_edges = Vec::new();
let mut top_half_edges = Vec::new();
for bottom_half_edge_pair in self.half_edges().pairs() {
let (bottom_half_edge, bottom_half_edge_next) =
bottom_half_edge_pair;
let (side_face, top_half_edge) = bottom_half_edge.sweep_half_edge(
let swept_half_edge = bottom_half_edge.sweep_half_edge(
bottom_half_edge_next.start_vertex().clone(),
bottom_surface.clone(),
color,
@ -75,10 +75,10 @@ impl SweepCycle for Cycle {
core,
);
faces.push(side_face);
faces.push(swept_half_edge.face);
top_edges.push((
top_half_edge,
top_half_edges.push((
swept_half_edge.top_half_edge,
*core.layers.geometry.of_half_edge(bottom_half_edge),
core.layers
.geometry
@ -91,7 +91,7 @@ impl SweepCycle for Cycle {
}
let top_cycle =
Cycle::empty().add_joined_edges(top_edges, top_surface, core);
Cycle::empty().add_joined_edges(top_half_edges, top_surface, core);
SweptCycle { faces, top_cycle }
}

View File

@ -44,7 +44,7 @@ pub trait SweepHalfEdge {
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
core: &mut Core,
) -> (Face, Handle<HalfEdge>);
) -> SweptHalfEdge;
}
impl SweepHalfEdge for Handle<HalfEdge> {
@ -56,7 +56,7 @@ impl SweepHalfEdge for Handle<HalfEdge> {
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
core: &mut Core,
) -> (Face, Handle<HalfEdge>) {
) -> SweptHalfEdge {
let path = path.into();
let half_edge_geom = *core.layers.geometry.of_half_edge(self);
@ -161,6 +161,20 @@ impl SweepHalfEdge for Handle<HalfEdge> {
let face = Face::new(surface, region);
(face, edge_top)
SweptHalfEdge {
face,
top_half_edge: edge_top,
}
}
}
/// The result of sweeping a [`HalfEdge`]
///
/// See [`SweepHalfEdge`].
pub struct SweptHalfEdge {
/// The face created by sweeping the half-edge
pub face: Face,
/// The top half-edge of the created face
pub top_half_edge: Handle<HalfEdge>,
}

View File

@ -15,7 +15,7 @@ mod vertex;
pub use self::{
cycle::{SweepCycle, SweptCycle},
face::SweepFace,
half_edge::SweepHalfEdge,
half_edge::{SweepHalfEdge, SweptHalfEdge},
path::SweepSurfacePath,
region::{SweepRegion, SweptRegion},
shell_face::{ShellExtendedBySweep, SweepFaceOfShell},