mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 09:58:27 +00:00
Merge pull request #2283 from hannobraun/geometry
Remove redundant geometry from `HalfEdge`
This commit is contained in:
commit
7115ad074b
@ -11,7 +11,7 @@ use super::{GlobalPath, HalfEdgeGeometry, SurfaceGeometry};
|
||||
|
||||
/// Geometric data that is associated with topological objects
|
||||
pub struct Geometry {
|
||||
half_edge: BTreeMap<Handle<HalfEdge>, HalfEdgeGeometry>,
|
||||
half_edge: BTreeMap<HandleWrapper<HalfEdge>, HalfEdgeGeometry>,
|
||||
surface: BTreeMap<HandleWrapper<Surface>, SurfaceGeometry>,
|
||||
|
||||
xy_plane: Handle<Surface>,
|
||||
@ -61,7 +61,7 @@ impl Geometry {
|
||||
half_edge: Handle<HalfEdge>,
|
||||
geometry: HalfEdgeGeometry,
|
||||
) {
|
||||
self.half_edge.insert(half_edge, geometry);
|
||||
self.half_edge.insert(half_edge.into(), geometry);
|
||||
}
|
||||
|
||||
pub(crate) fn define_surface_inner(
|
||||
@ -82,7 +82,7 @@ impl Geometry {
|
||||
half_edge: &Handle<HalfEdge>,
|
||||
) -> HalfEdgeGeometry {
|
||||
self.half_edge
|
||||
.get(half_edge)
|
||||
.get(&half_edge.clone().into())
|
||||
.copied()
|
||||
.expect("Expected geometry of half-edge to be defined")
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
geometry::{CurveBoundary, SurfacePath},
|
||||
geometry::CurveBoundary,
|
||||
objects::{Curve, Vertex},
|
||||
storage::{Handle, HandleWrapper},
|
||||
};
|
||||
@ -35,7 +35,6 @@ use crate::{
|
||||
/// [`Shell`]: crate::objects::Shell
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct HalfEdge {
|
||||
path: SurfacePath,
|
||||
boundary: CurveBoundary<Point<1>>,
|
||||
curve: HandleWrapper<Curve>,
|
||||
start_vertex: HandleWrapper<Vertex>,
|
||||
@ -44,24 +43,17 @@ pub struct HalfEdge {
|
||||
impl HalfEdge {
|
||||
/// Create an instance of `Edge`
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Access the curve that defines the edge's geometry
|
||||
pub fn path(&self) -> SurfacePath {
|
||||
self.path
|
||||
}
|
||||
|
||||
/// Access the boundary points of the edge on the curve
|
||||
pub fn boundary(&self) -> CurveBoundary<Point<1>> {
|
||||
self.boundary
|
||||
|
@ -17,14 +17,13 @@ use crate::{
|
||||
pub trait BuildHalfEdge {
|
||||
/// Create a half-edge that is not joined to a sibling
|
||||
fn unjoined(
|
||||
path: SurfacePath,
|
||||
boundary: impl Into<CurveBoundary<Point<1>>>,
|
||||
core: &mut Core,
|
||||
) -> HalfEdge {
|
||||
let curve = Curve::new().insert(core);
|
||||
let start_vertex = Vertex::new().insert(core);
|
||||
|
||||
HalfEdge::new(path, boundary, curve, start_vertex)
|
||||
HalfEdge::new(boundary, curve, start_vertex)
|
||||
}
|
||||
|
||||
/// Create a half-edge from its sibling
|
||||
@ -34,7 +33,6 @@ pub trait BuildHalfEdge {
|
||||
core: &mut Core,
|
||||
) -> Handle<HalfEdge> {
|
||||
let half_edge = HalfEdge::new(
|
||||
core.layers.geometry.of_half_edge(sibling).path,
|
||||
sibling.boundary().reverse(),
|
||||
sibling.curve().clone(),
|
||||
start_vertex,
|
||||
@ -74,7 +72,7 @@ pub trait BuildHalfEdge {
|
||||
let boundary =
|
||||
[arc.start_angle, arc.end_angle].map(|coord| Point::from([coord]));
|
||||
|
||||
let half_edge = HalfEdge::unjoined(path, boundary, core).insert(core);
|
||||
let half_edge = HalfEdge::unjoined(boundary, core).insert(core);
|
||||
core.layers
|
||||
.geometry
|
||||
.define_half_edge(half_edge.clone(), HalfEdgeGeometry { path });
|
||||
@ -92,7 +90,7 @@ pub trait BuildHalfEdge {
|
||||
let boundary =
|
||||
[Scalar::ZERO, Scalar::TAU].map(|coord| Point::from([coord]));
|
||||
|
||||
let half_edge = HalfEdge::unjoined(path, boundary, core).insert(core);
|
||||
let half_edge = HalfEdge::unjoined(boundary, core).insert(core);
|
||||
core.layers
|
||||
.geometry
|
||||
.define_half_edge(half_edge.clone(), HalfEdgeGeometry { path });
|
||||
@ -112,7 +110,7 @@ pub trait BuildHalfEdge {
|
||||
boundary.zip_ext(points_surface),
|
||||
);
|
||||
|
||||
HalfEdge::unjoined(path, boundary, core)
|
||||
HalfEdge::unjoined(boundary, core)
|
||||
.insert(core)
|
||||
.set_path(path, &mut core.layers.geometry)
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ impl JoinCycle for Cycle {
|
||||
.into_iter()
|
||||
.circular_tuple_windows()
|
||||
.map(|((prev_half_edge, _, _), (half_edge, path, boundary))| {
|
||||
HalfEdge::unjoined(path, boundary, core)
|
||||
HalfEdge::unjoined(boundary, core)
|
||||
.update_curve(|_, _| half_edge.curve().clone(), core)
|
||||
.update_start_vertex(
|
||||
|_, _| prev_half_edge.start_vertex().clone(),
|
||||
|
@ -17,7 +17,6 @@ impl Reverse for Cycle {
|
||||
let path = core.layers.geometry.of_half_edge(current).path;
|
||||
|
||||
HalfEdge::new(
|
||||
path,
|
||||
current.boundary().reverse(),
|
||||
current.curve().clone(),
|
||||
next.start_vertex().clone(),
|
||||
|
@ -14,7 +14,6 @@ impl ReverseCurveCoordinateSystems for Handle<HalfEdge> {
|
||||
let boundary = self.boundary().reverse();
|
||||
|
||||
let half_edge = HalfEdge::new(
|
||||
path,
|
||||
boundary,
|
||||
self.curve().clone(),
|
||||
self.start_vertex().clone(),
|
||||
|
@ -44,14 +44,12 @@ impl SplitHalfEdge for Handle<HalfEdge> {
|
||||
let [start, end] = self.boundary().inner;
|
||||
|
||||
let a = HalfEdge::new(
|
||||
core.layers.geometry.of_half_edge(self).path,
|
||||
[start, point],
|
||||
self.curve().clone(),
|
||||
self.start_vertex().clone(),
|
||||
)
|
||||
.insert(core);
|
||||
let b = HalfEdge::new(
|
||||
core.layers.geometry.of_half_edge(self).path,
|
||||
[point, end],
|
||||
self.curve().clone(),
|
||||
Vertex::new().insert(core),
|
||||
|
@ -28,7 +28,7 @@ impl TransformObject for Handle<HalfEdge> {
|
||||
.transform_with_cache(transform, core, cache);
|
||||
|
||||
let half_edge =
|
||||
HalfEdge::new(path, boundary, curve, start_vertex).insert(core);
|
||||
HalfEdge::new(boundary, curve, start_vertex).insert(core);
|
||||
|
||||
core.layers
|
||||
.geometry
|
||||
|
@ -38,7 +38,6 @@ impl UpdateHalfEdge for HalfEdge {
|
||||
T: Insert<Inserted = Handle<Curve>>,
|
||||
{
|
||||
HalfEdge::new(
|
||||
self.path(),
|
||||
self.boundary(),
|
||||
update(self.curve(), core)
|
||||
.insert(core)
|
||||
@ -56,7 +55,6 @@ impl UpdateHalfEdge for HalfEdge {
|
||||
T: Insert<Inserted = Handle<Vertex>>,
|
||||
{
|
||||
HalfEdge::new(
|
||||
self.path(),
|
||||
self.boundary(),
|
||||
self.curve().clone(),
|
||||
update(self.start_vertex(), core)
|
||||
|
@ -446,7 +446,6 @@ mod tests {
|
||||
cycle.half_edges().nth_circular(0),
|
||||
|half_edge, core| {
|
||||
[HalfEdge::new(
|
||||
half_edge.path().reverse(),
|
||||
half_edge.boundary().reverse(),
|
||||
half_edge.curve().clone(),
|
||||
half_edge.start_vertex().clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user