mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-26 01:56:06 +00:00
Migrate update_boundary
to new trait
This commit is contained in:
parent
671def72bd
commit
e51cd314fd
@ -1,6 +1,11 @@
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
geometry::SurfacePath, objects::HalfEdge, operations::insert::Insert,
|
||||
storage::Handle, Core,
|
||||
geometry::{CurveBoundary, SurfacePath},
|
||||
objects::HalfEdge,
|
||||
operations::insert::Insert,
|
||||
storage::Handle,
|
||||
Core,
|
||||
};
|
||||
|
||||
/// Update the geometry of a [`HalfEdge`]
|
||||
@ -12,6 +17,14 @@ pub trait UpdateHalfEdgeGeometry {
|
||||
update: impl FnOnce(SurfacePath) -> SurfacePath,
|
||||
core: &mut Core,
|
||||
) -> Self;
|
||||
|
||||
/// Update the boundary of the edge
|
||||
#[must_use]
|
||||
fn update_boundary(
|
||||
&self,
|
||||
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
|
||||
core: &mut Core,
|
||||
) -> Self;
|
||||
}
|
||||
|
||||
impl UpdateHalfEdgeGeometry for Handle<HalfEdge> {
|
||||
@ -30,4 +43,18 @@ impl UpdateHalfEdgeGeometry for Handle<HalfEdge> {
|
||||
)
|
||||
.insert(core)
|
||||
}
|
||||
|
||||
fn update_boundary(
|
||||
&self,
|
||||
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
|
||||
core: &mut Core,
|
||||
) -> Self {
|
||||
HalfEdge::new(
|
||||
self.path(),
|
||||
update(self.boundary()),
|
||||
self.curve().clone(),
|
||||
self.start_vertex().clone(),
|
||||
)
|
||||
.insert(core)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,4 @@
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
geometry::CurveBoundary,
|
||||
objects::{Curve, HalfEdge, Vertex},
|
||||
operations::{derive::DeriveFrom, insert::Insert},
|
||||
storage::Handle,
|
||||
@ -10,13 +7,6 @@ use crate::{
|
||||
|
||||
/// Update a [`HalfEdge`]
|
||||
pub trait UpdateHalfEdge {
|
||||
/// Update the boundary of the edge
|
||||
#[must_use]
|
||||
fn update_boundary(
|
||||
&self,
|
||||
update: impl FnOnce(CurveBoundary<Point<1>>) -> CurveBoundary<Point<1>>,
|
||||
) -> Self;
|
||||
|
||||
/// Update the curve of the edge
|
||||
#[must_use]
|
||||
fn update_curve<T>(
|
||||
@ -39,18 +29,6 @@ pub trait UpdateHalfEdge {
|
||||
}
|
||||
|
||||
impl UpdateHalfEdge for HalfEdge {
|
||||
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<T>(
|
||||
&self,
|
||||
update: impl FnOnce(&Handle<Curve>, &mut Core) -> T,
|
||||
|
@ -436,9 +436,10 @@ mod tests {
|
||||
|path| path.reverse(),
|
||||
core,
|
||||
)
|
||||
.update_boundary(|boundary| {
|
||||
boundary.reverse()
|
||||
})]
|
||||
.update_boundary(
|
||||
|boundary| boundary.reverse(),
|
||||
core,
|
||||
)]
|
||||
},
|
||||
core,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user