mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-16 05:06:11 +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
|
// Need to compare surface forms here, as the global forms might
|
||||||
// be coincident when sweeping circles, despite the vertices
|
// be coincident when sweeping circles, despite the vertices
|
||||||
// being different!
|
// 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();
|
edges[j] = edges[j].clone().reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,33 +92,25 @@ impl Sweep for (Vertex, Handle<Surface>) {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// And now the vertices. Again, nothing wild here.
|
let vertices_surface = {
|
||||||
let vertices = {
|
let [_, position] = points_surface;
|
||||||
// Can be cleaned up, once `zip` is stable:
|
let [_, global_form] = vertices_global;
|
||||||
// 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,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
vertices_surface.map(|surface_form| {
|
[
|
||||||
Vertex::new(
|
vertex.surface_form().clone(),
|
||||||
[surface_form.position().v],
|
SurfaceVertex::new(position, surface, global_form, objects),
|
||||||
curve.clone(),
|
]
|
||||||
surface_form,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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
|
// And finally, creating the output `Edge` is just a matter of
|
||||||
// assembling the pieces we've already created.
|
// assembling the pieces we've already created.
|
||||||
HalfEdge::new(vertices, edge_global)
|
HalfEdge::new(vertices, edge_global)
|
||||||
|
@ -163,13 +163,40 @@ impl PartialCycle {
|
|||||||
pub fn build(self, objects: &Objects) -> Cycle {
|
pub fn build(self, objects: &Objects) -> Cycle {
|
||||||
let surface = self.surface.expect("Need surface to build `Cycle`");
|
let surface = self.surface.expect("Need surface to build `Cycle`");
|
||||||
let surface_for_edges = surface.clone();
|
let surface_for_edges = surface.clone();
|
||||||
let half_edges = self.half_edges.into_iter().map(|half_edge| {
|
let half_edges = {
|
||||||
half_edge
|
let (half_edges, _) = self.half_edges.into_iter().fold(
|
||||||
.update_partial(|half_edge| {
|
(Vec::new(), None),
|
||||||
half_edge.with_surface(Some(surface_for_edges.clone()))
|
|(mut half_edges, previous), next| {
|
||||||
})
|
let previous_half_edge: Option<HalfEdge> = previous;
|
||||||
.into_full(objects)
|
|
||||||
});
|
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)
|
Cycle::new(surface, half_edges)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user