mirror of https://github.com/hannobraun/Fornjot
Simplify `PartialVertex::with_curve`
This commit is contained in:
parent
18e1fb6eb3
commit
9ba8e98735
|
@ -184,7 +184,7 @@ mod tests {
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let vertex = Vertex::partial()
|
let vertex = Vertex::partial()
|
||||||
.with_position(Some([0.]))
|
.with_position(Some([0.]))
|
||||||
.with_curve(Some(curve))
|
.with_curve(curve)
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
|
|
||||||
let half_edge =
|
let half_edge =
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl TransformObject for PartialHalfEdge {
|
||||||
Ok(vertex
|
Ok(vertex
|
||||||
.into_partial()
|
.into_partial()
|
||||||
.transform(transform, objects)?
|
.transform(transform, objects)?
|
||||||
.with_curve(Some(curve.clone())))
|
.with_curve(curve.clone()))
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let global_form = self
|
let global_form = self
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl TransformObject for PartialVertex {
|
||||||
// coordinates and thus transforming the curve takes care of it.
|
// coordinates and thus transforming the curve takes care of it.
|
||||||
Ok(Self::default()
|
Ok(Self::default()
|
||||||
.with_position(self.position())
|
.with_position(self.position())
|
||||||
.with_curve(Some(curve))
|
.with_curve(curve)
|
||||||
.with_surface_form(surface_form))
|
.with_surface_form(surface_form))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl CycleBuilder for PartialCycle {
|
||||||
let [from, to] =
|
let [from, to] =
|
||||||
[(0., from), (1., to)].map(|(position, surface_form)| {
|
[(0., from), (1., to)].map(|(position, surface_form)| {
|
||||||
Vertex::partial()
|
Vertex::partial()
|
||||||
.with_curve(Some(curve.clone()))
|
.with_curve(curve.clone())
|
||||||
.with_position(Some([position]))
|
.with_position(Some([position]))
|
||||||
.with_surface_form(surface_form)
|
.with_surface_form(surface_form)
|
||||||
});
|
});
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||||
let [back, front] = [a_curve, b_curve].map(|point_curve| {
|
let [back, front] = [a_curve, b_curve].map(|point_curve| {
|
||||||
Vertex::partial()
|
Vertex::partial()
|
||||||
.with_position(Some(point_curve))
|
.with_position(Some(point_curve))
|
||||||
.with_curve(Some(curve.clone()))
|
.with_curve(curve.clone())
|
||||||
.with_surface_form(surface_vertex.clone())
|
.with_surface_form(surface_vertex.clone())
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||||
vertex.update_partial(|vertex| {
|
vertex.update_partial(|vertex| {
|
||||||
vertex
|
vertex
|
||||||
.with_position(Some([position]))
|
.with_position(Some([position]))
|
||||||
.with_curve(Some(curve.clone()))
|
.with_curve(curve.clone())
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ impl PartialHalfEdge {
|
||||||
let curve = self.curve.into_full(objects)?;
|
let curve = self.curve.into_full(objects)?;
|
||||||
let vertices = self.vertices.try_map_ext(|vertex| {
|
let vertices = self.vertices.try_map_ext(|vertex| {
|
||||||
vertex
|
vertex
|
||||||
.update_partial(|vertex| vertex.with_curve(Some(curve.clone())))
|
.update_partial(|vertex| vertex.with_curve(curve.clone()))
|
||||||
.into_full(objects)
|
.into_full(objects)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,8 @@ impl PartialVertex {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Provide a curve for the partial vertex
|
/// Provide a curve for the partial vertex
|
||||||
pub fn with_curve(
|
pub fn with_curve(mut self, curve: impl Into<MaybePartial<Curve>>) -> Self {
|
||||||
mut self,
|
|
||||||
curve: Option<impl Into<MaybePartial<Curve>>>,
|
|
||||||
) -> Self {
|
|
||||||
if let Some(curve) = curve {
|
|
||||||
self.curve = curve.into();
|
self.curve = curve.into();
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ mod tests {
|
||||||
vertices[1] = vertices[1]
|
vertices[1] = vertices[1]
|
||||||
.to_partial()
|
.to_partial()
|
||||||
// Arranging for an equal but not identical curve here.
|
// Arranging for an equal but not identical curve here.
|
||||||
.with_curve(Some(valid.curve().to_partial()))
|
.with_curve(valid.curve().to_partial())
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
|
|
||||||
HalfEdge::new(vertices, valid.global_form().clone())
|
HalfEdge::new(vertices, valid.global_form().clone())
|
||||||
|
|
|
@ -191,11 +191,11 @@ mod tests {
|
||||||
|
|
||||||
let valid = Vertex::partial()
|
let valid = Vertex::partial()
|
||||||
.with_position(Some([0.]))
|
.with_position(Some([0.]))
|
||||||
.with_curve(Some(
|
.with_curve(
|
||||||
Curve::partial()
|
Curve::partial()
|
||||||
.with_surface(Some(objects.surfaces.xy_plane()))
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
.update_as_u_axis(),
|
.update_as_u_axis(),
|
||||||
))
|
)
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let invalid = Vertex::new(
|
let invalid = Vertex::new(
|
||||||
valid.position(),
|
valid.position(),
|
||||||
|
@ -219,11 +219,11 @@ mod tests {
|
||||||
|
|
||||||
let valid = Vertex::partial()
|
let valid = Vertex::partial()
|
||||||
.with_position(Some([0.]))
|
.with_position(Some([0.]))
|
||||||
.with_curve(Some(
|
.with_curve(
|
||||||
Curve::partial()
|
Curve::partial()
|
||||||
.with_surface(Some(objects.surfaces.xy_plane()))
|
.with_surface(Some(objects.surfaces.xy_plane()))
|
||||||
.update_as_u_axis(),
|
.update_as_u_axis(),
|
||||||
))
|
)
|
||||||
.build(&objects)?;
|
.build(&objects)?;
|
||||||
let invalid = Vertex::new(
|
let invalid = Vertex::new(
|
||||||
valid.position(),
|
valid.position(),
|
||||||
|
|
Loading…
Reference in New Issue