Accept Vec<Face> as source in sweep

This commit is contained in:
Hanno Braun 2022-06-28 15:31:09 +02:00
parent e75e2e636a
commit 4ad8e50fc8
2 changed files with 9 additions and 5 deletions

View File

@ -12,7 +12,7 @@ use super::{CycleApprox, Tolerance};
/// Create a solid by sweeping a sketch
pub fn sweep(
source: Shape,
source: Vec<Face>,
path: impl Into<Vector<3>>,
tolerance: Tolerance,
color: [u8; 4],
@ -455,11 +455,13 @@ mod tests {
let mut shape = Shape::new();
let _sketch = Face::builder(Surface::xy_plane(), &mut shape)
let sketch = Face::builder(Surface::xy_plane(), &mut shape)
.with_exterior_polygon([[0., 0.], [1., 0.], [0., 1.]])
.build();
.build()
.get();
let solid = super::sweep(shape, direction, tolerance, [255, 0, 0, 255]);
let solid =
super::sweep(vec![sketch], direction, tolerance, [255, 0, 0, 255]);
let expected_vertices: Vec<_> = expected_vertices
.into_iter()

View File

@ -1,6 +1,7 @@
use fj_interop::debug::DebugInfo;
use fj_kernel::{
algorithms::{sweep, Tolerance},
iter::ObjectIters,
shape::Shape,
validation::{validate, Validated, ValidationConfig, ValidationError},
};
@ -19,7 +20,8 @@ impl ToShape for fj::Sweep {
let path = Vector::from(self.path());
let color = self.shape().color();
let swept = sweep(shape.into_inner(), path, tolerance, color);
let shape = shape.face_iter().collect::<Vec<_>>();
let swept = sweep(shape, path, tolerance, color);
let swept = validate(swept, config)?;
Ok(swept)