Add SweptHalfEdge

This commit is contained in:
Hanno Braun 2024-06-26 19:19:42 +02:00
parent d906b5327d
commit 07f6701935
3 changed files with 23 additions and 6 deletions

View File

@ -10,7 +10,7 @@ use crate::{
Core, Core,
}; };
use super::SweepCache; use super::{half_edge::SweptHalfEdge, SweepCache};
/// # Sweep a [`Cycle`] /// # Sweep a [`Cycle`]
/// ///
@ -66,7 +66,10 @@ impl SweepCycle for Cycle {
let (bottom_half_edge, bottom_half_edge_next) = let (bottom_half_edge, bottom_half_edge_next) =
bottom_half_edge_pair; bottom_half_edge_pair;
let (side_face, top_half_edge) = bottom_half_edge.sweep_half_edge( let SweptHalfEdge {
face: side_face,
top_half_edge,
} = bottom_half_edge.sweep_half_edge(
bottom_half_edge_next.start_vertex().clone(), bottom_half_edge_next.start_vertex().clone(),
bottom_surface.clone(), bottom_surface.clone(),
color, color,

View File

@ -44,7 +44,7 @@ pub trait SweepHalfEdge {
path: impl Into<Vector<3>>, path: impl Into<Vector<3>>,
cache: &mut SweepCache, cache: &mut SweepCache,
core: &mut Core, core: &mut Core,
) -> (Face, Handle<HalfEdge>); ) -> SweptHalfEdge;
} }
impl SweepHalfEdge for Handle<HalfEdge> { impl SweepHalfEdge for Handle<HalfEdge> {
@ -56,7 +56,7 @@ impl SweepHalfEdge for Handle<HalfEdge> {
path: impl Into<Vector<3>>, path: impl Into<Vector<3>>,
cache: &mut SweepCache, cache: &mut SweepCache,
core: &mut Core, core: &mut Core,
) -> (Face, Handle<HalfEdge>) { ) -> SweptHalfEdge {
let path = path.into(); let path = path.into();
let half_edge_geom = *core.layers.geometry.of_half_edge(self); 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); 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::{ pub use self::{
cycle::{SweepCycle, SweptCycle}, cycle::{SweepCycle, SweptCycle},
face::SweepFace, face::SweepFace,
half_edge::SweepHalfEdge, half_edge::{SweepHalfEdge, SweptHalfEdge},
path::SweepSurfacePath, path::SweepSurfacePath,
region::{SweepRegion, SweptRegion}, region::{SweepRegion, SweptRegion},
shell_face::{ShellExtendedBySweep, SweepFaceOfShell}, shell_face::{ShellExtendedBySweep, SweepFaceOfShell},