use fj_math::Point;
use crate::{
geometry::{CurveBoundary, SurfacePath},
objects::{Curve, HalfEdge, Vertex},
storage::Handle,
};
pub trait UpdateHalfEdge {
#[must_use]
fn update_path(
&self,
update: impl FnOnce(SurfacePath) -> SurfacePath,
) -> Self;
#[must_use]
fn update_boundary(
&self,
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
) -> Self;
#[must_use]
fn update_curve(
&self,
update: impl FnOnce(&Handle<Curve>) -> Handle<Curve>,
) -> Self;
#[must_use]
fn update_start_vertex(
&self,
update: impl FnOnce(&Handle<Vertex>) -> Handle<Vertex>,
) -> Self;
}
impl UpdateHalfEdge for HalfEdge {
fn update_path(
&self,
update: impl FnOnce(SurfacePath) -> SurfacePath,
) -> Self {
HalfEdge::new(
update(self.path()),
self.boundary(),
self.curve().clone(),
self.start_vertex().clone(),
)
}
fn update_boundary(
&self,
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
) -> Self {
HalfEdge::new(
self.path(),
update(self.boundary()),
self.curve().clone(),
self.start_vertex().clone(),
)
}
fn update_curve(
&self,
update: impl FnOnce(&Handle<Curve>) -> Handle<Curve>,
) -> Self {
HalfEdge::new(
self.path(),
self.boundary(),
update(self.curve()),
self.start_vertex().clone(),
)
}
fn update_start_vertex(
&self,
update: impl FnOnce(&Handle<Vertex>) -> Handle<Vertex>,
) -> Self {
HalfEdge::new(
self.path(),
self.boundary(),
self.curve().clone(),
update(self.start_vertex()),
)
}
}