Skip to content

Commit

Permalink
Merge pull request #2351 from hannobraun/geometry
Browse files Browse the repository at this point in the history
Define curve geometry in `JoinCycle::join_to`
  • Loading branch information
hannobraun committed May 7, 2024
2 parents 8ca2fbb + a6b8a26 commit 21e246e
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 106 deletions.
230 changes: 124 additions & 106 deletions crates/fj-core/src/operations/build/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,123 +166,141 @@ pub trait BuildShell {
let [a, b, c, d] = points.map(Into::into);

let abc = Face::triangle([a, b, c], core);
let bad = Face::triangle([b, a, 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,
)
.join_to(
abc.face.region().exterior(),
0..=0,
0..=0,
core,
)
},
core,
)
},
core,
);
let dac = Face::triangle([d, a, c], core).update_region(
|region, core| {
region.update_exterior(
|cycle, core| {
cycle
.update_half_edge(
cycle.half_edges().nth_circular(1),
|edge, core| {
[edge
let bad = {
let bad = Face::triangle([b, a, d], core);
bad.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,
)
.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)]
},
core,
)
.join_to(
abc.face.region().exterior(),
1..=1,
2..=2,
core,
)
.update_half_edge(
cycle.half_edges().nth_circular(0),
|edge, core| {
[edge
},
core,
)
.join_to(
abc.face.region().exterior(),
1..=1,
2..=2,
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,
core,
)
},
core,
)
.join_to(
bad.face.region().exterior(),
0..=0,
1..=1,
dac.face.surface().clone(),
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
};
let cbd =
{
let cbd = Face::triangle([c, b, d], core);
cbd.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
},
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
},
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,
)
.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,
);
};

let triangles =
[abc, bad, dac, cbd].map(|triangle| triangle.insert(core));
Expand Down
26 changes: 26 additions & 0 deletions crates/fj-core/src/operations/join/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub trait JoinCycle {
other: &Cycle,
range: RangeInclusive<usize>,
other_range: RangeInclusive<usize>,
surface_self: Handle<Surface>,
core: &mut Core,
) -> Self;
}
Expand Down Expand Up @@ -131,6 +132,7 @@ impl JoinCycle for Cycle {
other: &Cycle,
range: RangeInclusive<usize>,
range_other: RangeInclusive<usize>,
surface_self: Handle<Surface>,
core: &mut Core,
) -> Self {
assert_eq!(
Expand All @@ -148,6 +150,30 @@ impl JoinCycle for Cycle {
.update_half_edge(
self.half_edges().nth_circular(index),
|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
.update_curve(
|_, _| edge_other.curve().clone(),
Expand Down

0 comments on commit 21e246e

Please sign in to comment.