mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-06 02:48:27 +00:00
Don't use self.path
in HalfEdgeGeom
This prepares for moving the path to `CurveGeom`.
This commit is contained in:
parent
30549bc82e
commit
f7513d0646
@ -30,7 +30,14 @@ impl Approx for (&Handle<HalfEdge>, &Handle<Surface>) {
|
||||
let tolerance = tolerance.into();
|
||||
|
||||
let start_position_surface =
|
||||
geometry.of_half_edge(half_edge).start_position();
|
||||
geometry.of_half_edge(half_edge).start_position(
|
||||
&geometry
|
||||
.of_curve(half_edge.curve())
|
||||
.unwrap()
|
||||
.local_on(surface)
|
||||
.unwrap()
|
||||
.path,
|
||||
);
|
||||
let start_position =
|
||||
match cache.start_position.get(half_edge.start_vertex()) {
|
||||
Some(position) => position,
|
||||
|
@ -47,12 +47,12 @@ impl HalfEdgeGeom {
|
||||
}
|
||||
|
||||
/// Compute the surface position where the half-edge starts
|
||||
pub fn start_position(&self) -> Point<2> {
|
||||
pub fn start_position(&self, path: &SurfacePath) -> Point<2> {
|
||||
// Computing the surface position from the curve position is fine.
|
||||
// `HalfEdge` "owns" its start position. There is no competing code that
|
||||
// could compute the surface position from slightly different data.
|
||||
|
||||
let [start, _] = self.boundary.inner;
|
||||
self.path.point_from_path_coords(start)
|
||||
path.point_from_path_coords(start)
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,26 @@ impl SplitFace for Shell {
|
||||
let dividing_half_edge_a_to_d = {
|
||||
let half_edge = HalfEdge::line_segment(
|
||||
[
|
||||
core.layers.geometry.of_half_edge(&b).start_position(),
|
||||
core.layers.geometry.of_half_edge(&d).start_position(),
|
||||
core.layers.geometry.of_half_edge(&b).start_position(
|
||||
&core
|
||||
.layers
|
||||
.geometry
|
||||
.of_curve(b.curve())
|
||||
.unwrap()
|
||||
.local_on(face.surface())
|
||||
.unwrap()
|
||||
.path,
|
||||
),
|
||||
core.layers.geometry.of_half_edge(&d).start_position(
|
||||
&core
|
||||
.layers
|
||||
.geometry
|
||||
.of_curve(d.curve())
|
||||
.unwrap()
|
||||
.local_on(face.surface())
|
||||
.unwrap()
|
||||
.path,
|
||||
),
|
||||
],
|
||||
None,
|
||||
face.surface().clone(),
|
||||
|
@ -31,7 +31,11 @@ impl Cycle {
|
||||
/// Please note that this is not *the* winding of the cycle, only one of the
|
||||
/// two possible windings, depending on the direction you look at the
|
||||
/// surface that the cycle is defined on from.
|
||||
pub fn winding(&self, geometry: &Geometry, _: &Handle<Surface>) -> Winding {
|
||||
pub fn winding(
|
||||
&self,
|
||||
geometry: &Geometry,
|
||||
surface: &Handle<Surface>,
|
||||
) -> Winding {
|
||||
// The cycle could be made up of one or two circles. If that is the
|
||||
// case, the winding of the cycle is determined by the winding of the
|
||||
// first circle.
|
||||
@ -70,7 +74,14 @@ impl Cycle {
|
||||
|
||||
for (a, b) in self.half_edges().pairs() {
|
||||
let [a, b] = [a, b].map(|half_edge| {
|
||||
geometry.of_half_edge(half_edge).start_position()
|
||||
geometry.of_half_edge(half_edge).start_position(
|
||||
&geometry
|
||||
.of_curve(half_edge.curve())
|
||||
.unwrap()
|
||||
.local_on(surface)
|
||||
.unwrap()
|
||||
.path,
|
||||
)
|
||||
});
|
||||
|
||||
sum += (b.u - a.u) * (b.v + a.v);
|
||||
|
@ -106,13 +106,23 @@ impl SolidValidationError {
|
||||
.flat_map(|cycle| cycle.half_edges().iter().cloned())
|
||||
.zip(repeat(face.surface()))
|
||||
})
|
||||
.map(|(h, s)| {
|
||||
(
|
||||
.filter_map(|(h, s)| {
|
||||
let Some(local_curve_geometry) =
|
||||
geometry.of_curve(h.curve()).unwrap().local_on(s)
|
||||
else {
|
||||
// If the curve geometry has no local definition,
|
||||
// there's nothing we can check.
|
||||
return None;
|
||||
};
|
||||
|
||||
Some((
|
||||
geometry.of_surface(s).point_from_surface_coords(
|
||||
geometry.of_half_edge(&h).start_position(),
|
||||
geometry
|
||||
.of_half_edge(&h)
|
||||
.start_position(&local_curve_geometry.path),
|
||||
),
|
||||
h.start_vertex().clone(),
|
||||
)
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -201,6 +201,9 @@ mod tests {
|
||||
)
|
||||
.is_err());
|
||||
|
||||
// Ignore remaining validation errors.
|
||||
let _ = core.layers.validation.take_errors();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ fn check_region<'r>(
|
||||
|
||||
fn check_cycle<'r>(
|
||||
cycle: &'r Cycle,
|
||||
_: &'r Handle<Surface>,
|
||||
surface: &'r Handle<Surface>,
|
||||
geometry: &'r Geometry,
|
||||
config: &'r ValidationConfig,
|
||||
) -> impl Iterator<Item = AdjacentHalfEdgesNotConnected> + 'r {
|
||||
@ -105,8 +105,18 @@ fn check_cycle<'r>(
|
||||
.path
|
||||
.point_from_path_coords(end)
|
||||
};
|
||||
let start_pos_of_second_half_edge =
|
||||
geometry.of_half_edge(second).start_position();
|
||||
|
||||
let Some(local_curve_geometry) =
|
||||
geometry.of_curve(second.curve()).unwrap().local_on(surface)
|
||||
else {
|
||||
// If the curve geometry is not defined for our local surface,
|
||||
// there's nothing we can check.
|
||||
return None;
|
||||
};
|
||||
|
||||
let start_pos_of_second_half_edge = geometry
|
||||
.of_half_edge(second)
|
||||
.start_position(&local_curve_geometry.path);
|
||||
|
||||
let distance_between_positions = (end_pos_of_first_half_edge
|
||||
- start_pos_of_second_half_edge)
|
||||
|
Loading…
Reference in New Issue
Block a user