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