Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete UpdateHalfEdge #1975

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/fj-core/src/operations/update/edge.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
use fj_math::Point;

use crate::{
geometry::{CurveBoundary, SurfacePath},
objects::{Curve, GlobalEdge, HalfEdge, Vertex},
storage::Handle,
};

/// Update a [`HalfEdge`]
pub trait UpdateHalfEdge {
/// Replace the path of the half-edge
#[must_use]
fn replace_path(&self, path: SurfacePath) -> Self;

/// Replace the boundary of the half-edge
#[must_use]
fn replace_boundary(&self, boundary: CurveBoundary<Point<1>>) -> Self;

/// Replace the curve of the half-edge
#[must_use]
fn replace_curve(&self, curve: Handle<Curve>) -> Self;
Expand All @@ -19,6 +30,26 @@ pub trait UpdateHalfEdge {
}

impl UpdateHalfEdge for HalfEdge {
fn replace_path(&self, path: SurfacePath) -> Self {
HalfEdge::new(
path,
self.boundary(),
self.curve().clone(),
self.start_vertex().clone(),
self.global_form().clone(),
)
}

fn replace_boundary(&self, boundary: CurveBoundary<Point<1>>) -> Self {
HalfEdge::new(
self.path(),
boundary,
self.curve().clone(),
self.start_vertex().clone(),
self.global_form().clone(),
)
}

fn replace_curve(&self, curve: Handle<Curve>) -> Self {
HalfEdge::new(
self.path(),
Expand Down