mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-15 21:00:20 +00:00
Merge pull request #1215 from hannobraun/duplication
Fix some `SurfaceVertex` duplication issues
This commit is contained in:
commit
9845024fe0
@ -169,7 +169,9 @@ impl Sweep for (HalfEdge, Color) {
|
||||
// Need to compare surface forms here, as the global forms might
|
||||
// be coincident when sweeping circles, despite the vertices
|
||||
// being different!
|
||||
if prev_last.surface_form() != next_first.surface_form() {
|
||||
if prev_last.surface_form().id()
|
||||
!= next_first.surface_form().id()
|
||||
{
|
||||
edges[j] = edges[j].clone().reverse();
|
||||
}
|
||||
|
||||
|
@ -92,32 +92,24 @@ impl Sweep for (Vertex, Handle<Surface>) {
|
||||
)
|
||||
};
|
||||
|
||||
// And now the vertices. Again, nothing wild here.
|
||||
let vertices = {
|
||||
// Can be cleaned up, once `zip` is stable:
|
||||
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
|
||||
let [a_surface, b_surface] = points_surface;
|
||||
let [a_global, b_global] = vertices_global;
|
||||
let vertices_surface =
|
||||
[(a_surface, a_global), (b_surface, b_global)].map(
|
||||
|(point_surface, vertex_global)| {
|
||||
SurfaceVertex::new(
|
||||
point_surface,
|
||||
surface.clone(),
|
||||
vertex_global,
|
||||
objects,
|
||||
)
|
||||
},
|
||||
);
|
||||
let vertices_surface = {
|
||||
let [_, position] = points_surface;
|
||||
let [_, global_form] = vertices_global;
|
||||
|
||||
vertices_surface.map(|surface_form| {
|
||||
[
|
||||
vertex.surface_form().clone(),
|
||||
SurfaceVertex::new(position, surface, global_form, objects),
|
||||
]
|
||||
};
|
||||
|
||||
// And now the vertices. Again, nothing wild here.
|
||||
let vertices = vertices_surface.map(|surface_form| {
|
||||
Vertex::new(
|
||||
[surface_form.position().v],
|
||||
curve.clone(),
|
||||
surface_form,
|
||||
)
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
// And finally, creating the output `Edge` is just a matter of
|
||||
// assembling the pieces we've already created.
|
||||
|
@ -163,14 +163,41 @@ impl PartialCycle {
|
||||
pub fn build(self, objects: &Objects) -> Cycle {
|
||||
let surface = self.surface.expect("Need surface to build `Cycle`");
|
||||
let surface_for_edges = surface.clone();
|
||||
let half_edges = self.half_edges.into_iter().map(|half_edge| {
|
||||
half_edge
|
||||
.update_partial(|half_edge| {
|
||||
half_edge.with_surface(Some(surface_for_edges.clone()))
|
||||
})
|
||||
.into_full(objects)
|
||||
let half_edges = {
|
||||
let (half_edges, _) = self.half_edges.into_iter().fold(
|
||||
(Vec::new(), None),
|
||||
|(mut half_edges, previous), next| {
|
||||
let previous_half_edge: Option<HalfEdge> = previous;
|
||||
|
||||
let previous_vertex = previous_half_edge.map(|half_edge| {
|
||||
let [_, vertex] = half_edge.vertices().clone();
|
||||
vertex.surface_form().clone()
|
||||
});
|
||||
|
||||
let next = next
|
||||
.update_partial(|half_edge| {
|
||||
let [from, _] = half_edge.vertices.clone();
|
||||
let from = from.map(|vertex| {
|
||||
vertex.update_partial(|partial| {
|
||||
partial.with_surface_form(previous_vertex)
|
||||
})
|
||||
});
|
||||
|
||||
half_edge
|
||||
.with_surface(Some(surface_for_edges.clone()))
|
||||
.with_from_vertex(from)
|
||||
})
|
||||
.into_full(objects);
|
||||
|
||||
half_edges.push(next.clone());
|
||||
|
||||
(half_edges, Some(next))
|
||||
},
|
||||
);
|
||||
|
||||
half_edges
|
||||
};
|
||||
|
||||
Cycle::new(surface, half_edges)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user