mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-06 10:58: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 {
|
pub fn to_face(&self, surface: Handle<Surface>) -> Face {
|
||||||
let vertices = VerticesFromSegments::new(&self.segments, &surface);
|
let vertices = VerticesFromSegments::new(&self.segments, &surface);
|
||||||
|
|
||||||
let half_edges =
|
let half_edges = vertices.iter().map(|([start, end], is_internal)| {
|
||||||
vertices.vertices.into_iter().circular_tuple_windows().map(
|
let curve = Handle::new(Curve::line_from_vertices([&start, &end]));
|
||||||
|(start, end)| {
|
|
||||||
let curve =
|
|
||||||
Handle::new(Curve::line_from_vertices([&start, &end]));
|
|
||||||
|
|
||||||
let [start_is_coincident, end_is_coincident] =
|
Handle::new(HalfEdge {
|
||||||
[&start, &end].map(|vertex| {
|
curve,
|
||||||
vertices.coincident_vertices.contains(vertex)
|
start,
|
||||||
});
|
is_internal,
|
||||||
let is_internal = start_is_coincident && end_is_coincident;
|
})
|
||||||
|
});
|
||||||
Handle::new(HalfEdge {
|
|
||||||
curve,
|
|
||||||
start,
|
|
||||||
is_internal,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Face::new(surface, half_edges, false)
|
Face::new(surface, half_edges, false)
|
||||||
}
|
}
|
||||||
@ -115,4 +105,16 @@ impl VerticesFromSegments {
|
|||||||
coincident_vertices,
|
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