mirror of
https://github.com/hannobraun/Fornjot
synced 2025-09-01 15:06:42 +00:00
Convert Face::from_sketch
into Sketch::to_face
This commit is contained in:
parent
fa3da9acad
commit
ef061b4e16
@ -1,9 +1,36 @@
|
||||
use crate::math::Point;
|
||||
use crate::{
|
||||
math::{Plane, Point},
|
||||
storage::Store,
|
||||
topology::{Face, Vertex},
|
||||
};
|
||||
|
||||
use super::Handle;
|
||||
|
||||
pub struct Sketch {
|
||||
pub points: Vec<Point<2>>,
|
||||
}
|
||||
|
||||
impl Sketch {
|
||||
pub fn to_face(
|
||||
&self,
|
||||
surface: Handle<Plane>,
|
||||
vertices: &mut Store<Vertex>,
|
||||
) -> Face {
|
||||
let vertices = self
|
||||
.points
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|point| {
|
||||
let point = surface.point_from_local(point);
|
||||
let vertex = Vertex::from(point);
|
||||
vertices.insert(vertex)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Face::new(surface, vertices)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I, P> From<I> for Sketch
|
||||
where
|
||||
I: IntoIterator<Item = P>,
|
||||
|
@ -22,7 +22,7 @@ pub fn model(shape: &mut Shape) {
|
||||
},
|
||||
});
|
||||
|
||||
Face::from_sketch(&sketch, surface, stores.get())
|
||||
sketch.to_face(surface, stores.get())
|
||||
};
|
||||
let bottom = top.flip(stores.get()).translate([0., 0., -1.], &mut stores);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use spade::Triangulation;
|
||||
|
||||
use crate::{
|
||||
geometry::{AnyOp, Handle, Operation, Sketch, TriMesh, Triangle},
|
||||
geometry::{AnyOp, Handle, Operation, TriMesh, Triangle},
|
||||
math::{Plane, Point, Vector},
|
||||
storage::{Store, Stores},
|
||||
};
|
||||
@ -25,25 +25,6 @@ impl Face {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_sketch(
|
||||
sketch: &Sketch,
|
||||
surface: Handle<Plane>,
|
||||
vertices: &mut Store<Vertex>,
|
||||
) -> Self {
|
||||
let vertices = sketch
|
||||
.points
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|point| {
|
||||
let point = surface.point_from_local(point);
|
||||
let vertex = Vertex::from(point);
|
||||
vertices.insert(vertex)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Self::new(surface, vertices)
|
||||
}
|
||||
|
||||
pub fn vertices(&self) -> impl Iterator<Item = &Handle<Vertex>> {
|
||||
self.vertices.iter()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user