mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 02:18:28 +00:00
Extract more code into VerticesFromSegments
This commit is contained in:
parent
79bbc7f38d
commit
475fc027ba
@ -37,25 +37,15 @@ impl Sketch {
|
||||
pub fn to_face(&self, surface: Handle<Surface>) -> Face {
|
||||
let vertices = VerticesFromSegments::new(&self.segments, &surface);
|
||||
|
||||
let half_edges =
|
||||
vertices.vertices.into_iter().circular_tuple_windows().map(
|
||||
|(start, end)| {
|
||||
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]));
|
||||
|
||||
let [start_is_coincident, end_is_coincident] =
|
||||
[&start, &end].map(|vertex| {
|
||||
vertices.coincident_vertices.contains(vertex)
|
||||
});
|
||||
let is_internal = start_is_coincident && end_is_coincident;
|
||||
|
||||
Handle::new(HalfEdge {
|
||||
curve,
|
||||
start,
|
||||
is_internal,
|
||||
})
|
||||
},
|
||||
);
|
||||
Handle::new(HalfEdge {
|
||||
curve,
|
||||
start,
|
||||
is_internal,
|
||||
})
|
||||
});
|
||||
|
||||
Face::new(surface, half_edges, false)
|
||||
}
|
||||
@ -115,4 +105,16 @@ impl VerticesFromSegments {
|
||||
coincident_vertices,
|
||||
}
|
||||
}
|
||||
|
||||
fn iter(&self) -> impl Iterator<Item = ([Handle<Vertex>; 2], bool)> {
|
||||
self.vertices.iter().cloned().circular_tuple_windows().map(
|
||||
|(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)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user