Make sure cycles that bound face are part of shape

This commit is contained in:
Hanno Braun 2022-03-08 14:44:45 +01:00
parent f3da496e9f
commit a16ebef638
6 changed files with 10 additions and 17 deletions

View File

@ -262,9 +262,9 @@ mod tests {
let cd = shape.edges().add(Edge::line_segment([v3, v4.clone()]));
let da = shape.edges().add(Edge::line_segment([v4, v1]));
let abcd = Cycle {
let abcd = shape.cycles().add(Cycle {
edges: vec![ab, bc, cd, da],
};
});
let face = Face::Face {
surface: Surface::x_y_plane(),

View File

@ -125,9 +125,9 @@ mod tests {
.edges()
.add(Edge::line_segment([c.clone(), a.clone()]));
let cycles = Cycle {
let cycles = shape.cycles().add(Cycle {
edges: vec![ab, bc, ca],
};
});
let abc = Face::Face {
surface: Surface::Swept(Swept::plane_from_points(

View File

@ -43,7 +43,7 @@ pub fn transform_face(
for cycle in cycles {
let mut edges = Vec::new();
for edge in cycle.edges {
for edge in &cycle.edges {
let vertices = edge.vertices.clone().map(|vertices| {
vertices.map(|vertex| {
let point =
@ -62,7 +62,7 @@ pub fn transform_face(
edges.push(edge);
}
cycles_trans.push(Cycle { edges });
cycles_trans.push(shape.cycles().add(Cycle { edges }));
}
Face::Face {

View File

@ -25,11 +25,7 @@ impl ToShape for fj::Circle {
.add(Edge::circle(Scalar::from_f64(self.radius)));
shape.cycles().add(Cycle { edges: vec![edge] });
let cycles = shape
.cycles()
.all()
.map(|handle| (*handle).clone())
.collect();
let cycles = shape.cycles().all().collect();
shape.faces().add(Face::Face {
cycles,
surface: Surface::x_y_plane(),

View File

@ -48,11 +48,7 @@ impl ToShape for fj::Sketch {
};
let face = Face::Face {
cycles: shape
.cycles()
.all()
.map(|handle| (*handle).clone())
.collect(),
cycles: shape.cycles().all().collect(),
surface: Surface::x_y_plane(),
};
shape.faces().add(face);

View File

@ -10,6 +10,7 @@ use crate::{
approximation::Approximation, triangulation::triangulate,
},
geometry::Surface,
shape::handle::Handle,
},
math::{Aabb, Scalar, Segment, Triangle},
};
@ -37,7 +38,7 @@ pub enum Face {
///
/// It might be less error-prone to specify the edges in surface
/// coordinates.
cycles: Vec<Cycle>,
cycles: Vec<Handle<Cycle>>,
},
/// The triangles of the face