mirror of https://github.com/hannobraun/Fornjot
Move non-essential methods to builder trait
This commit is contained in:
parent
aeb686c5cd
commit
e24c56b69a
|
@ -6,7 +6,7 @@ use crate::{
|
||||||
Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex,
|
Curve, GlobalVertex, Objects, Surface, SurfaceVertex, Vertex,
|
||||||
VerticesInNormalizedOrder,
|
VerticesInNormalizedOrder,
|
||||||
},
|
},
|
||||||
partial::{HasPartial, PartialGlobalEdge, PartialHalfEdge},
|
partial::{HasPartial, MaybePartial, PartialGlobalEdge, PartialHalfEdge},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,12 @@ use super::{CurveBuilder, GlobalVertexBuilder};
|
||||||
|
|
||||||
/// Builder API for [`PartialHalfEdge`]
|
/// Builder API for [`PartialHalfEdge`]
|
||||||
pub trait HalfEdgeBuilder: Sized {
|
pub trait HalfEdgeBuilder: Sized {
|
||||||
|
/// Update the partial half-edge with the given back vertex
|
||||||
|
fn with_back_vertex(self, back: impl Into<MaybePartial<Vertex>>) -> Self;
|
||||||
|
|
||||||
|
/// Update the partial half-edge with the given front vertex
|
||||||
|
fn with_front_vertex(self, front: impl Into<MaybePartial<Vertex>>) -> Self;
|
||||||
|
|
||||||
/// Update partial half-edge as a circle, from the given radius
|
/// Update partial half-edge as a circle, from the given radius
|
||||||
///
|
///
|
||||||
/// # Implementation Note
|
/// # Implementation Note
|
||||||
|
@ -40,6 +46,16 @@ pub trait HalfEdgeBuilder: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HalfEdgeBuilder for PartialHalfEdge {
|
impl HalfEdgeBuilder for PartialHalfEdge {
|
||||||
|
fn with_back_vertex(self, back: impl Into<MaybePartial<Vertex>>) -> Self {
|
||||||
|
let [_, front] = self.vertices();
|
||||||
|
self.with_vertices([back.into(), front])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_front_vertex(self, front: impl Into<MaybePartial<Vertex>>) -> Self {
|
||||||
|
let [back, _] = self.vertices();
|
||||||
|
self.with_vertices([back, front.into()])
|
||||||
|
}
|
||||||
|
|
||||||
fn update_as_circle_from_radius(
|
fn update_as_circle_from_radius(
|
||||||
self,
|
self,
|
||||||
radius: impl Into<Scalar>,
|
radius: impl Into<Scalar>,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
builder::HalfEdgeBuilder,
|
||||||
objects::{Cycle, HalfEdge, Objects, Surface},
|
objects::{Cycle, HalfEdge, Objects, Surface},
|
||||||
partial::{
|
partial::{
|
||||||
util::merge_options, MaybePartial, PartialHalfEdge, PartialVertex,
|
util::merge_options, MaybePartial, PartialHalfEdge, PartialVertex,
|
||||||
|
|
|
@ -73,28 +73,6 @@ impl PartialHalfEdge {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the partial half-edge with the given back vertex
|
|
||||||
pub fn with_back_vertex(
|
|
||||||
mut self,
|
|
||||||
vertex: impl Into<MaybePartial<Vertex>>,
|
|
||||||
) -> Self {
|
|
||||||
let [from, _] = &mut self.vertices;
|
|
||||||
*from = vertex.into();
|
|
||||||
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update the partial half-edge with the given front vertex
|
|
||||||
pub fn with_front_vertex(
|
|
||||||
mut self,
|
|
||||||
vertex: impl Into<MaybePartial<Vertex>>,
|
|
||||||
) -> Self {
|
|
||||||
let [_, to] = &mut self.vertices;
|
|
||||||
*to = vertex.into();
|
|
||||||
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Update the partial half-edge with the given vertices
|
/// Update the partial half-edge with the given vertices
|
||||||
pub fn with_vertices(
|
pub fn with_vertices(
|
||||||
mut self,
|
mut self,
|
||||||
|
|
Loading…
Reference in New Issue