mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-11 05:18:26 +00:00
Add SegmentWithStartVertex
This commit is contained in:
parent
92cd104edf
commit
fad3e95389
@ -37,32 +37,33 @@ impl Sketch {
|
|||||||
pub fn to_face(&self, surface: Handle<Surface>) -> Face {
|
pub fn to_face(&self, surface: Handle<Surface>) -> Face {
|
||||||
let vertices = SegmentsWithStartVertex::new(&self.segments, &surface);
|
let vertices = SegmentsWithStartVertex::new(&self.segments, &surface);
|
||||||
|
|
||||||
let half_edges = vertices.iter().map(
|
let half_edges =
|
||||||
|([(segment, start_vertex), (_, end_vertex)], is_internal)| {
|
vertices
|
||||||
let curve = match segment {
|
.iter()
|
||||||
|
.map(|([segment, next_segment], is_internal)| {
|
||||||
|
let curve = match segment.segment {
|
||||||
SketchSegment::Arc { .. } => {
|
SketchSegment::Arc { .. } => {
|
||||||
// We are creating a line here, temporarily, while
|
// We are creating a line here, temporarily, while
|
||||||
// support for arcs is being implemented.
|
// support for arcs is being implemented.
|
||||||
Handle::new(Curve::line_from_vertices([
|
Handle::new(Curve::line_from_vertices([
|
||||||
&start_vertex,
|
&segment.start,
|
||||||
&end_vertex,
|
&next_segment.start,
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
SketchSegment::Line { .. } => {
|
SketchSegment::Line { .. } => {
|
||||||
Handle::new(Curve::line_from_vertices([
|
Handle::new(Curve::line_from_vertices([
|
||||||
&start_vertex,
|
&segment.start,
|
||||||
&end_vertex,
|
&next_segment.start,
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Handle::new(HalfEdge {
|
Handle::new(HalfEdge {
|
||||||
curve,
|
curve,
|
||||||
start: start_vertex,
|
start: segment.start,
|
||||||
is_internal,
|
is_internal,
|
||||||
})
|
})
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
Face::new(surface, half_edges, false)
|
Face::new(surface, half_edges, false)
|
||||||
}
|
}
|
||||||
@ -126,8 +127,7 @@ impl SegmentsWithStartVertex {
|
|||||||
|
|
||||||
fn iter(
|
fn iter(
|
||||||
&self,
|
&self,
|
||||||
) -> impl Iterator<Item = ([(SketchSegment, Handle<Vertex>); 2], bool)>
|
) -> impl Iterator<Item = ([SegmentWithStartVertex; 2], bool)> {
|
||||||
{
|
|
||||||
self.segments_with_start_vertex
|
self.segments_with_start_vertex
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
@ -137,7 +137,21 @@ impl SegmentsWithStartVertex {
|
|||||||
.map(|vertex| self.coincident_vertices.contains(vertex));
|
.map(|vertex| self.coincident_vertices.contains(vertex));
|
||||||
let is_internal = start_is_coincident && end_is_coincident;
|
let is_internal = start_is_coincident && end_is_coincident;
|
||||||
|
|
||||||
([(segment, start), (next_segment, end)], is_internal)
|
(
|
||||||
|
[
|
||||||
|
SegmentWithStartVertex { segment, start },
|
||||||
|
SegmentWithStartVertex {
|
||||||
|
segment: next_segment,
|
||||||
|
start: end,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
is_internal,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SegmentWithStartVertex {
|
||||||
|
segment: SketchSegment,
|
||||||
|
start: Handle<Vertex>,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user