mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-12 03:06:59 +00:00
Merge pull request #2270 from hannobraun/geometry
Add operation for updating half-edge geometry
This commit is contained in:
commit
795fe382a0
60
crates/fj-core/src/operations/geometry/half_edge.rs
Normal file
60
crates/fj-core/src/operations/geometry/half_edge.rs
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
5
crates/fj-core/src/operations/geometry/mod.rs
Normal file
5
crates/fj-core/src/operations/geometry/mod.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//! Operations to update the geometry of objects
|
||||||
|
|
||||||
|
mod half_edge;
|
||||||
|
|
||||||
|
pub use self::half_edge::UpdateHalfEdgeGeometry;
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
pub mod build;
|
pub mod build;
|
||||||
pub mod derive;
|
pub mod derive;
|
||||||
|
pub mod geometry;
|
||||||
pub mod holes;
|
pub mod holes;
|
||||||
pub mod insert;
|
pub mod insert;
|
||||||
pub mod join;
|
pub mod join;
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use fj_math::Point;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::{CurveBoundary, SurfacePath},
|
|
||||||
objects::{Curve, HalfEdge, Vertex},
|
objects::{Curve, HalfEdge, Vertex},
|
||||||
operations::{derive::DeriveFrom, insert::Insert},
|
operations::{derive::DeriveFrom, insert::Insert},
|
||||||
storage::Handle,
|
storage::Handle,
|
||||||
@ -9,22 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Update a [`HalfEdge`]
|
/// Update a [`HalfEdge`]
|
||||||
pub trait UpdateHalfEdge: Sized {
|
pub trait UpdateHalfEdge {
|
||||||
/// Update the path of the edge
|
|
||||||
#[must_use]
|
|
||||||
fn update_path(
|
|
||||||
&self,
|
|
||||||
update: impl FnOnce(SurfacePath) -> SurfacePath,
|
|
||||||
core: &mut Core,
|
|
||||||
) -> Handle<Self>;
|
|
||||||
|
|
||||||
/// 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>(
|
||||||
@ -47,34 +29,6 @@ pub trait UpdateHalfEdge: Sized {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl UpdateHalfEdge for HalfEdge {
|
impl UpdateHalfEdge for HalfEdge {
|
||||||
fn update_path(
|
|
||||||
&self,
|
|
||||||
update: impl FnOnce(SurfacePath) -> SurfacePath,
|
|
||||||
core: &mut Core,
|
|
||||||
) -> Handle<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>>,
|
|
||||||
) -> 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,
|
||||||
|
@ -403,6 +403,7 @@ mod tests {
|
|||||||
objects::{Curve, Shell},
|
objects::{Curve, Shell},
|
||||||
operations::{
|
operations::{
|
||||||
build::BuildShell,
|
build::BuildShell,
|
||||||
|
geometry::UpdateHalfEdgeGeometry,
|
||||||
update::{
|
update::{
|
||||||
UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion,
|
UpdateCycle, UpdateFace, UpdateHalfEdge, UpdateRegion,
|
||||||
UpdateShell,
|
UpdateShell,
|
||||||
@ -435,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