mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-08 11:58:27 +00:00
Add HalfEdge
, add it to Face
This commit is contained in:
parent
8d54268c72
commit
bce3e7a158
@ -9,12 +9,12 @@ use crate::{
|
||||
object::{Handle, HandleAny, Object},
|
||||
};
|
||||
|
||||
use super::vertex::Vertex;
|
||||
use super::{half_edge::HalfEdge, vertex::Vertex};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Face {
|
||||
surface: Plane,
|
||||
vertices: Vec<Handle<Vertex>>,
|
||||
vertices: Vec<Handle<HalfEdge>>,
|
||||
}
|
||||
|
||||
impl Face {
|
||||
@ -22,7 +22,10 @@ impl Face {
|
||||
surface: Plane,
|
||||
vertices: impl IntoIterator<Item = Handle<Vertex>>,
|
||||
) -> Self {
|
||||
let vertices = vertices.into_iter().collect();
|
||||
let vertices = vertices
|
||||
.into_iter()
|
||||
.map(|vertex| Handle::new(HalfEdge::new(vertex)))
|
||||
.collect();
|
||||
Self { surface, vertices }
|
||||
}
|
||||
|
||||
@ -31,14 +34,14 @@ impl Face {
|
||||
}
|
||||
|
||||
pub fn vertices(&self) -> impl Iterator<Item = &Handle<Vertex>> {
|
||||
self.vertices.iter()
|
||||
self.vertices.iter().map(|half_edge| half_edge.start())
|
||||
}
|
||||
|
||||
pub fn half_edges(&self) -> impl Iterator<Item = [&Handle<Vertex>; 2]> {
|
||||
self.vertices
|
||||
.iter()
|
||||
.circular_tuple_windows()
|
||||
.map(|(a, b)| [a, b])
|
||||
.map(|(a, b)| [a.start(), b.start()])
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +51,10 @@ impl Object for Face {
|
||||
}
|
||||
|
||||
fn tri_mesh(&self) -> TriMesh {
|
||||
triangulate(&self.vertices, self.surface())
|
||||
let mut vertices = Vec::new();
|
||||
vertices.extend(self.vertices().cloned());
|
||||
|
||||
triangulate(&vertices, self.surface())
|
||||
}
|
||||
|
||||
fn children(&self) -> Vec<HandleAny> {
|
||||
|
17
experiments/2024-12-09/src/topology/half_edge.rs
Normal file
17
experiments/2024-12-09/src/topology/half_edge.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use crate::object::Handle;
|
||||
|
||||
use super::vertex::Vertex;
|
||||
|
||||
pub struct HalfEdge {
|
||||
start: Handle<Vertex>,
|
||||
}
|
||||
|
||||
impl HalfEdge {
|
||||
pub fn new(start: Handle<Vertex>) -> Self {
|
||||
Self { start }
|
||||
}
|
||||
|
||||
pub fn start(&self) -> &Handle<Vertex> {
|
||||
&self.start
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
pub mod face;
|
||||
pub mod half_edge;
|
||||
pub mod solid;
|
||||
pub mod vertex;
|
||||
|
Loading…
Reference in New Issue
Block a user