mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-12 18:26:00 +00:00
Make construction of side faces more generic
This commit is contained in:
parent
36e472c771
commit
b7610f2e5f
@ -1,5 +1,3 @@
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
geometry::{AnyOp, Sketch},
|
||||
math::{Bivector, Plane, Point, Vector},
|
||||
@ -30,21 +28,21 @@ pub fn model() -> AnyOp {
|
||||
&mut stores.vertices,
|
||||
);
|
||||
|
||||
let [a, b, c, d] = bottom.vertices().collect_array().unwrap();
|
||||
let [e, f, g, h] = top.vertices().collect_array().unwrap();
|
||||
|
||||
let [left, right, front, back] =
|
||||
[[a, e, h, d], [b, c, g, f], [a, b, f, e], [c, d, h, g]].map(
|
||||
|[q, r, s, t]| {
|
||||
let surface = stores.surfaces.insert(Plane::from_points(
|
||||
[q, r, s].map(|vertex| vertex.point),
|
||||
));
|
||||
Face::new(surface, [q, r, s, t].map(|vertex| vertex.clone()))
|
||||
},
|
||||
);
|
||||
let side_faces = bottom
|
||||
.half_edges()
|
||||
.zip(top.half_edges())
|
||||
.map(|([q, r], [t, s])| {
|
||||
let surface = stores.surfaces.insert(Plane::from_points(
|
||||
[q, r, s].map(|vertex| vertex.point),
|
||||
));
|
||||
Face::new(surface, [q, r, s, t].map(|vertex| vertex.clone()))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let solid = Solid::new(
|
||||
[bottom, top, left, right, front, back]
|
||||
[bottom, top]
|
||||
.into_iter()
|
||||
.chain(side_faces)
|
||||
.map(|face| stores.faces.insert(face)),
|
||||
);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
use itertools::Itertools;
|
||||
use spade::Triangulation;
|
||||
|
||||
use crate::{
|
||||
@ -25,10 +26,18 @@ impl Face {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)] // fell out of use, but will likely be required again
|
||||
pub fn vertices(&self) -> impl Iterator<Item = &Handle<Vertex>> {
|
||||
self.vertices.iter()
|
||||
}
|
||||
|
||||
pub fn half_edges(&self) -> impl Iterator<Item = [&Handle<Vertex>; 2]> {
|
||||
self.vertices
|
||||
.iter()
|
||||
.circular_tuple_windows()
|
||||
.map(|(a, b)| [a, b])
|
||||
}
|
||||
|
||||
pub fn flip(&self, surfaces: &mut Store<Plane>) -> Self {
|
||||
Self {
|
||||
surface: surfaces.insert(self.surface.flip()),
|
||||
|
Loading…
Reference in New Issue
Block a user