Skip to content

Commit

Permalink
Merge pull request #2419 from hannobraun/geom
Browse files Browse the repository at this point in the history
Remove all code dealing with half-edge geometry
  • Loading branch information
hannobraun authored Jul 10, 2024
2 parents ee5121b + 346e202 commit 44955d9
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 309 deletions.
27 changes: 3 additions & 24 deletions crates/fj-core/src/geometry/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ use fj_math::Vector;

use crate::{
storage::Handle,
topology::{Curve, HalfEdge, Surface, Topology, Vertex},
topology::{Curve, Surface, Topology, Vertex},
};

use super::{
vertex::LocalVertexGeom, CurveGeom, GlobalPath, HalfEdgeGeom,
LocalCurveGeom, SurfaceGeom, VertexGeom,
vertex::LocalVertexGeom, CurveGeom, GlobalPath, LocalCurveGeom,
SurfaceGeom, VertexGeom,
};

/// Geometric data that is associated with topological objects
pub struct Geometry {
curve: BTreeMap<Handle<Curve>, CurveGeom>,
half_edge: BTreeMap<Handle<HalfEdge>, HalfEdgeGeom>,
surface: BTreeMap<Handle<Surface>, SurfaceGeom>,
vertex: BTreeMap<Handle<Vertex>, VertexGeom>,

Expand All @@ -31,7 +30,6 @@ impl Geometry {
pub fn new(topology: &Topology) -> Self {
let mut self_ = Self {
curve: BTreeMap::new(),
half_edge: BTreeMap::new(),
surface: BTreeMap::new(),
vertex: BTreeMap::new(),

Expand Down Expand Up @@ -80,14 +78,6 @@ impl Geometry {
.insert(surface, geometry);
}

pub(crate) fn define_half_edge_inner(
&mut self,
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeom,
) {
self.half_edge.insert(half_edge, geometry);
}

pub(crate) fn define_surface_inner(
&mut self,
surface: Handle<Surface>,
Expand Down Expand Up @@ -126,17 +116,6 @@ impl Geometry {
self.curve.get(curve)
}

/// # Access the geometry of the provided half-edge
///
/// ## Panics
///
/// Panics, if the geometry of the half-edge is not defined.
pub fn of_half_edge(&self, half_edge: &Handle<HalfEdge>) -> &HalfEdgeGeom {
self.half_edge
.get(half_edge)
.expect("Expected geometry of half-edge to be defined")
}

/// # Access the geometry of the provided surface
///
/// ## Panics
Expand Down
31 changes: 0 additions & 31 deletions crates/fj-core/src/geometry/half_edge.rs

This file was deleted.

4 changes: 1 addition & 3 deletions crates/fj-core/src/geometry/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Types that are tied to objects, but aren't objects themselves
//! Geometry that is applied to the topological object graph
mod boundary;
mod curve;
mod geometry;
mod half_edge;
mod path;
mod surface;
mod vertex;
Expand All @@ -12,7 +11,6 @@ pub use self::{
boundary::{CurveBoundary, CurveBoundaryElement},
curve::{CurveGeom, LocalCurveGeom},
geometry::Geometry,
half_edge::HalfEdgeGeom,
path::{GlobalPath, SurfacePath},
surface::SurfaceGeom,
vertex::{LocalVertexGeom, VertexGeom},
Expand Down
47 changes: 2 additions & 45 deletions crates/fj-core/src/layers/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! Layer infrastructure for [`Geometry`]
use crate::{
geometry::{
Geometry, HalfEdgeGeom, LocalCurveGeom, LocalVertexGeom, SurfaceGeom,
},
geometry::{Geometry, LocalCurveGeom, LocalVertexGeom, SurfaceGeom},
storage::Handle,
topology::{Curve, HalfEdge, Surface, Vertex},
topology::{Curve, Surface, Vertex},
};

use super::{Command, Event, Layer};
Expand All @@ -29,22 +27,6 @@ impl Layer<Geometry> {
);
}

/// Define the geometry of the provided half-edge
pub fn define_half_edge(
&mut self,
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeom,
) {
let mut events = Vec::new();
self.process(
DefineHalfEdge {
half_edge,
geometry,
},
&mut events,
);
}

/// # Define the geometry of the provided surface
///
/// ## Panics
Expand Down Expand Up @@ -109,31 +91,6 @@ impl Event<Geometry> for DefineCurve {
}
}

/// Define the geometry of a half-edge
pub struct DefineHalfEdge {
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeom,
}

impl Command<Geometry> for DefineHalfEdge {
type Result = ();
type Event = Self;

fn decide(
self,
_: &Geometry,
events: &mut Vec<Self::Event>,
) -> Self::Result {
events.push(self);
}
}

impl Event<Geometry> for DefineHalfEdge {
fn evolve(&self, state: &mut Geometry) {
state.define_half_edge_inner(self.half_edge.clone(), self.geometry);
}
}

/// Define the geometry of a surface
pub struct DefineSurface {
surface: Handle<Surface>,
Expand Down
21 changes: 3 additions & 18 deletions crates/fj-core/src/operations/build/half_edge.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use fj_math::{Arc, Point, Scalar};

use crate::{
geometry::{CurveBoundary, HalfEdgeGeom, LocalCurveGeom, SurfacePath},
operations::{
geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry},
insert::Insert,
},
geometry::{CurveBoundary, LocalCurveGeom, SurfacePath},
operations::{geometry::UpdateCurveGeometry, insert::Insert},
storage::Handle,
topology::{Curve, HalfEdge, Surface, Vertex},
Core,
Expand All @@ -31,12 +28,7 @@ pub trait BuildHalfEdge {
start_vertex: Handle<Vertex>,
core: &mut Core,
) -> Handle<HalfEdge> {
let mut geometry = *core.layers.geometry.of_half_edge(sibling);
geometry.boundary = geometry.boundary.reverse();

HalfEdge::new(sibling.curve().clone(), start_vertex)
.insert(core)
.set_geometry(geometry, &mut core.layers.geometry)
HalfEdge::new(sibling.curve().clone(), start_vertex).insert(core)
}

/// Create an arc
Expand Down Expand Up @@ -72,9 +64,6 @@ pub trait BuildHalfEdge {
surface,
LocalCurveGeom { path },
);
core.layers
.geometry
.define_half_edge(half_edge.clone(), HalfEdgeGeom { boundary });

(half_edge, boundary)
}
Expand All @@ -96,10 +85,6 @@ pub trait BuildHalfEdge {
&mut core.layers.geometry,
);

core.layers
.geometry
.define_half_edge(half_edge.clone(), HalfEdgeGeom { boundary });

(half_edge, boundary)
}
}
Expand Down
8 changes: 2 additions & 6 deletions crates/fj-core/src/operations/build/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use fj_interop::ext::ArrayExt;
use fj_math::Point;

use crate::{
geometry::{CurveBoundary, HalfEdgeGeom, LocalVertexGeom},
geometry::{CurveBoundary, LocalVertexGeom},
operations::{
build::{BuildFace, BuildHalfEdge, BuildSurface, Polygon},
geometry::{UpdateCurveGeometry, UpdateHalfEdgeGeometry},
geometry::UpdateCurveGeometry,
insert::{Insert, IsInserted, IsInsertedNo, IsInsertedYes},
join::JoinCycle,
reverse::ReverseCurveCoordinateSystems,
Expand Down Expand Up @@ -123,10 +123,6 @@ pub trait BuildShell {
)
.update_curve(|_, _| curve.clone(), core)
.insert(core)
.set_geometry(
HalfEdgeGeom { boundary },
&mut core.layers.geometry,
)
},
)
};
Expand Down
27 changes: 0 additions & 27 deletions crates/fj-core/src/operations/geometry/half_edge.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/fj-core/src/operations/geometry/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Operations to update the geometry of objects
mod curve;
mod half_edge;

pub use self::{curve::UpdateCurveGeometry, half_edge::UpdateHalfEdgeGeometry};
pub use self::curve::UpdateCurveGeometry;
Loading

0 comments on commit 44955d9

Please sign in to comment.