mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-15 12:47:19 +00:00
Merge pull request #1218 from hannobraun/duplication
Fix more `SurfaceVertex` duplication issues
This commit is contained in:
commit
045a2bc8f3
@ -90,9 +90,9 @@ impl Sweep for (HalfEdge, Color) {
|
|||||||
let top_edge = {
|
let top_edge = {
|
||||||
let bottom_vertices = bottom_edge.vertices();
|
let bottom_vertices = bottom_edge.vertices();
|
||||||
|
|
||||||
let global_vertices = side_edges.clone().map(|edge| {
|
let surface_vertices = side_edges.clone().map(|edge| {
|
||||||
let [_, vertex] = edge.vertices();
|
let [_, vertex] = edge.vertices();
|
||||||
vertex.global_form().clone()
|
vertex.surface_form().clone()
|
||||||
});
|
});
|
||||||
|
|
||||||
let points_curve_and_surface =
|
let points_curve_and_surface =
|
||||||
@ -120,30 +120,19 @@ impl Sweep for (HalfEdge, Color) {
|
|||||||
|
|
||||||
let global = GlobalEdge::new(
|
let global = GlobalEdge::new(
|
||||||
curve.global_form().clone(),
|
curve.global_form().clone(),
|
||||||
global_vertices.clone(),
|
surface_vertices
|
||||||
|
.clone()
|
||||||
|
.map(|surface_vertex| surface_vertex.global_form().clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let vertices = {
|
let vertices = {
|
||||||
let surface_points = points_curve_and_surface
|
|
||||||
.map(|(_, point_surface)| point_surface);
|
|
||||||
|
|
||||||
// Can be cleaned up, once `zip` is stable:
|
// Can be cleaned up, once `zip` is stable:
|
||||||
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
|
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
|
||||||
let [a_vertex, b_vertex] = bottom_vertices;
|
let [a_vertex, b_vertex] = bottom_vertices;
|
||||||
let [a_surface, b_surface] = surface_points;
|
let [a_surface, b_surface] = surface_vertices;
|
||||||
let [a_global, b_global] = global_vertices;
|
let vertices = [(a_vertex, a_surface), (b_vertex, b_surface)];
|
||||||
let vertices = [
|
|
||||||
(a_vertex, a_surface, a_global),
|
|
||||||
(b_vertex, b_surface, b_global),
|
|
||||||
];
|
|
||||||
|
|
||||||
vertices.map(|(vertex, point_surface, global_form)| {
|
vertices.map(|(vertex, surface_form)| {
|
||||||
let surface_form = SurfaceVertex::new(
|
|
||||||
point_surface,
|
|
||||||
surface.clone(),
|
|
||||||
global_form,
|
|
||||||
objects,
|
|
||||||
);
|
|
||||||
Vertex::new(vertex.position(), curve.clone(), surface_form)
|
Vertex::new(vertex.position(), curve.clone(), surface_form)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
@ -141,18 +141,12 @@ impl<'a> ShellBuilder<'a> {
|
|||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(sides_down.clone())
|
.zip(sides_down.clone())
|
||||||
.zip(&surfaces)
|
.map(|(side_up, side_down)| {
|
||||||
.map(|((side_up, side_down), surface)| {
|
|
||||||
let [_, from] = side_up.vertices();
|
let [_, from] = side_up.vertices();
|
||||||
let [to, _] = side_down.vertices();
|
let [to, _] = side_down.vertices();
|
||||||
|
|
||||||
let from = from.surface_form().clone();
|
let from = from.surface_form().clone();
|
||||||
let to = Handle::<SurfaceVertex>::partial()
|
let to = to.surface_form().clone();
|
||||||
.with_position(Some(
|
|
||||||
from.position() + [-edge_length, Z],
|
|
||||||
))
|
|
||||||
.with_surface(Some(surface.clone()))
|
|
||||||
.with_global_form(Some(to.global_form().clone()));
|
|
||||||
|
|
||||||
let from = Vertex::partial().with_surface_form(Some(from));
|
let from = Vertex::partial().with_surface_form(Some(from));
|
||||||
let to = Vertex::partial().with_surface_form(Some(to));
|
let to = Vertex::partial().with_surface_form(Some(to));
|
||||||
@ -194,6 +188,8 @@ impl<'a> ShellBuilder<'a> {
|
|||||||
let mut top_edges = top_edges;
|
let mut top_edges = top_edges;
|
||||||
top_edges.reverse();
|
top_edges.reverse();
|
||||||
|
|
||||||
|
let mut vertex_prev = None;
|
||||||
|
|
||||||
let mut edges = Vec::new();
|
let mut edges = Vec::new();
|
||||||
for (points, edge) in points.windows(2).zip(top_edges) {
|
for (points, edge) in points.windows(2).zip(top_edges) {
|
||||||
// This can't panic, as we passed `2` to `windows`. Can be
|
// This can't panic, as we passed `2` to `windows`. Can be
|
||||||
@ -204,20 +200,26 @@ impl<'a> ShellBuilder<'a> {
|
|||||||
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
|
// https://doc.rust-lang.org/std/primitive.array.html#method.zip
|
||||||
let [point_a, point_b] = points;
|
let [point_a, point_b] = points;
|
||||||
let [vertex_a, vertex_b] = edge.vertices().clone();
|
let [vertex_a, vertex_b] = edge.vertices().clone();
|
||||||
let vertices = [(point_a, vertex_a), (point_b, vertex_b)].map(
|
let vertices = [
|
||||||
|(point, vertex)| {
|
(point_a, vertex_a, vertex_prev.clone()),
|
||||||
let surface_form = Handle::<SurfaceVertex>::partial()
|
(point_b, vertex_b, None),
|
||||||
|
]
|
||||||
|
.map(|(point, vertex, surface_form)| {
|
||||||
|
let surface_form = surface_form.unwrap_or_else(|| {
|
||||||
|
Handle::<SurfaceVertex>::partial()
|
||||||
.with_position(Some(point))
|
.with_position(Some(point))
|
||||||
.with_surface(Some(surface.clone()))
|
.with_surface(Some(surface.clone()))
|
||||||
.with_global_form(Some(
|
.with_global_form(Some(
|
||||||
vertex.global_form().clone(),
|
vertex.global_form().clone(),
|
||||||
))
|
))
|
||||||
.build(self.objects);
|
.build(self.objects)
|
||||||
Vertex::partial()
|
});
|
||||||
.with_position(Some(vertex.position()))
|
vertex_prev = Some(surface_form.clone());
|
||||||
.with_surface_form(Some(surface_form))
|
|
||||||
},
|
Vertex::partial()
|
||||||
);
|
.with_position(Some(vertex.position()))
|
||||||
|
.with_surface_form(Some(surface_form))
|
||||||
|
});
|
||||||
|
|
||||||
edges.push(
|
edges.push(
|
||||||
HalfEdge::partial()
|
HalfEdge::partial()
|
||||||
|
Loading…
Reference in New Issue
Block a user