mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-11 02:37:00 +00:00
Merge pull request #2341 from hannobraun/geometry
Set curve geometry in `JoinCycle::add_joined_edges`
This commit is contained in:
commit
992783ea15
@ -75,6 +75,7 @@ impl AddHole for Shell {
|
|||||||
entry.clone(),
|
entry.clone(),
|
||||||
*core.layers.geometry.of_half_edge(&entry),
|
*core.layers.geometry.of_half_edge(&entry),
|
||||||
)],
|
)],
|
||||||
|
location.face.surface().clone(),
|
||||||
core,
|
core,
|
||||||
)],
|
)],
|
||||||
core,
|
core,
|
||||||
@ -150,6 +151,7 @@ impl AddHole for Shell {
|
|||||||
entry.clone(),
|
entry.clone(),
|
||||||
*core.layers.geometry.of_half_edge(&entry),
|
*core.layers.geometry.of_half_edge(&entry),
|
||||||
)],
|
)],
|
||||||
|
entry_location.face.surface().clone(),
|
||||||
core,
|
core,
|
||||||
)],
|
)],
|
||||||
core,
|
core,
|
||||||
@ -171,6 +173,7 @@ impl AddHole for Shell {
|
|||||||
exit.clone(),
|
exit.clone(),
|
||||||
*core.layers.geometry.of_half_edge(exit),
|
*core.layers.geometry.of_half_edge(exit),
|
||||||
)],
|
)],
|
||||||
|
exit_location.face.surface().clone(),
|
||||||
core,
|
core,
|
||||||
)],
|
)],
|
||||||
core,
|
core,
|
||||||
|
@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::HalfEdgeGeom,
|
geometry::{HalfEdgeGeom, LocalCurveGeom},
|
||||||
operations::{
|
operations::{
|
||||||
build::BuildHalfEdge,
|
build::BuildHalfEdge,
|
||||||
geometry::UpdateHalfEdgeGeometry,
|
geometry::UpdateHalfEdgeGeometry,
|
||||||
@ -11,15 +11,28 @@ use crate::{
|
|||||||
update::{UpdateCycle, UpdateHalfEdge},
|
update::{UpdateCycle, UpdateHalfEdge},
|
||||||
},
|
},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
topology::{Cycle, HalfEdge},
|
topology::{Cycle, HalfEdge, Surface},
|
||||||
Core,
|
Core,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Join a [`Cycle`] to another
|
/// Join a [`Cycle`] to another
|
||||||
pub trait JoinCycle {
|
pub trait JoinCycle {
|
||||||
/// Add half-edges to the cycle that are joined to the provided ones
|
/// Add new half-edges to the cycle that are joined to the provided ones
|
||||||
|
///
|
||||||
|
/// This method creates a new half-edge for each half-edge that is provided,
|
||||||
|
/// joins the new half-edge to the provided one, and adds the new half-edge
|
||||||
|
/// to the cycle.
|
||||||
|
///
|
||||||
|
/// The geometry for each new half-edge needs to be provided as well.
|
||||||
|
///
|
||||||
|
/// Also requires the surface that the cycle is defined in.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn add_joined_edges<Es>(&self, edges: Es, core: &mut Core) -> Self
|
fn add_joined_edges<Es>(
|
||||||
|
&self,
|
||||||
|
edges: Es,
|
||||||
|
surface: Handle<Surface>,
|
||||||
|
core: &mut Core,
|
||||||
|
) -> Self
|
||||||
where
|
where
|
||||||
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
|
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
|
||||||
Es::IntoIter: Clone + ExactSizeIterator;
|
Es::IntoIter: Clone + ExactSizeIterator;
|
||||||
@ -76,7 +89,12 @@ pub trait JoinCycle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl JoinCycle for Cycle {
|
impl JoinCycle for Cycle {
|
||||||
fn add_joined_edges<Es>(&self, edges: Es, core: &mut Core) -> Self
|
fn add_joined_edges<Es>(
|
||||||
|
&self,
|
||||||
|
edges: Es,
|
||||||
|
surface: Handle<Surface>,
|
||||||
|
core: &mut Core,
|
||||||
|
) -> Self
|
||||||
where
|
where
|
||||||
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
|
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
|
||||||
Es::IntoIter: Clone + ExactSizeIterator,
|
Es::IntoIter: Clone + ExactSizeIterator,
|
||||||
@ -85,14 +103,24 @@ impl JoinCycle for Cycle {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.circular_tuple_windows()
|
.circular_tuple_windows()
|
||||||
.map(|((prev_half_edge, _), (half_edge, geometry))| {
|
.map(|((prev_half_edge, _), (half_edge, geometry))| {
|
||||||
HalfEdge::unjoined(core)
|
let half_edge = HalfEdge::unjoined(core)
|
||||||
.update_curve(|_, _| half_edge.curve().clone(), core)
|
.update_curve(|_, _| half_edge.curve().clone(), core)
|
||||||
.update_start_vertex(
|
.update_start_vertex(
|
||||||
|_, _| prev_half_edge.start_vertex().clone(),
|
|_, _| prev_half_edge.start_vertex().clone(),
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
.insert(core)
|
.insert(core)
|
||||||
.set_geometry(geometry, &mut core.layers.geometry)
|
.set_geometry(geometry, &mut core.layers.geometry);
|
||||||
|
|
||||||
|
core.layers.geometry.define_curve(
|
||||||
|
half_edge.curve().clone(),
|
||||||
|
surface.clone(),
|
||||||
|
LocalCurveGeom {
|
||||||
|
path: geometry.path,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
half_edge
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
self.add_half_edges(half_edges, core)
|
self.add_half_edges(half_edges, core)
|
||||||
|
@ -39,6 +39,7 @@ pub trait SweepCycle {
|
|||||||
fn sweep_cycle(
|
fn sweep_cycle(
|
||||||
&self,
|
&self,
|
||||||
surface: Handle<Surface>,
|
surface: Handle<Surface>,
|
||||||
|
top_surface: Handle<Surface>,
|
||||||
color: Option<Color>,
|
color: Option<Color>,
|
||||||
path: impl Into<Vector<3>>,
|
path: impl Into<Vector<3>>,
|
||||||
cache: &mut SweepCache,
|
cache: &mut SweepCache,
|
||||||
@ -50,6 +51,7 @@ impl SweepCycle for Cycle {
|
|||||||
fn sweep_cycle(
|
fn sweep_cycle(
|
||||||
&self,
|
&self,
|
||||||
surface: Handle<Surface>,
|
surface: Handle<Surface>,
|
||||||
|
top_surface: Handle<Surface>,
|
||||||
color: Option<Color>,
|
color: Option<Color>,
|
||||||
path: impl Into<Vector<3>>,
|
path: impl Into<Vector<3>>,
|
||||||
cache: &mut SweepCache,
|
cache: &mut SweepCache,
|
||||||
@ -64,7 +66,7 @@ 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_edge) = bottom_half_edge.sweep_half_edge(
|
let (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(),
|
||||||
surface.clone(),
|
surface.clone(),
|
||||||
color,
|
color,
|
||||||
@ -76,12 +78,13 @@ impl SweepCycle for Cycle {
|
|||||||
faces.push(side_face);
|
faces.push(side_face);
|
||||||
|
|
||||||
top_edges.push((
|
top_edges.push((
|
||||||
top_edge,
|
top_half_edge,
|
||||||
*core.layers.geometry.of_half_edge(bottom_half_edge),
|
*core.layers.geometry.of_half_edge(bottom_half_edge),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let top_cycle = Cycle::empty().add_joined_edges(top_edges, core);
|
let top_cycle =
|
||||||
|
Cycle::empty().add_joined_edges(top_edges, top_surface, core);
|
||||||
|
|
||||||
SweptCycle { faces, top_cycle }
|
SweptCycle { faces, top_cycle }
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,12 @@ impl SweepRegion for Region {
|
|||||||
|
|
||||||
let mut faces = Vec::new();
|
let mut faces = Vec::new();
|
||||||
|
|
||||||
|
let top_surface = surface.translate(path, core).insert(core);
|
||||||
|
|
||||||
let top_exterior = sweep_cycle(
|
let top_exterior = sweep_cycle(
|
||||||
self.exterior(),
|
self.exterior(),
|
||||||
surface.clone(),
|
surface.clone(),
|
||||||
|
top_surface.clone(),
|
||||||
color,
|
color,
|
||||||
&mut faces,
|
&mut faces,
|
||||||
path,
|
path,
|
||||||
@ -69,6 +72,7 @@ impl SweepRegion for Region {
|
|||||||
sweep_cycle(
|
sweep_cycle(
|
||||||
bottom_cycle,
|
bottom_cycle,
|
||||||
surface.clone(),
|
surface.clone(),
|
||||||
|
top_surface.clone(),
|
||||||
color,
|
color,
|
||||||
&mut faces,
|
&mut faces,
|
||||||
path,
|
path,
|
||||||
@ -79,7 +83,6 @@ impl SweepRegion for Region {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let top_face = {
|
let top_face = {
|
||||||
let top_surface = surface.translate(path, core).insert(core);
|
|
||||||
let top_region =
|
let top_region =
|
||||||
Region::new(top_exterior, top_interiors).insert(core);
|
Region::new(top_exterior, top_interiors).insert(core);
|
||||||
|
|
||||||
@ -93,9 +96,11 @@ impl SweepRegion for Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn sweep_cycle(
|
fn sweep_cycle(
|
||||||
bottom_cycle: &Cycle,
|
bottom_cycle: &Cycle,
|
||||||
bottom_surface: Handle<Surface>,
|
bottom_surface: Handle<Surface>,
|
||||||
|
top_surface: Handle<Surface>,
|
||||||
color: Option<Color>,
|
color: Option<Color>,
|
||||||
faces: &mut Vec<Face>,
|
faces: &mut Vec<Face>,
|
||||||
path: Vector<3>,
|
path: Vector<3>,
|
||||||
@ -104,6 +109,7 @@ fn sweep_cycle(
|
|||||||
) -> Handle<Cycle> {
|
) -> Handle<Cycle> {
|
||||||
let swept_cycle = bottom_cycle.reverse(core).sweep_cycle(
|
let swept_cycle = bottom_cycle.reverse(core).sweep_cycle(
|
||||||
bottom_surface,
|
bottom_surface,
|
||||||
|
top_surface,
|
||||||
color,
|
color,
|
||||||
path,
|
path,
|
||||||
cache,
|
cache,
|
||||||
|
Loading…
Reference in New Issue
Block a user