Skip to content

Commit

Permalink
Make transform operation work on all shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jul 15, 2022
1 parent ecb6f4e commit 6c310b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
10 changes: 3 additions & 7 deletions crates/fj-operations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions crates/fj-operations/src/transform.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
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};

use super::Shape;

impl Shape for fj::Transform {
type Brep = Solid;
type Brep = Vec<Face>;

fn compute_brep(
&self,
config: &ValidationConfig,
tolerance: Tolerance,
debug_info: &mut DebugInfo,
) -> Result<Validated<Self::Brep>, 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> {
Expand Down

0 comments on commit 6c310b7

Please sign in to comment.