mirror of
https://github.com/hannobraun/Fornjot
synced 2025-09-02 15:36:47 +00:00
Prepare to support curved half-edges
This commit is contained in:
parent
5a1a7d502c
commit
1c694e0270
@ -91,8 +91,18 @@ fn approximate_half_edge(
|
|||||||
end_vertex: end,
|
end_vertex: end,
|
||||||
}: HalfEdgeWithEndVertex,
|
}: HalfEdgeWithEndVertex,
|
||||||
) -> Vec<Point<3>> {
|
) -> Vec<Point<3>> {
|
||||||
let [start, _] = [&half_edge.start, end].map(|vertex| vertex.point);
|
let [start, end] = [&half_edge.start, end].map(|vertex| vertex.point);
|
||||||
vec![start]
|
|
||||||
|
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(
|
fn polygon_from_half_edges(
|
||||||
|
@ -5,6 +5,7 @@ pub trait CurveGeometry {
|
|||||||
fn point_from_local(&self, point: Point<1>) -> Point<3>;
|
fn point_from_local(&self, point: Point<1>) -> Point<3>;
|
||||||
fn project_point(&self, point: Point<3>) -> Point<1>;
|
fn project_point(&self, point: Point<3>) -> Point<1>;
|
||||||
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
fn translate(&self, offset: Vector<3>) -> Box<dyn CurveGeometry>;
|
||||||
|
fn approximate(&self, boundary: [Point<1>; 2]) -> Vec<Point<1>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CurveGeometry for Line<3> {
|
impl CurveGeometry for Line<3> {
|
||||||
@ -24,4 +25,8 @@ impl CurveGeometry for Line<3> {
|
|||||||
let translated = self.transform(&Transform::translation(offset));
|
let translated = self.transform(&Transform::translation(offset));
|
||||||
Box::new(translated)
|
Box::new(translated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn approximate(&self, _: [Point<1>; 2]) -> Vec<Point<1>> {
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user