Return Handle from UpdateHalfEdge::update_path

This commit is contained in:
Hanno Braun 2024-03-14 14:29:13 +01:00
parent 34ce68d89f
commit f8038849d9
2 changed files with 11 additions and 5 deletions

View File

@ -9,13 +9,14 @@ use crate::{
}; };
/// Update a [`HalfEdge`] /// Update a [`HalfEdge`]
pub trait UpdateHalfEdge { pub trait UpdateHalfEdge: Sized {
/// Update the path of the edge /// Update the path of the edge
#[must_use] #[must_use]
fn update_path( fn update_path(
&self, &self,
update: impl FnOnce(SurfacePath) -> SurfacePath, update: impl FnOnce(SurfacePath) -> SurfacePath,
) -> Self; core: &mut Core,
) -> Handle<Self>;
/// Update the boundary of the edge /// Update the boundary of the edge
#[must_use] #[must_use]
@ -49,13 +50,15 @@ impl UpdateHalfEdge for HalfEdge {
fn update_path( fn update_path(
&self, &self,
update: impl FnOnce(SurfacePath) -> SurfacePath, update: impl FnOnce(SurfacePath) -> SurfacePath,
) -> Self { core: &mut Core,
) -> Handle<Self> {
HalfEdge::new( HalfEdge::new(
update(self.path()), update(self.path()),
self.boundary(), self.boundary(),
self.curve().clone(), self.curve().clone(),
self.start_vertex().clone(), self.start_vertex().clone(),
) )
.insert(core)
} }
fn update_boundary( fn update_boundary(

View File

@ -429,9 +429,12 @@ mod tests {
|cycle, core| { |cycle, core| {
cycle.update_half_edge( cycle.update_half_edge(
cycle.half_edges().nth_circular(0), cycle.half_edges().nth_circular(0),
|edge, _| { |edge, core| {
[edge [edge
.update_path(|path| path.reverse()) .update_path(
|path| path.reverse(),
core,
)
.update_boundary(|boundary| { .update_boundary(|boundary| {
boundary.reverse() boundary.reverse()
})] })]