Prepare to support curved half-edges

This commit is contained in:
Hanno Braun 2025-04-10 12:02:43 +02:00
parent 5a1a7d502c
commit 1c694e0270
2 changed files with 17 additions and 2 deletions

View File

@ -91,8 +91,18 @@ fn approximate_half_edge(
end_vertex: end,
}: HalfEdgeWithEndVertex,
) -> Vec<Point<3>> {
let [start, _] = [&half_edge.start, end].map(|vertex| vertex.point);
vec![start]
let [start, end] = [&half_edge.start, end].map(|vertex| vertex.point);
let points_local = half_edge.curve.geometry.approximate([start, end].map(
|point_global| half_edge.curve.geometry.project_point(point_global),
));
let mut points_global = vec![start];
points_global.extend(points_local.into_iter().map(|point_local| {
half_edge.curve.geometry.point_from_local(point_local)
}));
points_global
}
fn polygon_from_half_edges(

View File

@ -5,6 +5,7 @@ pub trait CurveGeometry {
fn point_from_local(&self, point: Point<1>) -> Point<3>;
fn project_point(&self, point: Point<3>) -> Point<1>;
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
fn approximate(&self, boundary: [Point<1>; 2]) -> Vec<Point<1>>;
}
impl CurveGeometry for Line<3> {
@ -24,4 +25,8 @@ impl CurveGeometry for Line<3> {
let translated = self.transform(&Transform::translation(offset));
Box::new(translated)
}
fn approximate(&self, _: [Point<1>; 2]) -> Vec<Point<1>> {
vec![]
}
}