use fj_math::Point;
use crate::{
geometry::{CurveBoundary, SurfacePath},
objects::{Curve, Vertex},
storage::{Handle, HandleWrapper},
};
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct HalfEdge {
path: SurfacePath,
boundary: CurveBoundary<Point<1>>,
curve: HandleWrapper<Curve>,
start_vertex: HandleWrapper<Vertex>,
}
impl HalfEdge {
pub fn new(
path: SurfacePath,
boundary: impl Into<CurveBoundary<Point<1>>>,
curve: Handle<Curve>,
start_vertex: Handle<Vertex>,
) -> Self {
Self {
path,
boundary: boundary.into(),
curve: curve.into(),
start_vertex: start_vertex.into(),
}
}
pub fn path(&self) -> SurfacePath {
self.path
}
pub fn boundary(&self) -> CurveBoundary<Point<1>> {
self.boundary
}
pub fn curve(&self) -> &Handle<Curve> {
&self.curve
}
pub fn start_vertex(&self) -> &Handle<Vertex> {
&self.start_vertex
}
pub fn start_position(&self) -> Point<2> {
let [start, _] = self.boundary.inner;
self.path.point_from_path_coords(start)
}
}