Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve internal representation of Sketch and Solid #827

Merged
merged 2 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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