Skip to content

Commit

Permalink
Merge pull request #827 from hannobraun/set
Browse files Browse the repository at this point in the history
Improve internal representation of `Sketch` and `Solid`
  • Loading branch information
hannobraun authored Jul 15, 2022
2 parents 19fb526 + 948a6c2 commit 9c1278a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ fn project_line_into_plane(
plane: &PlaneParametric,
) -> Curve<2> {
let line_origin_relative_to_plane = line.origin - plane.origin;
dbg!(&line_origin_relative_to_plane);
let line_origin_in_plane = Vector::from([
plane
.u
Expand Down
12 changes: 8 additions & 4 deletions crates/fj-kernel/src/algorithms/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,20 @@ impl TransformObject for GlobalVertex {

impl TransformObject for Sketch {
fn transform(self, transform: &Transform) -> Self {
let mut faces = self.into_faces();
transform_faces(&mut faces, transform);
let faces = self
.into_faces()
.into_iter()
.map(|face| face.transform(transform));
Self::from_faces(faces)
}
}

impl TransformObject for Solid {
fn transform(self, transform: &Transform) -> Self {
let mut faces = self.into_faces();
transform_faces(&mut faces, transform);
let faces = self
.into_faces()
.into_iter()
.map(|face| face.transform(transform));
Self::from_faces(faces)
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/fj-kernel/src/objects/sketch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::BTreeSet;

use super::Face;

/// A 2-dimensional shape
Expand All @@ -8,7 +10,7 @@ use super::Face;
/// currently validated.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Sketch {
faces: Vec<Face>,
faces: BTreeSet<Face>,
}

impl Sketch {
Expand All @@ -24,7 +26,7 @@ impl Sketch {
}

/// Convert the sketch into a list of faces
pub fn into_faces(self) -> Vec<Face> {
pub fn into_faces(self) -> BTreeSet<Face> {
self.faces
}
}
6 changes: 4 additions & 2 deletions crates/fj-kernel/src/objects/solid.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::BTreeSet;

use fj_math::Scalar;

use crate::algorithms::TransformObject;
Expand All @@ -12,7 +14,7 @@ use super::{Face, Surface};
/// currently validated.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Solid {
faces: Vec<Face>,
faces: BTreeSet<Face>,
}

impl Solid {
Expand Down Expand Up @@ -53,7 +55,7 @@ impl Solid {
}

/// Convert the solid into a list of faces
pub fn into_faces(self) -> Vec<Face> {
pub fn into_faces(self) -> BTreeSet<Face> {
self.faces
}
}
8 changes: 6 additions & 2 deletions crates/fj-operations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ impl Shape for fj::Shape {
shape
.compute_brep(config, tolerance, debug_info)?
.into_inner()
.into_faces(),
.into_faces()
.into_iter()
.collect(),
config,
),
Self::Group(shape) => {
Expand All @@ -76,7 +78,9 @@ impl Shape for fj::Shape {
shape
.compute_brep(config, tolerance, debug_info)?
.into_inner()
.into_faces(),
.into_faces()
.into_iter()
.collect(),
config,
),
Self::Transform(shape) => {
Expand Down

0 comments on commit 9c1278a

Please sign in to comment.