Skip to content

Commit

Permalink
Merge pull request #265 from hannobraun/difference
Browse files Browse the repository at this point in the history
Remove `fj::Difference`
  • Loading branch information
hannobraun authored Feb 28, 2022
2 parents 31f9002 + 16689e2 commit 54d5cc1
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 83 deletions.
3 changes: 1 addition & 2 deletions fj/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ mod syntax;

pub mod prelude {
pub use crate::syntax::{
Difference as _, Rotate as _, Sketch as _, Sweep as _, Translate as _,
Union as _,
Rotate as _, Sketch as _, Sweep as _, Translate as _, Union as _,
};
}

Expand Down
34 changes: 0 additions & 34 deletions fj/src/shape_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use crate::{Shape, Shape2d};
#[derive(Clone, Debug)]
#[repr(C)]
pub enum Shape3d {
/// The difference of two 3-dimensional shapes
Difference(Box<Difference>),

/// A sweep of 2-dimensional shape along the z-axis
Sweep(Sweep),

Expand All @@ -23,37 +20,6 @@ impl From<Shape3d> for Shape {
}
}

/// The difference of two 3-dimensional shapes
///
/// # Limitations
///
/// This operation is not supported right now. Using it in a model, will result
/// in the host application crashing.
///
/// See issue:
/// https://github.com/hannobraun/Fornjot/issues/43
#[derive(Clone, Debug)]
#[repr(C)]
pub struct Difference {
/// The first of the shapes
pub a: Shape3d,

/// The second of the shapes
pub b: Shape3d,
}

impl From<Difference> for Shape {
fn from(shape: Difference) -> Self {
Self::Shape3d(Shape3d::Difference(Box::new(shape)))
}
}

impl From<Difference> for Shape3d {
fn from(shape: Difference) -> Self {
Self::Difference(Box::new(shape))
}
}

/// A transformed 3-dimensional shape
///
/// # Limitations
Expand Down
21 changes: 0 additions & 21 deletions fj/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ where
}
}

pub trait Difference {
fn difference<Other>(&self, other: &Other) -> crate::Difference
where
Other: Clone + Into<crate::Shape3d>;
}

impl<T> Difference for T
where
T: Clone + Into<crate::Shape3d>,
{
fn difference<Other>(&self, other: &Other) -> crate::Difference
where
Other: Clone + Into<crate::Shape3d>,
{
let a = self.clone().into();
let b = other.clone().into();

crate::Difference { a, b }
}
}

pub trait Sweep {
fn sweep(&self, length: f64) -> crate::Sweep;
}
Expand Down
24 changes: 0 additions & 24 deletions src/kernel/shapes/difference_3d.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/kernel/shapes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod circle;
pub mod difference_2d;
pub mod difference_3d;
pub mod sketch;
pub mod sweep;
pub mod transform;
Expand Down Expand Up @@ -54,7 +53,6 @@ macro_rules! dispatch {
$(
fn $method(&self, $($arg_name: $arg_ty,)*) -> $ret {
match self {
Self::Difference(shape) => shape.$method($($arg_name,)*),
Self::Sweep(shape) => shape.$method($($arg_name,)*),
Self::Transform(shape) => shape.$method($($arg_name,)*),
Self::Union(shape) => shape.$method($($arg_name,)*),
Expand Down

0 comments on commit 54d5cc1

Please sign in to comment.