mirror of
https://github.com/hannobraun/Fornjot
synced 2025-09-30 04:58:17 +00:00
Consolidate redundant code
This commit is contained in:
parent
6b6bcca528
commit
52ddd8a5e4
@ -9,10 +9,7 @@ use geo::{Contains, Coord, LineString, Polygon};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
extra::triangulate::{delaunay::triangles, triangulate_surface},
|
extra::triangulate::{delaunay::triangles, triangulate_surface},
|
||||||
topology::{
|
topology::face::{Face, HalfEdgeWithEndVertex},
|
||||||
face::{Face, HalfEdgeWithEndVertex},
|
|
||||||
surface::Surface,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::TriangulationPoint;
|
use super::TriangulationPoint;
|
||||||
@ -35,7 +32,6 @@ pub fn triangulate_face(
|
|||||||
|
|
||||||
triangulate_surface(&face.surface, &boundary, tolerance)
|
triangulate_surface(&face.surface, &boundary, tolerance)
|
||||||
};
|
};
|
||||||
dbg!(surface_points);
|
|
||||||
dbg!(surface_triangles);
|
dbg!(surface_triangles);
|
||||||
|
|
||||||
let mut points_from_half_edges = Vec::new();
|
let mut points_from_half_edges = Vec::new();
|
||||||
@ -44,14 +40,7 @@ pub fn triangulate_face(
|
|||||||
let polygon_from_half_edges =
|
let polygon_from_half_edges =
|
||||||
polygon_from_half_edges(&points_from_half_edges);
|
polygon_from_half_edges(&points_from_half_edges);
|
||||||
|
|
||||||
let mut points_from_surface = Vec::new();
|
let triangles = triangles(points_from_half_edges, surface_points)
|
||||||
surface_to_points(
|
|
||||||
&face.surface,
|
|
||||||
&polygon_from_half_edges,
|
|
||||||
&mut points_from_surface,
|
|
||||||
);
|
|
||||||
|
|
||||||
let triangles = triangles(points_from_half_edges, points_from_surface)
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|triangle| {
|
.filter(|triangle| {
|
||||||
let points = triangle.map(|point| point.point_surface);
|
let points = triangle.map(|point| point.point_surface);
|
||||||
@ -199,27 +188,3 @@ fn polygon_from_half_edges(
|
|||||||
|
|
||||||
Polygon::new(exterior, interiors)
|
Polygon::new(exterior, interiors)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn surface_to_points(
|
|
||||||
surface: &Surface,
|
|
||||||
boundary: &Polygon,
|
|
||||||
target: &mut Vec<TriangulationPoint>,
|
|
||||||
) {
|
|
||||||
let aabb = Aabb::<2>::from_points(
|
|
||||||
boundary
|
|
||||||
.exterior()
|
|
||||||
.points()
|
|
||||||
.map(|point| Point::from([point.x(), point.y()])),
|
|
||||||
);
|
|
||||||
|
|
||||||
target.extend(surface.geometry.approximate(&aabb).into_iter().map(
|
|
||||||
|point_surface| {
|
|
||||||
let point_global = surface.geometry.point_from_local(point_surface);
|
|
||||||
|
|
||||||
TriangulationPoint {
|
|
||||||
point_surface,
|
|
||||||
point_global,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user