Prepare to support curved surfaces

This commit is contained in:
Hanno Braun 2025-02-28 20:48:34 +01:00
parent 640c124c5f
commit 9ba7e0873e
5 changed files with 12 additions and 9 deletions

View File

@ -5,7 +5,9 @@ use itertools::Itertools;
use crate::{ use crate::{
math::{Plane, Point}, math::{Plane, Point},
object::Handle, object::Handle,
topology::{face::Face, half_edge::HalfEdge, vertex::Vertex}, topology::{
face::Face, half_edge::HalfEdge, surface::Surface, vertex::Vertex,
},
}; };
pub struct Sketch { pub struct Sketch {
@ -48,7 +50,7 @@ impl Sketch {
}, },
); );
Face::new(surface, half_edges, false) Face::new(Surface { geometry: surface }, half_edges, false)
} }
} }

View File

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

View File

@ -7,7 +7,7 @@ pub trait FlipExt {
impl FlipExt for Face { impl FlipExt for Face {
fn flip(&self) -> Self { fn flip(&self) -> Self {
Face::new( Face::new(
self.surface.flip().geometry, self.surface.flip(),
self.half_edges.clone(), self.half_edges.clone(),
self.is_internal, self.is_internal,
) )

View File

@ -15,7 +15,7 @@ impl TranslateExt for Face {
let offset = offset.into(); let offset = offset.into();
Face::new( Face::new(
self.surface.translate(offset).geometry, self.surface.translate(offset),
self.half_edges self.half_edges
.iter() .iter()
.map(|half_edge| Handle::new(half_edge.translate(offset))), .map(|half_edge| Handle::new(half_edge.translate(offset))),

View File

@ -5,7 +5,6 @@ use itertools::Itertools;
use crate::{ use crate::{
extra::triangulate::triangulate, extra::triangulate::triangulate,
geometry::TriMesh, geometry::TriMesh,
math::Plane,
object::{Handle, HandleAny, Object}, object::{Handle, HandleAny, Object},
}; };
@ -20,12 +19,12 @@ pub struct Face {
impl Face { impl Face {
pub fn new( pub fn new(
surface: Plane, surface: Surface,
half_edges: impl IntoIterator<Item = Handle<HalfEdge>>, half_edges: impl IntoIterator<Item = Handle<HalfEdge>>,
is_internal: bool, is_internal: bool,
) -> Self { ) -> Self {
Self { Self {
surface: Surface { geometry: surface }, surface,
half_edges: half_edges.into_iter().collect(), half_edges: half_edges.into_iter().collect(),
is_internal, is_internal,
} }