diff --git a/experiments/2024-12-09/src/topology/connect.rs b/experiments/2024-12-09/src/topology/connect.rs index c9c6b08fb..b50226868 100644 --- a/experiments/2024-12-09/src/topology/connect.rs +++ b/experiments/2024-12-09/src/topology/connect.rs @@ -1,4 +1,4 @@ -use crate::geometry::Handle; +use crate::{geometry::Handle, math::Plane}; use super::{face::Face, solid::Solid}; @@ -24,6 +24,27 @@ pub trait ConnectExt { impl ConnectExt for Handle { fn connect(self, other: Handle) -> Solid { - Solid::connect_faces([self, other]) + assert_eq!( + self.vertices().count(), + other.vertices().count(), + "Can only connect faces that have the same number of vertices.", + ); + + let side_faces = self + .half_edges() + .zip(other.half_edges()) + .map(|([q, r], [t, s])| { + let surface = Handle::new(Plane::from_points( + [q, r, s].map(|vertex| vertex.point), + )); + let face = Face::new( + surface, + [q, r, s, t].map(|vertex| vertex.clone()), + ); + Handle::new(face) + }) + .collect::>(); + + Solid::new([self, other].into_iter().chain(side_faces)) } } diff --git a/experiments/2024-12-09/src/topology/solid.rs b/experiments/2024-12-09/src/topology/solid.rs index c1b81004d..194de992f 100644 --- a/experiments/2024-12-09/src/topology/solid.rs +++ b/experiments/2024-12-09/src/topology/solid.rs @@ -1,9 +1,6 @@ use std::fmt; -use crate::{ - geometry::{AnyOp, Handle, Operation, TriMesh}, - math::Plane, -}; +use crate::geometry::{AnyOp, Handle, Operation, TriMesh}; use super::face::Face; @@ -17,31 +14,6 @@ impl Solid { faces: faces.into_iter().collect(), } } - - pub fn connect_faces([a, b]: [Handle; 2]) -> Self { - assert_eq!( - a.vertices().count(), - b.vertices().count(), - "Can only connect faces that have the same number of vertices.", - ); - - let side_faces = a - .half_edges() - .zip(b.half_edges()) - .map(|([q, r], [t, s])| { - let surface = Handle::new(Plane::from_points( - [q, r, s].map(|vertex| vertex.point), - )); - let face = Face::new( - surface, - [q, r, s, t].map(|vertex| vertex.clone()), - ); - Handle::new(face) - }) - .collect::>(); - - Solid::new([a, b].into_iter().chain(side_faces)) - } } impl Operation for Solid {