Accept `Vec<Face>` in `transform`

This commit is contained in:
Hanno Braun 2022-06-28 16:42:27 +02:00
parent 9aa8efaa36
commit 34a34e52b5
2 changed files with 5 additions and 4 deletions

View File

@ -1,16 +1,15 @@
use fj_math::Transform; use fj_math::Transform;
use crate::{ use crate::{
iter::ObjectIters,
objects::{Cycle, CyclesInFace, Edge, Face, FaceBRep, Vertex}, objects::{Cycle, CyclesInFace, Edge, Face, FaceBRep, Vertex},
shape::{LocalForm, Shape}, shape::{LocalForm, Shape},
}; };
/// Transform a shape /// Transform a shape
pub fn transform(shape: &Shape, transform: &Transform) -> Vec<Face> { pub fn transform(shape: &[Face], transform: &Transform) -> Vec<Face> {
let mut target = Vec::new(); let mut target = Vec::new();
for face in shape.face_iter() { for face in shape {
let face = match face { let face = match face {
Face::Face(face) => { Face::Face(face) => {
let mut tmp = Shape::new(); let mut tmp = Shape::new();
@ -32,7 +31,7 @@ pub fn transform(shape: &Shape, transform: &Transform) -> Vec<Face> {
Face::Triangles(triangles) => { Face::Triangles(triangles) => {
let mut target = Vec::new(); let mut target = Vec::new();
for (triangle, color) in triangles { for &(triangle, color) in triangles {
let triangle = transform.transform_triangle(&triangle); let triangle = transform.transform_triangle(&triangle);
target.push((triangle, color)); target.push((triangle, color));
} }

View File

@ -1,6 +1,7 @@
use fj_interop::debug::DebugInfo; use fj_interop::debug::DebugInfo;
use fj_kernel::{ use fj_kernel::{
algorithms::{transform, Tolerance}, algorithms::{transform, Tolerance},
iter::ObjectIters,
shape::Shape, shape::Shape,
validation::{validate, Validated, ValidationConfig, ValidationError}, validation::{validate, Validated, ValidationConfig, ValidationError},
}; };
@ -18,6 +19,7 @@ impl ToShape for fj::Transform {
let shape = self.shape.to_shape(config, tolerance, debug_info)?; let shape = self.shape.to_shape(config, tolerance, debug_info)?;
let shape = shape.into_inner(); let shape = shape.into_inner();
let shape = shape.face_iter().collect::<Vec<_>>();
let faces = transform(&shape, &make_transform(self)); let faces = transform(&shape, &make_transform(self));
let mut target = Shape::new(); let mut target = Shape::new();