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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
use crate::{ use crate::{
math::Vector, math::Vector,
object::Handle, object::Handle,
topology::{face::Face, vertex::Vertex}, topology::{face::Face, half_edge::HalfEdge, vertex::Vertex},
}; };
pub trait TranslateExt { pub trait TranslateExt {
@ -15,7 +15,9 @@ impl TranslateExt for Face {
Face::new( Face::new(
self.surface().translate(offset), self.surface().translate(offset),
self.half_edges().map(|half_edge| { 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 { impl Face {
pub fn new( pub fn new(
surface: Plane, surface: Plane,
vertices: impl IntoIterator<Item = Handle<Vertex>>, vertices: impl IntoIterator<Item = Handle<HalfEdge>>,
) -> Self { ) -> Self {
let half_edges = vertices let half_edges = vertices.into_iter().collect();
.into_iter()
.map(|vertex| Handle::new(HalfEdge::new(vertex)))
.collect();
Self { Self {
surface, surface,
half_edges, half_edges,