From e311c9d00d7fddccb9579aeb095894efb57d05fd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Fri, 31 Jan 2025 21:08:04 +0100 Subject: [PATCH] Add `Sweep` --- experiments/2024-12-09/src/topology/sweep.rs | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/experiments/2024-12-09/src/topology/sweep.rs b/experiments/2024-12-09/src/topology/sweep.rs index 81a69ffa2..ca28ef09c 100644 --- a/experiments/2024-12-09/src/topology/sweep.rs +++ b/experiments/2024-12-09/src/topology/sweep.rs @@ -1,11 +1,35 @@ use crate::{ - geometry::Handle, + geometry::{AnyOp, Handle, Operation, TriMesh}, math::{Plane, Vector}, storage::Store, }; use super::{face::Face, solid::Solid, vertex::Vertex}; +pub struct Sweep { + output: Solid, +} + +impl Operation for Sweep { + type Output = Solid; + + fn output(&self) -> &Self::Output { + &self.output + } + + fn label(&self) -> &'static str { + "Sweep" + } + + fn tri_mesh(&self) -> TriMesh { + self.output.tri_mesh() + } + + fn children(&self) -> Vec { + self.output.children() + } +} + pub trait SweepExt { /// Sweep a face along a path, creating a solid /// @@ -24,7 +48,7 @@ pub trait SweepExt { faces: &mut Store, surfaces: &mut Store, vertices: &mut Store, - ) -> Solid; + ) -> Sweep; } impl SweepExt for Handle { @@ -34,10 +58,12 @@ impl SweepExt for Handle { faces: &mut Store, surfaces: &mut Store, vertices: &mut Store, - ) -> Solid { + ) -> Sweep { let target = faces .insert(self.flip(surfaces).translate(path, surfaces, vertices)); - Solid::connect_faces([target, self], faces, surfaces) + let solid = Solid::connect_faces([target, self], faces, surfaces); + + Sweep { output: solid } } }