From aaa613ec2ec973b58d39e849ec3599141f475cad Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Sun, 6 Nov 2022 08:47:01 +0100 Subject: [PATCH] Simplify `GlobalPath` transforms It's not an object, so it doesn't make much sense to include it with the transformation infrastructure of objects. --- .../fj-kernel/src/algorithms/transform/mod.rs | 1 - .../src/algorithms/transform/path.rs | 22 ------------------- .../src/algorithms/transform/surface.rs | 2 +- crates/fj-kernel/src/path.rs | 13 ++++++++++- 4 files changed, 13 insertions(+), 25 deletions(-) delete mode 100644 crates/fj-kernel/src/algorithms/transform/path.rs diff --git a/crates/fj-kernel/src/algorithms/transform/mod.rs b/crates/fj-kernel/src/algorithms/transform/mod.rs index c8d831468..f262a2750 100644 --- a/crates/fj-kernel/src/algorithms/transform/mod.rs +++ b/crates/fj-kernel/src/algorithms/transform/mod.rs @@ -4,7 +4,6 @@ mod curve; mod cycle; mod edge; mod face; -mod path; mod shell; mod sketch; mod solid; diff --git a/crates/fj-kernel/src/algorithms/transform/path.rs b/crates/fj-kernel/src/algorithms/transform/path.rs deleted file mode 100644 index 1f15d3321..000000000 --- a/crates/fj-kernel/src/algorithms/transform/path.rs +++ /dev/null @@ -1,22 +0,0 @@ -use fj_math::Transform; - -use crate::{objects::Objects, path::GlobalPath, validate::ValidationError}; - -use super::TransformObject; - -impl TransformObject for GlobalPath { - fn transform( - self, - transform: &Transform, - _: &Objects, - ) -> Result { - match self { - Self::Circle(curve) => { - Ok(Self::Circle(transform.transform_circle(&curve))) - } - Self::Line(curve) => { - Ok(Self::Line(transform.transform_line(&curve))) - } - } - } -} diff --git a/crates/fj-kernel/src/algorithms/transform/surface.rs b/crates/fj-kernel/src/algorithms/transform/surface.rs index 61edf94fd..f05007520 100644 --- a/crates/fj-kernel/src/algorithms/transform/surface.rs +++ b/crates/fj-kernel/src/algorithms/transform/surface.rs @@ -15,7 +15,7 @@ impl TransformObject for Handle { objects: &Objects, ) -> Result { Ok(objects.surfaces.insert(Surface::new( - self.u().transform(transform, objects)?, + self.u().transform(transform), transform.transform_vector(&self.v()), ))?) } diff --git a/crates/fj-kernel/src/path.rs b/crates/fj-kernel/src/path.rs index 16e01a6b4..a4b7a528b 100644 --- a/crates/fj-kernel/src/path.rs +++ b/crates/fj-kernel/src/path.rs @@ -22,7 +22,7 @@ //! [`Surface`]: crate::objects::Surface //! [#1021]: https://github.com/hannobraun/Fornjot/issues/1021 -use fj_math::{Circle, Line, Point, Scalar, Vector}; +use fj_math::{Circle, Line, Point, Scalar, Transform, Vector}; /// A path through surface (2D) space #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] @@ -141,4 +141,15 @@ impl GlobalPath { Self::Line(line) => line.vector_from_line_coords(vector), } } + + /// Transform the path + #[must_use] + pub fn transform(self, transform: &Transform) -> Self { + match self { + Self::Circle(curve) => { + Self::Circle(transform.transform_circle(&curve)) + } + Self::Line(curve) => Self::Line(transform.transform_line(&curve)), + } + } }