From de67dd4a5f13b2672cbaf7471f1c84249b9aa44d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:13:43 +0200 Subject: [PATCH 1/6] Move `fj::Transform` to dedicated module --- crates/fj/src/lib.rs | 3 ++- crates/fj/src/shape_3d.rs | 40 +----------------------------------- crates/fj/src/transform.rs | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 40 deletions(-) create mode 100644 crates/fj/src/transform.rs diff --git a/crates/fj/src/lib.rs b/crates/fj/src/lib.rs index 945f4bede..28dbc1d40 100644 --- a/crates/fj/src/lib.rs +++ b/crates/fj/src/lib.rs @@ -23,8 +23,9 @@ pub mod syntax; mod angle; mod shape_2d; mod shape_3d; +mod transform; -pub use self::{angle::*, shape_2d::*, shape_3d::*}; +pub use self::{angle::*, shape_2d::*, shape_3d::*, transform::Transform}; pub use fj_proc::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/crates/fj/src/shape_3d.rs b/crates/fj/src/shape_3d.rs index 90c95a71b..879f0e8f7 100644 --- a/crates/fj/src/shape_3d.rs +++ b/crates/fj/src/shape_3d.rs @@ -1,4 +1,4 @@ -use crate::{Angle, Shape, Shape2d}; +use crate::{Shape, Shape2d, Transform}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -54,44 +54,6 @@ impl From for Shape3d { } } -/// A transformed 3-dimensional shape -/// -/// # Limitations -/// -/// Transformations are currently limited to a rotation, followed by a -/// translation. -/// -/// See issue: -/// -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[repr(C)] -pub struct Transform { - /// The shape being transformed - pub shape: Shape3d, - - /// The axis of the rotation - pub axis: [f64; 3], - - /// The angle of the rotation - pub angle: Angle, - - /// The offset of the translation - pub offset: [f64; 3], -} - -impl From for Shape { - fn from(shape: Transform) -> Self { - Self::Shape3d(Shape3d::Transform(Box::new(shape))) - } -} - -impl From for Shape3d { - fn from(shape: Transform) -> Self { - Self::Transform(Box::new(shape)) - } -} - /// A sweep of a 2-dimensional shape along straight path #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] diff --git a/crates/fj/src/transform.rs b/crates/fj/src/transform.rs new file mode 100644 index 000000000..7cc96312d --- /dev/null +++ b/crates/fj/src/transform.rs @@ -0,0 +1,42 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use crate::{Angle, Shape, Shape3d}; + +/// A transformed 3-dimensional shape +/// +/// # Limitations +/// +/// Transformations are currently limited to a rotation, followed by a +/// translation. +/// +/// See issue: +/// +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[repr(C)] +pub struct Transform { + /// The shape being transformed + pub shape: Shape3d, + + /// The axis of the rotation + pub axis: [f64; 3], + + /// The angle of the rotation + pub angle: Angle, + + /// The offset of the translation + pub offset: [f64; 3], +} + +impl From for Shape { + fn from(shape: Transform) -> Self { + Self::Shape3d(Shape3d::Transform(Box::new(shape))) + } +} + +impl From for Shape3d { + fn from(shape: Transform) -> Self { + Self::Transform(Box::new(shape)) + } +} From b20fdf8267d27185d0d412c10cb7d2db92491466 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:17:20 +0200 Subject: [PATCH 2/6] Move `fj::Group` to dedicated module --- crates/fj/src/group.rs | 35 +++++++++++++++++++++++++++++++++++ crates/fj/src/lib.rs | 5 ++++- crates/fj/src/shape_3d.rs | 33 +-------------------------------- 3 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 crates/fj/src/group.rs diff --git a/crates/fj/src/group.rs b/crates/fj/src/group.rs new file mode 100644 index 000000000..ecab09070 --- /dev/null +++ b/crates/fj/src/group.rs @@ -0,0 +1,35 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use crate::{Shape, Shape3d}; + +/// A group of two 3-dimensional shapes +/// +/// A group is a collection of disjoint shapes. It is not a union, in that the +/// shapes in the group are not allowed to touch or overlap. +/// +/// # Limitations +/// +/// Whether the shapes in the group touch or overlap is not currently checked. +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[repr(C)] +pub struct Group { + /// The first of the shapes + pub a: Shape3d, + + /// The second of the shapes + pub b: Shape3d, +} + +impl From for Shape { + fn from(shape: Group) -> Self { + Self::Shape3d(Shape3d::Group(Box::new(shape))) + } +} + +impl From for Shape3d { + fn from(shape: Group) -> Self { + Self::Group(Box::new(shape)) + } +} diff --git a/crates/fj/src/lib.rs b/crates/fj/src/lib.rs index 28dbc1d40..3e286152e 100644 --- a/crates/fj/src/lib.rs +++ b/crates/fj/src/lib.rs @@ -21,11 +21,14 @@ pub mod syntax; mod angle; +mod group; mod shape_2d; mod shape_3d; mod transform; -pub use self::{angle::*, shape_2d::*, shape_3d::*, transform::Transform}; +pub use self::{ + angle::*, group::Group, shape_2d::*, shape_3d::*, transform::Transform, +}; pub use fj_proc::*; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/crates/fj/src/shape_3d.rs b/crates/fj/src/shape_3d.rs index 879f0e8f7..3bf6b3d2f 100644 --- a/crates/fj/src/shape_3d.rs +++ b/crates/fj/src/shape_3d.rs @@ -1,4 +1,4 @@ -use crate::{Shape, Shape2d, Transform}; +use crate::{Group, Shape, Shape2d, Transform}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -23,37 +23,6 @@ impl From for Shape { } } -/// A group of two 3-dimensional shapes -/// -/// A group is a collection of disjoint shapes. It is not a union, in that the -/// shapes in the group are not allowed to touch or overlap. -/// -/// # Limitations -/// -/// Whether the shapes in the group touch or overlap is not currently checked. -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[repr(C)] -pub struct Group { - /// The first of the shapes - pub a: Shape3d, - - /// The second of the shapes - pub b: Shape3d, -} - -impl From for Shape { - fn from(shape: Group) -> Self { - Self::Shape3d(Shape3d::Group(Box::new(shape))) - } -} - -impl From for Shape3d { - fn from(shape: Group) -> Self { - Self::Group(Box::new(shape)) - } -} - /// A sweep of a 2-dimensional shape along straight path #[derive(Clone, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] From 814bc60e4293a473d51a848f7c6ed69a5e34d7df Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:19:13 +0200 Subject: [PATCH 3/6] Move `fj::Sweep` to dedicated module --- crates/fj/src/lib.rs | 4 +++- crates/fj/src/shape_3d.rs | 43 +------------------------------------ crates/fj/src/sweep.rs | 45 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 43 deletions(-) create mode 100644 crates/fj/src/sweep.rs diff --git a/crates/fj/src/lib.rs b/crates/fj/src/lib.rs index 3e286152e..297b9c41e 100644 --- a/crates/fj/src/lib.rs +++ b/crates/fj/src/lib.rs @@ -24,10 +24,12 @@ mod angle; mod group; mod shape_2d; mod shape_3d; +mod sweep; mod transform; pub use self::{ - angle::*, group::Group, shape_2d::*, shape_3d::*, transform::Transform, + angle::*, group::Group, shape_2d::*, shape_3d::*, sweep::Sweep, + transform::Transform, }; pub use fj_proc::*; #[cfg(feature = "serde")] diff --git a/crates/fj/src/shape_3d.rs b/crates/fj/src/shape_3d.rs index 3bf6b3d2f..c7ed8cac8 100644 --- a/crates/fj/src/shape_3d.rs +++ b/crates/fj/src/shape_3d.rs @@ -1,4 +1,4 @@ -use crate::{Group, Shape, Shape2d, Transform}; +use crate::{Group, Shape, Sweep, Transform}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; @@ -22,44 +22,3 @@ impl From for Shape { Self::Shape3d(shape) } } - -/// A sweep of a 2-dimensional shape along straight path -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[repr(C)] -pub struct Sweep { - /// The 2-dimensional shape being swept - shape: Shape2d, - - /// The length and direction of the sweep - path: [f64; 3], -} - -impl Sweep { - /// Create a `Sweep` along a straight path - pub fn from_path(shape: Shape2d, path: [f64; 3]) -> Self { - Self { shape, path } - } - - /// Access the shape being swept - pub fn shape(&self) -> &Shape2d { - &self.shape - } - - /// Access the path of the sweep - pub fn path(&self) -> [f64; 3] { - self.path - } -} - -impl From for Shape { - fn from(shape: Sweep) -> Self { - Self::Shape3d(shape.into()) - } -} - -impl From for Shape3d { - fn from(shape: Sweep) -> Self { - Self::Sweep(shape) - } -} diff --git a/crates/fj/src/sweep.rs b/crates/fj/src/sweep.rs new file mode 100644 index 000000000..1ff50d50a --- /dev/null +++ b/crates/fj/src/sweep.rs @@ -0,0 +1,45 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +use crate::{Shape, Shape2d, Shape3d}; + +/// A sweep of a 2-dimensional shape along straight path +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[repr(C)] +pub struct Sweep { + /// The 2-dimensional shape being swept + shape: Shape2d, + + /// The length and direction of the sweep + path: [f64; 3], +} + +impl Sweep { + /// Create a `Sweep` along a straight path + pub fn from_path(shape: Shape2d, path: [f64; 3]) -> Self { + Self { shape, path } + } + + /// Access the shape being swept + pub fn shape(&self) -> &Shape2d { + &self.shape + } + + /// Access the path of the sweep + pub fn path(&self) -> [f64; 3] { + self.path + } +} + +impl From for Shape { + fn from(shape: Sweep) -> Self { + Self::Shape3d(shape.into()) + } +} + +impl From for Shape3d { + fn from(shape: Sweep) -> Self { + Self::Sweep(shape) + } +} From d2c6f1ad6889103a6e89f3dd439870045f02ba47 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:37:06 +0200 Subject: [PATCH 4/6] Merge `fj::Shape3d` into `fj::Shape` The distinction is overly restrictive, as it prevents the transform and group operations from working on 2D shapes. --- crates/fj-operations/src/group.rs | 4 +- crates/fj-operations/src/lib.rs | 53 ++++++++++----------------- crates/fj-operations/src/transform.rs | 9 +++-- crates/fj/src/group.rs | 12 ++---- crates/fj/src/lib.rs | 14 ++++--- crates/fj/src/shape_3d.rs | 24 ------------ crates/fj/src/sweep.rs | 8 +--- crates/fj/src/syntax.rs | 8 ++-- crates/fj/src/transform.rs | 10 +---- models/test/src/lib.rs | 4 +- 10 files changed, 47 insertions(+), 99 deletions(-) delete mode 100644 crates/fj/src/shape_3d.rs diff --git a/crates/fj-operations/src/group.rs b/crates/fj-operations/src/group.rs index 68096cc9c..2607818af 100644 --- a/crates/fj-operations/src/group.rs +++ b/crates/fj-operations/src/group.rs @@ -22,8 +22,8 @@ impl Shape for fj::Group { let a = self.a.compute_brep(config, tolerance, debug_info)?; let b = self.b.compute_brep(config, tolerance, debug_info)?; - faces.extend(a.into_inner().into_faces()); - faces.extend(b.into_inner().into_faces()); + faces.extend(a.into_inner()); + faces.extend(b.into_inner()); let group = Solid::from_faces(faces); validate(group, config) diff --git a/crates/fj-operations/src/lib.rs b/crates/fj-operations/src/lib.rs index 0384c4027..68eb8561f 100644 --- a/crates/fj-operations/src/lib.rs +++ b/crates/fj-operations/src/lib.rs @@ -27,7 +27,7 @@ mod transform; use fj_interop::debug::DebugInfo; use fj_kernel::{ algorithms::Tolerance, - objects::{Face, Sketch, Solid}, + objects::{Face, Sketch}, validation::{validate, Validated, ValidationConfig, ValidationError}, }; use fj_math::Aabb; @@ -69,7 +69,21 @@ impl Shape for fj::Shape { .into_faces(), config, ), - Self::Shape3d(shape) => validate( + Self::Group(shape) => validate( + shape + .compute_brep(config, tolerance, debug_info)? + .into_inner() + .into_faces(), + config, + ), + Self::Sweep(shape) => validate( + shape + .compute_brep(config, tolerance, debug_info)? + .into_inner() + .into_faces(), + config, + ), + Self::Transform(shape) => validate( shape .compute_brep(config, tolerance, debug_info)? .into_inner() @@ -82,7 +96,9 @@ impl Shape for fj::Shape { fn bounding_volume(&self) -> Aabb<3> { match self { Self::Shape2d(shape) => shape.bounding_volume(), - Self::Shape3d(shape) => shape.bounding_volume(), + Self::Group(shape) => shape.bounding_volume(), + Self::Sweep(shape) => shape.bounding_volume(), + Self::Transform(shape) => shape.bounding_volume(), } } } @@ -113,34 +129,3 @@ impl Shape for fj::Shape2d { } } } - -impl Shape for fj::Shape3d { - type Brep = Solid; - - fn compute_brep( - &self, - config: &ValidationConfig, - tolerance: Tolerance, - debug_info: &mut DebugInfo, - ) -> Result, ValidationError> { - match self { - Self::Group(shape) => { - shape.compute_brep(config, tolerance, debug_info) - } - Self::Sweep(shape) => { - shape.compute_brep(config, tolerance, debug_info) - } - Self::Transform(shape) => { - shape.compute_brep(config, tolerance, debug_info) - } - } - } - - fn bounding_volume(&self) -> Aabb<3> { - match self { - Self::Group(shape) => shape.bounding_volume(), - Self::Sweep(shape) => shape.bounding_volume(), - Self::Transform(shape) => shape.bounding_volume(), - } - } -} diff --git a/crates/fj-operations/src/transform.rs b/crates/fj-operations/src/transform.rs index ef3fb5fba..3667323a9 100644 --- a/crates/fj-operations/src/transform.rs +++ b/crates/fj-operations/src/transform.rs @@ -17,10 +17,11 @@ impl Shape for fj::Transform { tolerance: Tolerance, debug_info: &mut DebugInfo, ) -> Result, ValidationError> { - let original = self - .shape - .compute_brep(config, tolerance, debug_info)? - .into_inner(); + let original = Solid::from_faces( + self.shape + .compute_brep(config, tolerance, debug_info)? + .into_inner(), + ); let transformed = original.transform(&make_transform(self)); validate(transformed, config) diff --git a/crates/fj/src/group.rs b/crates/fj/src/group.rs index ecab09070..a870d816a 100644 --- a/crates/fj/src/group.rs +++ b/crates/fj/src/group.rs @@ -1,7 +1,7 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::{Shape, Shape3d}; +use crate::Shape; /// A group of two 3-dimensional shapes /// @@ -16,19 +16,13 @@ use crate::{Shape, Shape3d}; #[repr(C)] pub struct Group { /// The first of the shapes - pub a: Shape3d, + pub a: Shape, /// The second of the shapes - pub b: Shape3d, + pub b: Shape, } impl From for Shape { - fn from(shape: Group) -> Self { - Self::Shape3d(Shape3d::Group(Box::new(shape))) - } -} - -impl From for Shape3d { fn from(shape: Group) -> Self { Self::Group(Box::new(shape)) } diff --git a/crates/fj/src/lib.rs b/crates/fj/src/lib.rs index 297b9c41e..6282b4cbe 100644 --- a/crates/fj/src/lib.rs +++ b/crates/fj/src/lib.rs @@ -23,13 +23,11 @@ pub mod syntax; mod angle; mod group; mod shape_2d; -mod shape_3d; mod sweep; mod transform; pub use self::{ - angle::*, group::Group, shape_2d::*, shape_3d::*, sweep::Sweep, - transform::Transform, + angle::*, group::Group, shape_2d::*, sweep::Sweep, transform::Transform, }; pub use fj_proc::*; #[cfg(feature = "serde")] @@ -40,9 +38,15 @@ use serde::{Deserialize, Serialize}; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[repr(C)] pub enum Shape { + /// A group of two 3-dimensional shapes + Group(Box), + /// A 2D shape Shape2d(Shape2d), - /// A 3D shape - Shape3d(Shape3d), + /// A sweep of 2-dimensional shape along the z-axis + Sweep(Sweep), + + /// A transformed 3-dimensional shape + Transform(Box), } diff --git a/crates/fj/src/shape_3d.rs b/crates/fj/src/shape_3d.rs deleted file mode 100644 index c7ed8cac8..000000000 --- a/crates/fj/src/shape_3d.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::{Group, Shape, Sweep, Transform}; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; - -/// A 3-dimensional shape -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[repr(C)] -pub enum Shape3d { - /// A group of two 3-dimensional shapes - Group(Box), - - /// A sweep of 2-dimensional shape along the z-axis - Sweep(Sweep), - - /// A transformed 3-dimensional shape - Transform(Box), -} - -impl From for Shape { - fn from(shape: Shape3d) -> Self { - Self::Shape3d(shape) - } -} diff --git a/crates/fj/src/sweep.rs b/crates/fj/src/sweep.rs index 1ff50d50a..afb6b1ebd 100644 --- a/crates/fj/src/sweep.rs +++ b/crates/fj/src/sweep.rs @@ -1,7 +1,7 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::{Shape, Shape2d, Shape3d}; +use crate::{Shape, Shape2d}; /// A sweep of a 2-dimensional shape along straight path #[derive(Clone, Debug)] @@ -33,12 +33,6 @@ impl Sweep { } impl From for Shape { - fn from(shape: Sweep) -> Self { - Self::Shape3d(shape.into()) - } -} - -impl From for Shape3d { fn from(shape: Sweep) -> Self { Self::Sweep(shape) } diff --git a/crates/fj/src/syntax.rs b/crates/fj/src/syntax.rs index 34fb0c076..fb887191b 100644 --- a/crates/fj/src/syntax.rs +++ b/crates/fj/src/syntax.rs @@ -35,16 +35,16 @@ pub trait Group { /// Create a group with `self` and `other` fn group(&self, other: &Other) -> crate::Group where - Other: Clone + Into; + Other: Clone + Into; } impl Group for T where - T: Clone + Into, + T: Clone + Into, { fn group(&self, other: &Other) -> crate::Group where - Other: Clone + Into, + Other: Clone + Into, { let a = self.clone().into(); let b = other.clone().into(); @@ -109,7 +109,7 @@ pub trait Transform { impl Transform for T where - T: Clone + Into, + T: Clone + Into, { fn rotate(&self, axis: [f64; 3], angle: crate::Angle) -> crate::Transform { let shape = self.clone().into(); diff --git a/crates/fj/src/transform.rs b/crates/fj/src/transform.rs index 7cc96312d..b826626ae 100644 --- a/crates/fj/src/transform.rs +++ b/crates/fj/src/transform.rs @@ -1,7 +1,7 @@ #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use crate::{Angle, Shape, Shape3d}; +use crate::{Angle, Shape}; /// A transformed 3-dimensional shape /// @@ -17,7 +17,7 @@ use crate::{Angle, Shape, Shape3d}; #[repr(C)] pub struct Transform { /// The shape being transformed - pub shape: Shape3d, + pub shape: Shape, /// The axis of the rotation pub axis: [f64; 3], @@ -30,12 +30,6 @@ pub struct Transform { } impl From for Shape { - fn from(shape: Transform) -> Self { - Self::Shape3d(Shape3d::Transform(Box::new(shape))) - } -} - -impl From for Shape3d { fn from(shape: Transform) -> Self { Self::Transform(Box::new(shape)) } diff --git a/models/test/src/lib.rs b/models/test/src/lib.rs index 89ecb5e08..76f955cf6 100644 --- a/models/test/src/lib.rs +++ b/models/test/src/lib.rs @@ -15,7 +15,7 @@ pub fn model() -> fj::Shape { group.into() } -fn star(num_points: u64, height: f64, color: [u8; 4]) -> fj::Shape3d { +fn star(num_points: u64, height: f64, color: [u8; 4]) -> fj::Shape { let r1 = 1.; let r2 = 2.; @@ -53,7 +53,7 @@ fn star(num_points: u64, height: f64, color: [u8; 4]) -> fj::Shape3d { star.into() } -fn spacer() -> fj::Shape3d { +fn spacer() -> fj::Shape { let outer = 2.; let inner = 1.; let height = 2.; From ecb6f4e18b7503f721ac30bf0d45942cbde5ff62 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:39:16 +0200 Subject: [PATCH 5/6] Make group operation work on all shapes --- crates/fj-operations/src/group.rs | 7 +++---- crates/fj-operations/src/lib.rs | 10 +++------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/fj-operations/src/group.rs b/crates/fj-operations/src/group.rs index 2607818af..610f1ec77 100644 --- a/crates/fj-operations/src/group.rs +++ b/crates/fj-operations/src/group.rs @@ -1,7 +1,7 @@ use fj_interop::debug::DebugInfo; use fj_kernel::{ algorithms::Tolerance, - objects::Solid, + objects::Face, validation::{validate, Validated, ValidationConfig, ValidationError}, }; use fj_math::Aabb; @@ -9,7 +9,7 @@ use fj_math::Aabb; use super::Shape; impl Shape for fj::Group { - type Brep = Solid; + type Brep = Vec; fn compute_brep( &self, @@ -25,8 +25,7 @@ impl Shape for fj::Group { faces.extend(a.into_inner()); faces.extend(b.into_inner()); - let group = Solid::from_faces(faces); - validate(group, config) + validate(faces, config) } fn bounding_volume(&self) -> Aabb<3> { diff --git a/crates/fj-operations/src/lib.rs b/crates/fj-operations/src/lib.rs index 68eb8561f..222cfeb27 100644 --- a/crates/fj-operations/src/lib.rs +++ b/crates/fj-operations/src/lib.rs @@ -69,13 +69,9 @@ impl Shape for fj::Shape { .into_faces(), config, ), - Self::Group(shape) => validate( - shape - .compute_brep(config, tolerance, debug_info)? - .into_inner() - .into_faces(), - config, - ), + Self::Group(shape) => { + shape.compute_brep(config, tolerance, debug_info) + } Self::Sweep(shape) => validate( shape .compute_brep(config, tolerance, debug_info)? From 6c310b751625f7676807f5bb1918dbe80e74d950 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 15 Jul 2022 13:41:35 +0200 Subject: [PATCH 6/6] Make transform operation work on all shapes --- crates/fj-operations/src/lib.rs | 10 +++------- crates/fj-operations/src/transform.rs | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/crates/fj-operations/src/lib.rs b/crates/fj-operations/src/lib.rs index 222cfeb27..be66802ee 100644 --- a/crates/fj-operations/src/lib.rs +++ b/crates/fj-operations/src/lib.rs @@ -79,13 +79,9 @@ impl Shape for fj::Shape { .into_faces(), config, ), - Self::Transform(shape) => validate( - shape - .compute_brep(config, tolerance, debug_info)? - .into_inner() - .into_faces(), - config, - ), + Self::Transform(shape) => { + shape.compute_brep(config, tolerance, debug_info) + } } } diff --git a/crates/fj-operations/src/transform.rs b/crates/fj-operations/src/transform.rs index 3667323a9..6d4c2998d 100644 --- a/crates/fj-operations/src/transform.rs +++ b/crates/fj-operations/src/transform.rs @@ -1,7 +1,7 @@ use fj_interop::debug::DebugInfo; use fj_kernel::{ - algorithms::{Tolerance, TransformObject}, - objects::Solid, + algorithms::{transform_faces, Tolerance}, + objects::Face, validation::{validate, Validated, ValidationConfig, ValidationError}, }; use fj_math::{Aabb, Transform, Vector}; @@ -9,7 +9,7 @@ use fj_math::{Aabb, Transform, Vector}; use super::Shape; impl Shape for fj::Transform { - type Brep = Solid; + type Brep = Vec; fn compute_brep( &self, @@ -17,14 +17,14 @@ impl Shape for fj::Transform { tolerance: Tolerance, debug_info: &mut DebugInfo, ) -> Result, ValidationError> { - let original = Solid::from_faces( - self.shape - .compute_brep(config, tolerance, debug_info)? - .into_inner(), - ); + let mut faces = self + .shape + .compute_brep(config, tolerance, debug_info)? + .into_inner(); - let transformed = original.transform(&make_transform(self)); - validate(transformed, config) + transform_faces(&mut faces, &make_transform(self)); + + validate(faces, config) } fn bounding_volume(&self) -> Aabb<3> {