Add `BuildSolid::tetrahedron`

This commit is contained in:
Hanno Braun 2023-05-04 12:18:50 +02:00
parent 01ba108aa2
commit 697083be4f
3 changed files with 36 additions and 3 deletions

View File

@ -10,6 +10,6 @@ pub use self::{
edge::BuildHalfEdge, edge::BuildHalfEdge,
face::{BuildFace, Polygon}, face::{BuildFace, Polygon},
shell::{BuildShell, TetrahedronShell}, shell::{BuildShell, TetrahedronShell},
solid::BuildSolid, solid::{BuildSolid, Tetrahedron},
surface::BuildSurface, surface::BuildSurface,
}; };

View File

@ -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`] /// Build a [`Solid`]
pub trait BuildSolid { pub trait BuildSolid {
@ -6,6 +15,30 @@ pub trait BuildSolid {
fn empty() -> Solid { fn empty() -> Solid {
Solid::new([]) Solid::new([])
} }
/// Build a tetrahedron from the provided points
///
/// See [`BuildShell::tetrahedron`] for more information.
fn tetrahedron(
points: [impl Into<Point<3>>; 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 {} 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<IsInsertedYes>,
}

View File

@ -8,7 +8,7 @@ mod update;
pub use self::{ pub use self::{
build::{ build::{
BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSolid, BuildCycle, BuildFace, BuildHalfEdge, BuildShell, BuildSolid,
BuildSurface, Polygon, TetrahedronShell, BuildSurface, Polygon, Tetrahedron, TetrahedronShell,
}, },
insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes}, insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes},
join::JoinCycle, join::JoinCycle,