mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-11 05:18:26 +00:00
Merge pull request #2351 from hannobraun/geometry
Define curve geometry in `JoinCycle::join_to`
This commit is contained in:
commit
21e246efea
@ -166,123 +166,141 @@ pub trait BuildShell {
|
|||||||
let [a, b, c, d] = points.map(Into::into);
|
let [a, b, c, d] = points.map(Into::into);
|
||||||
|
|
||||||
let abc = Face::triangle([a, b, c], core);
|
let abc = Face::triangle([a, b, c], core);
|
||||||
let bad = Face::triangle([b, a, d], core).update_region(
|
let bad = {
|
||||||
|region, core| {
|
let bad = Face::triangle([b, a, d], core);
|
||||||
region.update_exterior(
|
bad.update_region(
|
||||||
|cycle, core| {
|
|region, core| {
|
||||||
cycle
|
region.update_exterior(
|
||||||
.update_half_edge(
|
|cycle, core| {
|
||||||
cycle.half_edges().nth_circular(0),
|
cycle
|
||||||
|edge, core| {
|
.update_half_edge(
|
||||||
[edge
|
cycle.half_edges().nth_circular(0),
|
||||||
|
|edge, core| {
|
||||||
|
[edge.reverse_curve_coordinate_systems(
|
||||||
|
core,
|
||||||
|
)]
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
.join_to(
|
||||||
|
abc.face.region().exterior(),
|
||||||
|
0..=0,
|
||||||
|
0..=0,
|
||||||
|
bad.face.surface().clone(),
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
let dac =
|
||||||
|
{
|
||||||
|
let dac = Face::triangle([d, a, c], core);
|
||||||
|
dac.update_region(
|
||||||
|
|region, core| {
|
||||||
|
region.update_exterior(
|
||||||
|
|cycle, core| {
|
||||||
|
cycle
|
||||||
|
.update_half_edge(
|
||||||
|
cycle.half_edges().nth_circular(1),
|
||||||
|
|edge, core| {
|
||||||
|
[edge
|
||||||
.reverse_curve_coordinate_systems(core)]
|
.reverse_curve_coordinate_systems(core)]
|
||||||
},
|
},
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
.join_to(
|
.join_to(
|
||||||
abc.face.region().exterior(),
|
abc.face.region().exterior(),
|
||||||
0..=0,
|
1..=1,
|
||||||
0..=0,
|
2..=2,
|
||||||
core,
|
dac.face.surface().clone(),
|
||||||
)
|
core,
|
||||||
|
)
|
||||||
|
.update_half_edge(
|
||||||
|
cycle.half_edges().nth_circular(0),
|
||||||
|
|edge, core| {
|
||||||
|
[edge
|
||||||
|
.reverse_curve_coordinate_systems(core)]
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
.join_to(
|
||||||
|
bad.face.region().exterior(),
|
||||||
|
0..=0,
|
||||||
|
1..=1,
|
||||||
|
dac.face.surface().clone(),
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
},
|
};
|
||||||
core,
|
let cbd =
|
||||||
);
|
{
|
||||||
let dac = Face::triangle([d, a, c], core).update_region(
|
let cbd = Face::triangle([c, b, d], core);
|
||||||
|region, core| {
|
cbd.update_region(
|
||||||
region.update_exterior(
|
|region, core| {
|
||||||
|cycle, core| {
|
region.update_exterior(
|
||||||
cycle
|
|cycle, core| {
|
||||||
.update_half_edge(
|
cycle
|
||||||
cycle.half_edges().nth_circular(1),
|
.update_half_edge(
|
||||||
|edge, core| {
|
cycle.half_edges().nth_circular(0),
|
||||||
[edge
|
|edge, core| {
|
||||||
|
[edge
|
||||||
.reverse_curve_coordinate_systems(core)]
|
.reverse_curve_coordinate_systems(core)]
|
||||||
},
|
},
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
.join_to(
|
.update_half_edge(
|
||||||
abc.face.region().exterior(),
|
cycle.half_edges().nth_circular(1),
|
||||||
1..=1,
|
|edge, core| {
|
||||||
2..=2,
|
[edge
|
||||||
core,
|
|
||||||
)
|
|
||||||
.update_half_edge(
|
|
||||||
cycle.half_edges().nth_circular(0),
|
|
||||||
|edge, core| {
|
|
||||||
[edge
|
|
||||||
.reverse_curve_coordinate_systems(core)]
|
.reverse_curve_coordinate_systems(core)]
|
||||||
},
|
},
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
.join_to(
|
.update_half_edge(
|
||||||
bad.face.region().exterior(),
|
cycle.half_edges().nth_circular(2),
|
||||||
0..=0,
|
|edge, core| {
|
||||||
1..=1,
|
[edge
|
||||||
core,
|
.reverse_curve_coordinate_systems(core)]
|
||||||
)
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
.join_to(
|
||||||
|
abc.face.region().exterior(),
|
||||||
|
0..=0,
|
||||||
|
1..=1,
|
||||||
|
cbd.face.surface().clone(),
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
.join_to(
|
||||||
|
bad.face.region().exterior(),
|
||||||
|
1..=1,
|
||||||
|
2..=2,
|
||||||
|
cbd.face.surface().clone(),
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
.join_to(
|
||||||
|
dac.face.region().exterior(),
|
||||||
|
2..=2,
|
||||||
|
2..=2,
|
||||||
|
cbd.face.surface().clone(),
|
||||||
|
core,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
core,
|
||||||
|
)
|
||||||
},
|
},
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
},
|
};
|
||||||
core,
|
|
||||||
);
|
|
||||||
let cbd = Face::triangle([c, b, d], core).update_region(
|
|
||||||
|region, core| {
|
|
||||||
region.update_exterior(
|
|
||||||
|cycle, core| {
|
|
||||||
cycle
|
|
||||||
.update_half_edge(
|
|
||||||
cycle.half_edges().nth_circular(0),
|
|
||||||
|edge, core| {
|
|
||||||
[edge
|
|
||||||
.reverse_curve_coordinate_systems(core)]
|
|
||||||
},
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.update_half_edge(
|
|
||||||
cycle.half_edges().nth_circular(1),
|
|
||||||
|edge, core| {
|
|
||||||
[edge
|
|
||||||
.reverse_curve_coordinate_systems(core)]
|
|
||||||
},
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.update_half_edge(
|
|
||||||
cycle.half_edges().nth_circular(2),
|
|
||||||
|edge, core| {
|
|
||||||
[edge
|
|
||||||
.reverse_curve_coordinate_systems(core)]
|
|
||||||
},
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.join_to(
|
|
||||||
abc.face.region().exterior(),
|
|
||||||
0..=0,
|
|
||||||
1..=1,
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.join_to(
|
|
||||||
bad.face.region().exterior(),
|
|
||||||
1..=1,
|
|
||||||
2..=2,
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
.join_to(
|
|
||||||
dac.face.region().exterior(),
|
|
||||||
2..=2,
|
|
||||||
2..=2,
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
core,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
core,
|
|
||||||
);
|
|
||||||
|
|
||||||
let triangles =
|
let triangles =
|
||||||
[abc, bad, dac, cbd].map(|triangle| triangle.insert(core));
|
[abc, bad, dac, cbd].map(|triangle| triangle.insert(core));
|
||||||
|
@ -84,6 +84,7 @@ pub trait JoinCycle {
|
|||||||
other: &Cycle,
|
other: &Cycle,
|
||||||
range: RangeInclusive<usize>,
|
range: RangeInclusive<usize>,
|
||||||
other_range: RangeInclusive<usize>,
|
other_range: RangeInclusive<usize>,
|
||||||
|
surface_self: Handle<Surface>,
|
||||||
core: &mut Core,
|
core: &mut Core,
|
||||||
) -> Self;
|
) -> Self;
|
||||||
}
|
}
|
||||||
@ -131,6 +132,7 @@ impl JoinCycle for Cycle {
|
|||||||
other: &Cycle,
|
other: &Cycle,
|
||||||
range: RangeInclusive<usize>,
|
range: RangeInclusive<usize>,
|
||||||
range_other: RangeInclusive<usize>,
|
range_other: RangeInclusive<usize>,
|
||||||
|
surface_self: Handle<Surface>,
|
||||||
core: &mut Core,
|
core: &mut Core,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -148,6 +150,30 @@ impl JoinCycle for Cycle {
|
|||||||
.update_half_edge(
|
.update_half_edge(
|
||||||
self.half_edges().nth_circular(index),
|
self.half_edges().nth_circular(index),
|
||||||
|half_edge, core| {
|
|half_edge, core| {
|
||||||
|
// The curve of the other half-edge we're joining
|
||||||
|
// this one to already has a curve geometry,
|
||||||
|
// presumably. But it might not have a local
|
||||||
|
// definition for the surface that *this* half-edge
|
||||||
|
// is in.
|
||||||
|
//
|
||||||
|
// We need to make sure that any local definition
|
||||||
|
// that our current curve already has, moves over to
|
||||||
|
// the new one.
|
||||||
|
let curve_geom = core
|
||||||
|
.layers
|
||||||
|
.geometry
|
||||||
|
.of_curve(half_edge.curve())
|
||||||
|
.and_then(|curve_geom| {
|
||||||
|
curve_geom.local_on(&surface_self)
|
||||||
|
});
|
||||||
|
if let Some(curve_geom) = curve_geom {
|
||||||
|
core.layers.geometry.define_curve(
|
||||||
|
edge_other.curve().clone(),
|
||||||
|
surface_self.clone(),
|
||||||
|
curve_geom.clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
[half_edge
|
[half_edge
|
||||||
.update_curve(
|
.update_curve(
|
||||||
|_, _| edge_other.curve().clone(),
|
|_, _| edge_other.curve().clone(),
|
||||||
|
Loading…
Reference in New Issue
Block a user