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

Remove fj::Difference #265

Merged
merged 1 commit into from
Feb 28, 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
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