Prepare to support arcs in sketches

This commit is contained in:
Hanno Braun 2025-04-14 14:02:57 +02:00
parent b852dfd6cd
commit 7415e1f4b0

View File

@ -37,15 +37,17 @@ impl Sketch {
pub fn to_face(&self, surface: Handle<Surface>) -> Face {
let vertices = VerticesFromSegments::new(&self.segments, &surface);
let half_edges = vertices.iter().map(|([start, end], is_internal)| {
let curve = Handle::new(Curve::line_from_vertices([&start, &end]));
let half_edges =
vertices.iter().map(|(_, [start, end], is_internal)| {
let curve =
Handle::new(Curve::line_from_vertices([&start, &end]));
Handle::new(HalfEdge {
curve,
start,
is_internal,
})
});
Handle::new(HalfEdge {
curve,
start,
is_internal,
})
});
Face::new(surface, half_edges, false)
}
@ -107,17 +109,19 @@ impl VerticesFromSegments {
}
}
fn iter(&self) -> impl Iterator<Item = ([Handle<Vertex>; 2], bool)> {
fn iter(
&self,
) -> impl Iterator<Item = (SketchSegment, [Handle<Vertex>; 2], bool)> {
self.segments_with_start_vertex
.iter()
.cloned()
.circular_tuple_windows()
.map(|((_, start), (_, end))| {
.map(|((segment, start), (_, end))| {
let [start_is_coincident, end_is_coincident] = [&start, &end]
.map(|vertex| self.coincident_vertices.contains(vertex));
let is_internal = start_is_coincident && end_is_coincident;
([start, end], is_internal)
(segment, [start, end], is_internal)
})
}
}