mirror of https://github.com/hannobraun/Fornjot
Remove `PartialVertex::with_surface_form`
This commit is contained in:
parent
8c1077ae2a
commit
807f824746
|
@ -199,8 +199,8 @@ mod tests {
|
|||
algorithms::{reverse::Reverse, sweep::Sweep},
|
||||
builder::HalfEdgeBuilder,
|
||||
insert::Insert,
|
||||
objects::{Cycle, Face, HalfEdge, Objects, Vertex},
|
||||
partial::{HasPartial, PartialSurfaceVertex},
|
||||
objects::{Cycle, Face, HalfEdge, Objects},
|
||||
partial::{HasPartial, PartialSurfaceVertex, PartialVertex},
|
||||
};
|
||||
|
||||
#[test]
|
||||
|
@ -218,8 +218,7 @@ mod tests {
|
|||
let face =
|
||||
(half_edge, Color::default()).sweep([0., 0., 1.], &objects)?;
|
||||
|
||||
let expected_face =
|
||||
{
|
||||
let expected_face = {
|
||||
let surface = objects.surfaces.xz_plane();
|
||||
|
||||
let bottom = HalfEdge::partial()
|
||||
|
@ -231,42 +230,49 @@ mod tests {
|
|||
.insert(&objects)?;
|
||||
let side_up = HalfEdge::partial()
|
||||
.with_surface(surface.clone())
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
bottom.front().surface_form().clone(),
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
PartialSurfaceVertex {
|
||||
.with_back_vertex(PartialVertex {
|
||||
surface_form: bottom.front().surface_form().clone().into(),
|
||||
..Default::default()
|
||||
})
|
||||
.with_front_vertex(PartialVertex {
|
||||
surface_form: PartialSurfaceVertex {
|
||||
position: Some([1., 1.].into()),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
}
|
||||
.into(),
|
||||
..Default::default()
|
||||
})
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.insert(&objects)?;
|
||||
let top = HalfEdge::partial()
|
||||
.with_surface(surface.clone())
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
PartialSurfaceVertex {
|
||||
.with_back_vertex(PartialVertex {
|
||||
surface_form: PartialSurfaceVertex {
|
||||
position: Some([0., 1.].into()),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
side_up.front().surface_form().clone(),
|
||||
))
|
||||
}
|
||||
.into(),
|
||||
..Default::default()
|
||||
})
|
||||
.with_front_vertex(PartialVertex {
|
||||
surface_form: side_up.front().surface_form().clone().into(),
|
||||
..Default::default()
|
||||
})
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.insert(&objects)?
|
||||
.reverse(&objects)?;
|
||||
let side_down =
|
||||
HalfEdge::partial()
|
||||
let side_down = HalfEdge::partial()
|
||||
.with_surface(surface)
|
||||
.with_back_vertex(Vertex::partial().with_surface_form(
|
||||
bottom.back().surface_form().clone(),
|
||||
))
|
||||
.with_front_vertex(Vertex::partial().with_surface_form(
|
||||
top.front().surface_form().clone(),
|
||||
))
|
||||
.with_back_vertex(PartialVertex {
|
||||
surface_form: bottom.back().surface_form().clone().into(),
|
||||
..Default::default()
|
||||
})
|
||||
.with_front_vertex(PartialVertex {
|
||||
surface_form: top.front().surface_form().clone().into(),
|
||||
..Default::default()
|
||||
})
|
||||
.update_as_line_segment()
|
||||
.build(&objects)?
|
||||
.insert(&objects)?
|
||||
|
|
|
@ -25,9 +25,8 @@ impl TransformObject for PartialVertex {
|
|||
Ok(Self {
|
||||
position: self.position,
|
||||
curve,
|
||||
..Default::default()
|
||||
}
|
||||
.with_surface_form(surface_form))
|
||||
surface_form: surface_form.into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,10 @@ impl CycleBuilder for PartialCycle {
|
|||
.update_as_line_from_points([position_prev, position_next]);
|
||||
|
||||
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
||||
|(position, surface_form)| {
|
||||
PartialVertex {
|
||||
|(position, surface_form)| PartialVertex {
|
||||
position: Some([position].into()),
|
||||
curve: curve.clone().into(),
|
||||
..Default::default()
|
||||
}
|
||||
.with_surface_form(surface_form)
|
||||
surface_form,
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -96,13 +96,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
.build(objects)?
|
||||
.insert(objects)?;
|
||||
|
||||
let [back, front] = [a_curve, b_curve].map(|point_curve| {
|
||||
PartialVertex {
|
||||
let [back, front] =
|
||||
[a_curve, b_curve].map(|point_curve| PartialVertex {
|
||||
position: Some(point_curve),
|
||||
curve: curve.clone().into(),
|
||||
..Default::default()
|
||||
}
|
||||
.with_surface_form(surface_vertex.clone())
|
||||
surface_form: surface_vertex.clone().into(),
|
||||
});
|
||||
|
||||
Ok(self.with_curve(curve).with_vertices([back, front]))
|
||||
|
@ -120,7 +118,10 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
..Default::default()
|
||||
};
|
||||
|
||||
Vertex::partial().with_surface_form(surface_form)
|
||||
PartialVertex {
|
||||
surface_form: surface_form.into(),
|
||||
..Default::default()
|
||||
}
|
||||
});
|
||||
|
||||
self.with_surface(surface)
|
||||
|
@ -201,18 +202,16 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
.zip(global_forms)
|
||||
.collect::<[_; 2]>()
|
||||
.map(|(vertex, global_form)| {
|
||||
vertex.update_partial(|vertex| {
|
||||
vertex.clone().with_surface_form(
|
||||
vertex.surface_form.update_partial(
|
||||
|mut surface_vertex| {
|
||||
vertex.update_partial(|mut vertex| {
|
||||
vertex.surface_form = vertex
|
||||
.surface_form
|
||||
.update_partial(|mut surface_vertex| {
|
||||
if let Some(global_form) = global_form {
|
||||
surface_vertex.global_form =
|
||||
global_form;
|
||||
surface_vertex.global_form = global_form;
|
||||
}
|
||||
surface_vertex
|
||||
},
|
||||
),
|
||||
)
|
||||
});
|
||||
vertex
|
||||
})
|
||||
})
|
||||
};
|
||||
|
|
|
@ -8,9 +8,7 @@ use crate::{
|
|||
algorithms::transform::TransformObject,
|
||||
builder::{FaceBuilder, HalfEdgeBuilder},
|
||||
insert::Insert,
|
||||
objects::{
|
||||
Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface, Vertex,
|
||||
},
|
||||
objects::{Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface},
|
||||
partial::{HasPartial, PartialCurve, PartialSurfaceVertex, PartialVertex},
|
||||
storage::Handle,
|
||||
};
|
||||
|
@ -121,8 +119,14 @@ impl<'a> ShellBuilder<'a> {
|
|||
|
||||
HalfEdge::partial()
|
||||
.with_vertices([
|
||||
Vertex::partial().with_surface_form(from),
|
||||
Vertex::partial().with_surface_form(to),
|
||||
PartialVertex {
|
||||
surface_form: from.into(),
|
||||
..Default::default()
|
||||
},
|
||||
PartialVertex {
|
||||
surface_form: to.into(),
|
||||
..Default::default()
|
||||
},
|
||||
])
|
||||
.update_as_line_segment()
|
||||
.build(self.objects)
|
||||
|
@ -166,8 +170,14 @@ impl<'a> ShellBuilder<'a> {
|
|||
HalfEdge::partial()
|
||||
.with_curve(curve)
|
||||
.with_vertices([
|
||||
Vertex::partial().with_surface_form(from),
|
||||
Vertex::partial().with_surface_form(to),
|
||||
PartialVertex {
|
||||
surface_form: from.into(),
|
||||
..Default::default()
|
||||
},
|
||||
PartialVertex {
|
||||
surface_form: to.into(),
|
||||
..Default::default()
|
||||
},
|
||||
])
|
||||
.update_as_line_segment()
|
||||
.build(self.objects)
|
||||
|
@ -189,8 +199,14 @@ impl<'a> ShellBuilder<'a> {
|
|||
let from = from.surface_form().clone();
|
||||
let to = to.surface_form().clone();
|
||||
|
||||
let from = Vertex::partial().with_surface_form(from);
|
||||
let to = Vertex::partial().with_surface_form(to);
|
||||
let from = PartialVertex {
|
||||
surface_form: from.into(),
|
||||
..Default::default()
|
||||
};
|
||||
let to = PartialVertex {
|
||||
surface_form: to.into(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
HalfEdge::partial()
|
||||
.with_vertices([from, to])
|
||||
|
@ -276,12 +292,10 @@ impl<'a> ShellBuilder<'a> {
|
|||
.into_iter_fixed()
|
||||
.zip(surface_vertices.clone())
|
||||
.collect::<[_; 2]>()
|
||||
.map(|(vertex, surface_form)| {
|
||||
PartialVertex {
|
||||
.map(|(vertex, surface_form)| PartialVertex {
|
||||
position: Some(vertex.position()),
|
||||
surface_form: surface_form.into(),
|
||||
..Default::default()
|
||||
}
|
||||
.with_surface_form(surface_form)
|
||||
});
|
||||
|
||||
edges.push(
|
||||
|
|
|
@ -15,8 +15,9 @@ pub trait VertexBuilder {
|
|||
}
|
||||
|
||||
impl VertexBuilder for PartialVertex {
|
||||
fn infer_surface_form(self) -> Self {
|
||||
self.with_surface_form(PartialSurfaceVertex::default())
|
||||
fn infer_surface_form(mut self) -> Self {
|
||||
self.surface_form = PartialSurfaceVertex::default().into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,9 +96,14 @@ impl PartialCycle {
|
|||
|
||||
*half_edge = half_edge.clone().merge_with(
|
||||
PartialHalfEdge::default().with_vertices([
|
||||
PartialVertex::default().with_surface_form(back_vertex),
|
||||
PartialVertex::default()
|
||||
.with_surface_form(front_vertex.clone()),
|
||||
PartialVertex {
|
||||
surface_form: back_vertex,
|
||||
..Default::default()
|
||||
},
|
||||
PartialVertex {
|
||||
surface_form: front_vertex.clone().into(),
|
||||
..Default::default()
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
|
@ -111,9 +116,10 @@ impl PartialCycle {
|
|||
let back_vertex = previous_vertex.unwrap_or_default();
|
||||
|
||||
*half_edge = half_edge.clone().merge_with(
|
||||
PartialHalfEdge::default().with_back_vertex(
|
||||
PartialVertex::default().with_surface_form(back_vertex),
|
||||
),
|
||||
PartialHalfEdge::default().with_back_vertex(PartialVertex {
|
||||
surface_form: back_vertex,
|
||||
..Default::default()
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl PartialHalfEdge {
|
|||
});
|
||||
|
||||
self.vertices = self.vertices.map(|vertex| {
|
||||
vertex.update_partial(|vertex| {
|
||||
vertex.update_partial(|mut vertex| {
|
||||
let surface_form = vertex.surface_form.clone().update_partial(
|
||||
|mut surface_vertex| {
|
||||
surface_vertex.surface = Some(surface.clone());
|
||||
|
@ -62,7 +62,8 @@ impl PartialHalfEdge {
|
|||
},
|
||||
);
|
||||
|
||||
vertex.with_surface_form(surface_form)
|
||||
vertex.surface_form = surface_form;
|
||||
vertex
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -24,15 +24,6 @@ pub struct PartialVertex {
|
|||
}
|
||||
|
||||
impl PartialVertex {
|
||||
/// Provide a surface form for the partial vertex
|
||||
pub fn with_surface_form(
|
||||
mut self,
|
||||
surface_form: impl Into<MaybePartial<SurfaceVertex>>,
|
||||
) -> Self {
|
||||
self.surface_form = surface_form.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Build a full [`Vertex`] from the partial vertex
|
||||
///
|
||||
/// # Panics
|
||||
|
|
Loading…
Reference in New Issue