Skip to content

Commit

Permalink
Implement TransformObject for PartialHalfEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Oct 5, 2022
1 parent f4d85d6 commit 5ec0558
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion crates/fj-kernel/src/algorithms/transform/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_math::Transform;

use crate::{
objects::{GlobalEdge, HalfEdge},
partial::{HasPartial, PartialGlobalEdge},
partial::{HasPartial, PartialGlobalEdge, PartialHalfEdge},
stores::Stores,
};

Expand Down Expand Up @@ -45,6 +45,43 @@ impl TransformObject for GlobalEdge {
}
}

impl TransformObject for PartialHalfEdge {
fn transform(self, transform: &Transform, stores: &Stores) -> Self {
let curve = self
.curve
.clone()
.map(|curve| curve.transform(transform, stores));
let vertices = self.vertices.clone().map(|vertices| {
vertices.map(|vertex| {
let vertex = vertex.into_partial().transform(transform, stores);
let vertex = match &curve {
Some(curve) => vertex.with_curve(curve.clone()),
None => vertex,
};
vertex.into()
})
});
let global_form = self.global_form.map(|global_form| {
let global_form =
global_form.into_partial().transform(transform, stores);

let curve = curve.as_ref().and_then(|curve| curve.global_form());
let global_form = match curve {
Some(curve) => global_form.with_curve(curve),
None => global_form,
};

global_form.into()
});

Self {
curve,
vertices,
global_form,
}
}
}

impl TransformObject for PartialGlobalEdge {
fn transform(self, transform: &Transform, stores: &Stores) -> Self {
let curve =
Expand Down

0 comments on commit 5ec0558

Please sign in to comment.