-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2270 from hannobraun/geometry
Add operation for updating half-edge geometry
- Loading branch information
Showing
5 changed files
with
72 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use fj_math::Point; | ||
|
||
use crate::{ | ||
geometry::{CurveBoundary, SurfacePath}, | ||
objects::HalfEdge, | ||
operations::insert::Insert, | ||
storage::Handle, | ||
Core, | ||
}; | ||
|
||
/// Update the geometry of a [`HalfEdge`] | ||
pub trait UpdateHalfEdgeGeometry { | ||
/// Update the path of the edge | ||
#[must_use] | ||
fn update_path( | ||
&self, | ||
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> { | ||
fn update_path( | ||
&self, | ||
update: impl FnOnce(SurfacePath) -> SurfacePath, | ||
core: &mut Core, | ||
) -> Self { | ||
let path = update(self.path()); | ||
|
||
HalfEdge::new( | ||
path, | ||
self.boundary(), | ||
self.curve().clone(), | ||
self.start_vertex().clone(), | ||
) | ||
.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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! Operations to update the geometry of objects | ||
mod half_edge; | ||
|
||
pub use self::half_edge::UpdateHalfEdgeGeometry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
pub mod build; | ||
pub mod derive; | ||
pub mod geometry; | ||
pub mod holes; | ||
pub mod insert; | ||
pub mod join; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters