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