Update type of function parameter

This commit is contained in:
Hanno Braun 2025-02-24 19:24:21 +01:00
parent 3754d9e9b2
commit 634c427e11
5 changed files with 22 additions and 21 deletions

View File

@ -1,7 +1,7 @@
use crate::{
math::{Plane, Point},
object::Handle,
topology::{face::Face, vertex::Vertex},
topology::{face::Face, half_edge::HalfEdge, vertex::Vertex},
};
pub struct Sketch {
@ -10,11 +10,16 @@ pub struct Sketch {
impl Sketch {
pub fn to_face(&self, surface: Plane) -> Face {
let vertices = self.points.iter().copied().map(|point| {
let point = surface.point_from_local(point);
let vertex = Vertex::new(point);
Handle::new(vertex)
});
let vertices = self
.points
.iter()
.copied()
.map(|point| {
let point = surface.point_from_local(point);
let vertex = Vertex::new(point);
Handle::new(vertex)
})
.map(|vertex| Handle::new(HalfEdge::new(vertex)));
Face::new(surface, vertices)
}

View File

@ -1,7 +1,7 @@
use crate::{
math::Plane,
object::Handle,
topology::{face::Face, solid::Solid},
topology::{face::Face, half_edge::HalfEdge, solid::Solid},
};
pub trait ConnectExt {
@ -40,7 +40,9 @@ impl ConnectExt for Handle<Face> {
Plane::from_points([q, r, s].map(|vertex| vertex.point));
let face = Face::new(
surface,
[q, r, s, t].map(|vertex| vertex.clone()),
[q, r, s, t].map(|vertex| {
Handle::new(HalfEdge::new(vertex.clone()))
}),
);
Handle::new(face)
})

View File

@ -6,11 +6,6 @@ pub trait FlipExt {
impl FlipExt for &Face {
fn flip(self) -> Face {
Face::new(
self.surface().flip(),
self.half_edges()
.cloned()
.map(|half_edge| half_edge.start().clone()),
)
Face::new(self.surface().flip(), self.half_edges().cloned())
}
}

View File

@ -1,7 +1,7 @@
use crate::{
math::Vector,
object::Handle,
topology::{face::Face, vertex::Vertex},
topology::{face::Face, half_edge::HalfEdge, vertex::Vertex},
};
pub trait TranslateExt {
@ -15,7 +15,9 @@ impl TranslateExt for Face {
Face::new(
self.surface().translate(offset),
self.half_edges().map(|half_edge| {
Handle::new(half_edge.start().translate(offset))
Handle::new(HalfEdge::new(Handle::new(
half_edge.start().translate(offset),
)))
}),
)
}

View File

@ -20,12 +20,9 @@ pub struct Face {
impl Face {
pub fn new(
surface: Plane,
vertices: impl IntoIterator<Item = Handle<Vertex>>,
vertices: impl IntoIterator<Item = Handle<HalfEdge>>,
) -> Self {
let half_edges = vertices
.into_iter()
.map(|vertex| Handle::new(HalfEdge::new(vertex)))
.collect();
let half_edges = vertices.into_iter().collect();
Self {
surface,
half_edges,