mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 02:18:28 +00:00
Merge pull request #2306 from hannobraun/geometry
Make some refactorings to geometry-related code
This commit is contained in:
commit
6658cc1196
@ -192,12 +192,12 @@ mod tests {
|
||||
fn approx_line_on_flat_surface() {
|
||||
let mut core = Core::new();
|
||||
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let surface = core.layers.topology.surfaces.xz_plane();
|
||||
let (path, boundary) =
|
||||
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let boundary = CurveBoundary::from(boundary);
|
||||
let half_edge = HalfEdgeGeom { path, boundary };
|
||||
let surface = core.layers.topology.surfaces.xz_plane();
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx = (&curve, &half_edge, &surface)
|
||||
@ -210,16 +210,16 @@ mod tests {
|
||||
fn approx_line_on_curved_surface_but_not_along_curve() {
|
||||
let mut core = Core::new();
|
||||
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let (path, boundary) =
|
||||
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
|
||||
let boundary = CurveBoundary::from(boundary);
|
||||
let half_edge = HalfEdgeGeom { path, boundary };
|
||||
let surface = Surface::from_uv(
|
||||
GlobalPath::circle_from_radius(1.),
|
||||
[0., 0., 1.],
|
||||
&mut core,
|
||||
);
|
||||
let (path, boundary) =
|
||||
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let boundary = CurveBoundary::from(boundary);
|
||||
let half_edge = HalfEdgeGeom { path, boundary };
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx = (&curve, &half_edge, &surface)
|
||||
@ -233,14 +233,14 @@ mod tests {
|
||||
let mut core = Core::new();
|
||||
|
||||
let global_path = GlobalPath::circle_from_radius(1.);
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core);
|
||||
let path = SurfacePath::line_from_points_with_coords([
|
||||
([0.], [0., 1.]),
|
||||
([TAU], [TAU, 1.]),
|
||||
]);
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let boundary = CurveBoundary::from([[0.], [TAU]]);
|
||||
let half_edge = HalfEdgeGeom { path, boundary };
|
||||
let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core);
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx = (&curve, &half_edge, &surface)
|
||||
@ -266,11 +266,11 @@ mod tests {
|
||||
fn approx_circle_on_flat_surface() {
|
||||
let mut core = Core::new();
|
||||
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let surface = core.layers.topology.surfaces.xz_plane();
|
||||
let path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.);
|
||||
let curve = Curve::new().insert(&mut core);
|
||||
let boundary = CurveBoundary::from([[0.], [TAU]]);
|
||||
let half_edge = HalfEdgeGeom { path, boundary };
|
||||
let surface = core.layers.topology.surfaces.xz_plane();
|
||||
|
||||
let tolerance = 1.;
|
||||
let approx = (&curve, &half_edge, &surface)
|
||||
|
@ -10,8 +10,8 @@ impl super::BoundingVolume<2> for &Handle<HalfEdge> {
|
||||
fn aabb(self, geometry: &Geometry) -> Option<Aabb<2>> {
|
||||
let half_edge = self;
|
||||
|
||||
let half_edge = geometry.of_half_edge(half_edge);
|
||||
let path = half_edge.path;
|
||||
let half_edge_geom = geometry.of_half_edge(half_edge);
|
||||
let path = half_edge_geom.path;
|
||||
|
||||
match path {
|
||||
SurfacePath::Circle(circle) => {
|
||||
@ -27,7 +27,7 @@ impl super::BoundingVolume<2> for &Handle<HalfEdge> {
|
||||
})
|
||||
}
|
||||
SurfacePath::Line(_) => {
|
||||
let points = half_edge.boundary.inner.map(|point_curve| {
|
||||
let points = half_edge_geom.boundary.inner.map(|point_curve| {
|
||||
path.point_from_path_coords(point_curve)
|
||||
});
|
||||
|
||||
|
@ -106,13 +106,17 @@ pub trait BuildHalfEdge {
|
||||
boundary.zip_ext(points_surface),
|
||||
);
|
||||
|
||||
HalfEdge::unjoined(core).insert(core).set_geometry(
|
||||
let half_edge = HalfEdge::unjoined(core).insert(core);
|
||||
|
||||
core.layers.geometry.define_half_edge(
|
||||
half_edge.clone(),
|
||||
HalfEdgeGeom {
|
||||
path,
|
||||
boundary: boundary.into(),
|
||||
},
|
||||
&mut core.layers.geometry,
|
||||
)
|
||||
);
|
||||
|
||||
half_edge
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ use super::ReverseCurveCoordinateSystems;
|
||||
|
||||
impl ReverseCurveCoordinateSystems for Handle<HalfEdge> {
|
||||
fn reverse_curve_coordinate_systems(&self, core: &mut Core) -> Self {
|
||||
let mut geometry = *core.layers.geometry.of_half_edge(self);
|
||||
geometry.path = geometry.path.reverse();
|
||||
geometry.boundary = geometry.boundary.reverse();
|
||||
let mut half_edge_geom = *core.layers.geometry.of_half_edge(self);
|
||||
half_edge_geom.path = half_edge_geom.path.reverse();
|
||||
half_edge_geom.boundary = half_edge_geom.boundary.reverse();
|
||||
|
||||
let half_edge =
|
||||
HalfEdge::new(self.curve().clone(), self.start_vertex().clone())
|
||||
@ -20,7 +20,7 @@ impl ReverseCurveCoordinateSystems for Handle<HalfEdge> {
|
||||
|
||||
core.layers
|
||||
.geometry
|
||||
.define_half_edge(half_edge.clone(), geometry);
|
||||
.define_half_edge(half_edge.clone(), half_edge_geom);
|
||||
|
||||
half_edge
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ impl SolidValidationError {
|
||||
face.region()
|
||||
.all_cycles()
|
||||
.flat_map(|cycle| cycle.half_edges().iter().cloned())
|
||||
.zip(repeat(geometry.of_surface(face.surface())))
|
||||
.zip(repeat(face.surface()))
|
||||
})
|
||||
.map(|(h, s)| {
|
||||
(
|
||||
s.point_from_surface_coords(
|
||||
geometry.of_surface(s).point_from_surface_coords(
|
||||
geometry.of_half_edge(&h).start_position(),
|
||||
),
|
||||
h.start_vertex().clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user