-
-
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 #1151 from hannobraun/ready/transform
Clean up `algorithms::transform`
- Loading branch information
Showing
13 changed files
with
270 additions
and
250 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
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
use fj_math::Transform; | ||
|
||
use crate::{ | ||
objects::{Curve, GlobalCurve}, | ||
stores::{Handle, Stores}, | ||
}; | ||
|
||
use super::TransformObject; | ||
|
||
impl TransformObject for Curve { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
let surface = self.surface().transform(transform, stores); | ||
let global_form = | ||
self.global_form().clone().transform(transform, stores); | ||
|
||
// Don't need to transform `self.path`, as that's defined in surface | ||
// coordinates, and thus transforming `surface` takes care of it. | ||
Self::new(surface, self.path(), global_form) | ||
} | ||
} | ||
|
||
impl TransformObject for Handle<GlobalCurve> { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
stores.global_curves.insert(GlobalCurve::from_path( | ||
self.path().transform(transform, stores), | ||
)) | ||
} | ||
} |
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,15 @@ | ||
use fj_math::Transform; | ||
|
||
use crate::{objects::Cycle, stores::Stores}; | ||
|
||
use super::TransformObject; | ||
|
||
impl TransformObject for Cycle { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
Self::new( | ||
self.surface().transform(transform, stores), | ||
self.into_half_edges() | ||
.map(|edge| edge.transform(transform, stores)), | ||
) | ||
} | ||
} |
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,33 @@ | ||
use fj_math::Transform; | ||
|
||
use crate::{ | ||
objects::{GlobalEdge, HalfEdge}, | ||
stores::Stores, | ||
}; | ||
|
||
use super::TransformObject; | ||
|
||
impl TransformObject for HalfEdge { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
let curve = self.curve().clone().transform(transform, stores); | ||
let vertices = self | ||
.vertices() | ||
.clone() | ||
.map(|vertex| vertex.transform(transform, stores)); | ||
let global_form = | ||
self.global_form().clone().transform(transform, stores); | ||
|
||
Self::new(curve, vertices, global_form) | ||
} | ||
} | ||
|
||
impl TransformObject for GlobalEdge { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
let curve = self.curve().clone().transform(transform, stores); | ||
let vertices = self | ||
.vertices() | ||
.map(|vertex| vertex.transform(transform, stores)); | ||
|
||
Self::new(curve, vertices) | ||
} | ||
} |
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,34 @@ | ||
use fj_math::Transform; | ||
|
||
use crate::{ | ||
objects::{Face, Faces}, | ||
stores::Stores, | ||
}; | ||
|
||
use super::TransformObject; | ||
|
||
impl TransformObject for Face { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
let exterior = self.exterior().clone().transform(transform, stores); | ||
let interiors = self | ||
.interiors() | ||
.map(|cycle| cycle.clone().transform(transform, stores)); | ||
|
||
let color = self.color(); | ||
|
||
Face::from_exterior(exterior) | ||
.with_interiors(interiors) | ||
.with_color(color) | ||
} | ||
} | ||
|
||
impl TransformObject for Faces { | ||
fn transform(self, transform: &Transform, stores: &Stores) -> Self { | ||
let mut faces = Faces::new(); | ||
faces.extend( | ||
self.into_iter() | ||
.map(|face| face.transform(transform, stores)), | ||
); | ||
faces | ||
} | ||
} |
Oops, something went wrong.