From 697083be4fa3e2042a3e5b07321a10e005dbfd59 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 4 May 2023 12:18:50 +0200 Subject: [PATCH] Add `BuildSolid::tetrahedron` --- crates/fj-kernel/src/operations/build/mod.rs | 2 +- .../fj-kernel/src/operations/build/solid.rs | 35 ++++++++++++++++++- crates/fj-kernel/src/operations/mod.rs | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/crates/fj-kernel/src/operations/build/mod.rs b/crates/fj-kernel/src/operations/build/mod.rs index 48761b8f6..fe6010c3b 100644 --- a/crates/fj-kernel/src/operations/build/mod.rs +++ b/crates/fj-kernel/src/operations/build/mod.rs @@ -10,6 +10,6 @@ pub use self::{ edge::BuildHalfEdge, face::{BuildFace, Polygon}, shell::{BuildShell, TetrahedronShell}, - solid::BuildSolid, + solid::{BuildSolid, Tetrahedron}, surface::BuildSurface, }; diff --git a/crates/fj-kernel/src/operations/build/solid.rs b/crates/fj-kernel/src/operations/build/solid.rs index ac0eb7ca1..080405ee5 100644 --- a/crates/fj-kernel/src/operations/build/solid.rs +++ b/crates/fj-kernel/src/operations/build/solid.rs @@ -1,4 +1,13 @@ -use crate::objects::Solid; +use fj_math::Point; + +use crate::{ + objects::{Shell, Solid}, + operations::{ + build::shell::BuildShell, Insert, IsInsertedYes, TetrahedronShell, + UpdateSolid, + }, + services::Services, +}; /// Build a [`Solid`] pub trait BuildSolid { @@ -6,6 +15,30 @@ pub trait BuildSolid { fn empty() -> Solid { Solid::new([]) } + + /// Build a tetrahedron from the provided points + /// + /// See [`BuildShell::tetrahedron`] for more information. + fn tetrahedron( + points: [impl Into>; 4], + services: &mut Services, + ) -> Tetrahedron { + let shell = Shell::tetrahedron(points, services).insert(services); + let solid = Solid::empty().add_shell(shell.shell.clone()); + + Tetrahedron { solid, shell } + } } impl BuildSolid for Solid {} + +/// A tetrahedron +/// +/// Returned by [`BuildSolid::tetrahedron`]. +pub struct Tetrahedron { + /// The solid that forms the tetrahedron + pub solid: Solid, + + /// The shell of the tetrahedron + pub shell: TetrahedronShell, +} diff --git a/crates/fj-kernel/src/operations/mod.rs b/crates/fj-kernel/src/operations/mod.rs index 1f5913e9a..313bdeaae 100644 --- a/crates/fj-kernel/src/operations/mod.rs +++ b/crates/fj-kernel/src/operations/mod.rs @@ -8,7 +8,7 @@ mod update; pub use self::{ build::{ BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSolid, - BuildSurface, Polygon, TetrahedronShell, + BuildSurface, Polygon, Tetrahedron, TetrahedronShell, }, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, join::JoinCycle,