Skip to content

Commit

Permalink
Add some second-order implementations of Get
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 16, 2022
1 parent 9ad3c35 commit 44028e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/fj-kernel/src/objects/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ impl Get<GlobalEdge> for HalfEdge {
}
}

impl Get<GlobalCurve> for HalfEdge {
fn get(&self) -> Handle<GlobalCurve> {
self.global_form().curve().clone()
}
}

impl fmt::Display for HalfEdge {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let [a, b] = self.vertices().clone().map(|vertex| vertex.position());
Expand Down
20 changes: 19 additions & 1 deletion crates/fj-kernel/src/objects/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_math::Point;

use crate::{get::Get, storage::Handle};

use super::{Curve, Surface};
use super::{Curve, GlobalCurve, Surface};

/// A vertex
///
Expand Down Expand Up @@ -68,6 +68,24 @@ impl Get<SurfaceVertex> for Vertex {
}
}

impl Get<Surface> for Vertex {
fn get(&self) -> Handle<Surface> {
self.curve().surface().clone()
}
}

impl Get<GlobalCurve> for Vertex {
fn get(&self) -> Handle<GlobalCurve> {
self.curve().global_form().clone()
}
}

impl Get<GlobalVertex> for Vertex {
fn get(&self) -> Handle<GlobalVertex> {
self.surface_form().global_form().clone()
}
}

/// A vertex, defined in surface (2D) coordinates
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceVertex {
Expand Down

0 comments on commit 44028e2

Please sign in to comment.