diff --git a/src/kernel/algorithms/sweep.rs b/src/kernel/algorithms/sweep.rs index 36e4b0fc47..a63c276578 100644 --- a/src/kernel/algorithms/sweep.rs +++ b/src/kernel/algorithms/sweep.rs @@ -1,5 +1,10 @@ +use std::collections::HashMap; + use crate::{ - kernel::{shape::Shape, topology::faces::Face}, + kernel::{ + shape::Shape, + topology::{edges::Edge, faces::Face}, + }, math::{Scalar, Transform, Vector}, }; @@ -22,6 +27,45 @@ pub fn sweep_shape( let mut top_faces = Vec::new(); let mut side_faces = Vec::new(); + // Create new vertices. + let mut vertices = HashMap::new(); + for vertex_orig in shape_orig.vertices().all() { + let point = vertex_orig.point() + path; + + let vertex = shape.vertices().add(point); + + vertices.insert(vertex_orig, vertex); + } + + // Create top edges. + // let mut edges = HashMap::new(); + // for cycle_orig in shape_orig.cycles().all() { + // for edge_orig in cycle_orig.edges { + // let curve = + // shape.curves().add(edge_orig.curve.transform(&translation)); + + // let vertices = edge_orig.vertices.map(|vs| { + // vs.map(|v| { + // *vertices.get(&v).expect( + // "Edge is referring to vertex that doesn't exist in shape", + // ) + // }) + // }); + + // let edge = Edge { curve, vertices }; + // // TASK: We need to insert `edge` into `shape` here, but that + // // doesn't quite work. We're losing the cycles here, but we + // // need to faithfully reproduce those too. + + // edges.insert(edge_orig, edge); + // } + // } + + // Create top faces. + + // We could use `vertices` to create the side edges and faces here, but the + // side walls is created below, in triangle representation. + for face in shape_orig.faces().all() { bottom_faces.push(face.clone()); diff --git a/src/kernel/shape/vertices.rs b/src/kernel/shape/vertices.rs index 801a2c765e..cf84262400 100644 --- a/src/kernel/shape/vertices.rs +++ b/src/kernel/shape/vertices.rs @@ -52,6 +52,14 @@ impl Vertices<'_> { handle } + + /// Access iterator over all vertices + /// + /// The caller must not make any assumptions about the order of vertices. + pub fn all(&self) -> impl Iterator { + // TASK: Implement + std::iter::empty() + } } #[cfg(test)]