Update builder method

This commit is contained in:
Hanno Braun 2022-11-11 16:53:02 +01:00
parent 6f8f06f261
commit 674d33a6ba
2 changed files with 16 additions and 16 deletions

View File

@ -3,12 +3,9 @@ use iter_fixed::IntoIteratorFixed;
use crate::{ use crate::{
insert::Insert, insert::Insert,
objects::{ objects::{Curve, Objects, Surface, Vertex, VerticesInNormalizedOrder},
Curve, GlobalVertex, Objects, Surface, Vertex,
VerticesInNormalizedOrder,
},
partial::{ partial::{
HasPartial, MaybePartial, PartialCurve, PartialGlobalEdge, MaybePartial, PartialCurve, PartialGlobalEdge, PartialGlobalVertex,
PartialHalfEdge, PartialSurfaceVertex, PartialVertex, PartialHalfEdge, PartialSurfaceVertex, PartialVertex,
}, },
storage::Handle, storage::Handle,
@ -82,10 +79,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {
.vertices() .vertices()
.map(|[global_form, _]| global_form) .map(|[global_form, _]| global_form)
.unwrap_or_else(|| { .unwrap_or_else(|| {
let mut global_vertex = GlobalVertex::partial(); PartialGlobalVertex::from_curve_and_position(
global_vertex curve.clone(),
.update_from_curve_and_position(curve.clone(), a_curve); a_curve,
global_vertex.into() )
.into()
}); });
let surface_vertex = PartialSurfaceVertex { let surface_vertex = PartialSurfaceVertex {

View File

@ -37,11 +37,10 @@ impl SurfaceVertexBuilder for PartialSurfaceVertex {
/// Builder API for [`PartialGlobalVertex`] /// Builder API for [`PartialGlobalVertex`]
pub trait GlobalVertexBuilder { pub trait GlobalVertexBuilder {
/// Update partial global vertex from the given curve and position on it /// Update partial global vertex from the given curve and position on it
fn update_from_curve_and_position( fn from_curve_and_position(
&mut self,
curve: impl Into<MaybePartial<Curve>>, curve: impl Into<MaybePartial<Curve>>,
position: impl Into<Point<1>>, position: impl Into<Point<1>>,
) -> &mut Self; ) -> Self;
/// Update partial global vertex from the given surface and position on it /// Update partial global vertex from the given surface and position on it
fn update_from_surface_and_position( fn update_from_surface_and_position(
@ -52,11 +51,10 @@ pub trait GlobalVertexBuilder {
} }
impl GlobalVertexBuilder for PartialGlobalVertex { impl GlobalVertexBuilder for PartialGlobalVertex {
fn update_from_curve_and_position( fn from_curve_and_position(
&mut self,
curve: impl Into<MaybePartial<Curve>>, curve: impl Into<MaybePartial<Curve>>,
position: impl Into<Point<1>>, position: impl Into<Point<1>>,
) -> &mut Self { ) -> Self {
let curve = curve.into().into_partial(); let curve = curve.into().into_partial();
let path = curve.path.expect( let path = curve.path.expect(
@ -67,7 +65,11 @@ impl GlobalVertexBuilder for PartialGlobalVertex {
); );
let position_surface = path.point_from_path_coords(position); let position_surface = path.point_from_path_coords(position);
self.update_from_surface_and_position(&surface, position_surface)
let mut global_vertex = PartialGlobalVertex::default();
global_vertex
.update_from_surface_and_position(&surface, position_surface);
global_vertex
} }
fn update_from_surface_and_position( fn update_from_surface_and_position(