mirror of
https://github.com/hannobraun/Fornjot
synced 2025-07-19 00:16:07 +00:00
Remove PartialVertex::with_position
This commit is contained in:
parent
b71665a895
commit
4f4ddeffe9
@ -170,8 +170,8 @@ mod tests {
|
||||
algorithms::sweep::Sweep,
|
||||
builder::{CurveBuilder, HalfEdgeBuilder},
|
||||
insert::Insert,
|
||||
objects::{HalfEdge, Objects, Vertex},
|
||||
partial::{HasPartial, PartialCurve},
|
||||
objects::{HalfEdge, Objects},
|
||||
partial::{HasPartial, PartialCurve, PartialVertex},
|
||||
};
|
||||
|
||||
#[test]
|
||||
@ -185,11 +185,13 @@ mod tests {
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
let curve = curve.build(&objects)?.insert(&objects)?;
|
||||
let vertex = Vertex::partial()
|
||||
.with_position(Some([0.]))
|
||||
.with_curve(curve)
|
||||
.build(&objects)?
|
||||
.insert(&objects)?;
|
||||
let vertex = PartialVertex {
|
||||
position: Some([0.].into()),
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve)
|
||||
.build(&objects)?
|
||||
.insert(&objects)?;
|
||||
|
||||
let half_edge =
|
||||
(vertex, surface.clone()).sweep([0., 0., 1.], &objects)?;
|
||||
|
@ -22,10 +22,12 @@ impl TransformObject for PartialVertex {
|
||||
|
||||
// Don't need to transform `self.position`, as that is in curve
|
||||
// coordinates and thus transforming the curve takes care of it.
|
||||
Ok(Self::default()
|
||||
.with_position(self.position)
|
||||
.with_curve(curve)
|
||||
.with_surface_form(surface_form))
|
||||
Ok(Self {
|
||||
position: self.position,
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve)
|
||||
.with_surface_form(surface_form))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
objects::{HalfEdge, Surface, SurfaceVertex, Vertex},
|
||||
objects::{HalfEdge, Surface, SurfaceVertex},
|
||||
partial::{
|
||||
HasPartial, MaybePartial, PartialCurve, PartialCycle,
|
||||
PartialSurfaceVertex,
|
||||
PartialSurfaceVertex, PartialVertex,
|
||||
},
|
||||
storage::Handle,
|
||||
};
|
||||
@ -76,10 +76,12 @@ impl CycleBuilder for PartialCycle {
|
||||
|
||||
let vertices = [(0., vertex_prev), (1., vertex_next)].map(
|
||||
|(position, surface_form)| {
|
||||
Vertex::partial()
|
||||
.with_curve(curve.clone())
|
||||
.with_position(Some([position]))
|
||||
.with_surface_form(surface_form)
|
||||
PartialVertex {
|
||||
position: Some([position].into()),
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve.clone())
|
||||
.with_surface_form(surface_form)
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
},
|
||||
partial::{
|
||||
HasPartial, MaybePartial, PartialCurve, PartialGlobalEdge,
|
||||
PartialHalfEdge, PartialSurfaceVertex,
|
||||
PartialHalfEdge, PartialSurfaceVertex, PartialVertex,
|
||||
},
|
||||
storage::Handle,
|
||||
validate::ValidationError,
|
||||
@ -97,10 +97,12 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||
.insert(objects)?;
|
||||
|
||||
let [back, front] = [a_curve, b_curve].map(|point_curve| {
|
||||
Vertex::partial()
|
||||
.with_position(Some(point_curve))
|
||||
.with_curve(curve.clone())
|
||||
.with_surface_form(surface_vertex.clone())
|
||||
PartialVertex {
|
||||
position: Some(point_curve),
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve.clone())
|
||||
.with_surface_form(surface_vertex.clone())
|
||||
});
|
||||
|
||||
Ok(self.with_curve(curve).with_vertices([back, front]))
|
||||
@ -152,10 +154,9 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
||||
|
||||
let [back, front] = {
|
||||
let vertices = [(from, 0.), (to, 1.)].map(|(vertex, position)| {
|
||||
vertex.update_partial(|vertex| {
|
||||
vertex
|
||||
.with_position(Some([position]))
|
||||
.with_curve(curve.clone())
|
||||
vertex.update_partial(|mut vertex| {
|
||||
vertex.position = Some([position].into());
|
||||
vertex.with_curve(curve.clone())
|
||||
})
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,7 @@ use crate::{
|
||||
objects::{
|
||||
Cycle, Face, FaceSet, HalfEdge, Objects, Shell, Surface, Vertex,
|
||||
},
|
||||
partial::{HasPartial, PartialCurve, PartialSurfaceVertex},
|
||||
partial::{HasPartial, PartialCurve, PartialSurfaceVertex, PartialVertex},
|
||||
storage::Handle,
|
||||
};
|
||||
|
||||
@ -277,9 +277,11 @@ impl<'a> ShellBuilder<'a> {
|
||||
.zip(surface_vertices.clone())
|
||||
.collect::<[_; 2]>()
|
||||
.map(|(vertex, surface_form)| {
|
||||
Vertex::partial()
|
||||
.with_position(Some(vertex.position()))
|
||||
.with_surface_form(surface_form)
|
||||
PartialVertex {
|
||||
position: Some(vertex.position()),
|
||||
..Default::default()
|
||||
}
|
||||
.with_surface_form(surface_form)
|
||||
});
|
||||
|
||||
edges.push(
|
||||
|
@ -24,17 +24,6 @@ pub struct PartialVertex {
|
||||
}
|
||||
|
||||
impl PartialVertex {
|
||||
/// Provide a position for the partial vertex
|
||||
pub fn with_position(
|
||||
mut self,
|
||||
position: Option<impl Into<Point<1>>>,
|
||||
) -> Self {
|
||||
if let Some(position) = position {
|
||||
self.position = Some(position.into());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Provide a curve for the partial vertex
|
||||
pub fn with_curve(mut self, curve: impl Into<MaybePartial<Curve>>) -> Self {
|
||||
self.curve = curve.into();
|
||||
|
@ -308,9 +308,9 @@ mod tests {
|
||||
let invalid = HalfEdge::new(
|
||||
valid.vertices().clone().try_map_ext(
|
||||
|vertex| -> anyhow::Result<_, ValidationError> {
|
||||
let mut vertex = vertex.to_partial();
|
||||
vertex.position = Some([0.].into());
|
||||
Ok(vertex
|
||||
.to_partial()
|
||||
.with_position(Some([0.]))
|
||||
.infer_surface_form()
|
||||
.build(&objects)?
|
||||
.insert(&objects)?)
|
||||
|
@ -182,7 +182,9 @@ mod tests {
|
||||
builder::{CurveBuilder, SurfaceVertexBuilder},
|
||||
insert::Insert,
|
||||
objects::{GlobalVertex, Objects, SurfaceVertex, Vertex},
|
||||
partial::{HasPartial, PartialCurve, PartialSurfaceVertex},
|
||||
partial::{
|
||||
HasPartial, PartialCurve, PartialSurfaceVertex, PartialVertex,
|
||||
},
|
||||
validate::Validate,
|
||||
};
|
||||
|
||||
@ -196,10 +198,12 @@ mod tests {
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
|
||||
let valid = Vertex::partial()
|
||||
.with_position(Some([0.]))
|
||||
.with_curve(curve)
|
||||
.build(&objects)?;
|
||||
let valid = PartialVertex {
|
||||
position: Some([0.].into()),
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve)
|
||||
.build(&objects)?;
|
||||
let invalid = Vertex::new(valid.position(), valid.curve().clone(), {
|
||||
let mut tmp = valid.surface_form().to_partial();
|
||||
tmp.surface = Some(objects.surfaces.xz_plane());
|
||||
@ -223,10 +227,12 @@ mod tests {
|
||||
};
|
||||
curve.update_as_u_axis();
|
||||
|
||||
Vertex::partial()
|
||||
.with_position(Some([0.]))
|
||||
.with_curve(curve)
|
||||
.build(&objects)?
|
||||
PartialVertex {
|
||||
position: Some([0.].into()),
|
||||
..Default::default()
|
||||
}
|
||||
.with_curve(curve)
|
||||
.build(&objects)?
|
||||
};
|
||||
let invalid = Vertex::new(valid.position(), valid.curve().clone(), {
|
||||
let mut tmp = valid.surface_form().to_partial();
|
||||
|
Loading…
x
Reference in New Issue
Block a user