Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten names of geometry structs #2304

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions crates/fj-core/src/algorithms/approx/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use fj_math::Point;

use crate::{
geometry::{
CurveBoundary, Geometry, GlobalPath, HalfEdgeGeometry, SurfaceGeometry,
CurveBoundary, Geometry, GlobalPath, HalfEdgeGeom, SurfaceGeom,
SurfacePath,
},
storage::Handle,
Expand All @@ -15,7 +15,7 @@ use crate::{

use super::{Approx, ApproxPoint, Tolerance};

impl Approx for (&Handle<Curve>, &HalfEdgeGeometry, &Handle<Surface>) {
impl Approx for (&Handle<Curve>, &HalfEdgeGeom, &Handle<Surface>) {
type Approximation = CurveApprox;
type Cache = CurveApproxCache;

Expand Down Expand Up @@ -46,7 +46,7 @@ impl Approx for (&Handle<Curve>, &HalfEdgeGeometry, &Handle<Surface>) {

fn approx_curve(
path: &SurfacePath,
surface: &SurfaceGeometry,
surface: &SurfaceGeom,
boundary: CurveBoundary<Point<1>>,
tolerance: impl Into<Tolerance>,
geometry: &Geometry,
Expand Down Expand Up @@ -182,7 +182,7 @@ mod tests {

use crate::{
algorithms::approx::{Approx, ApproxPoint},
geometry::{CurveBoundary, GlobalPath, HalfEdgeGeometry, SurfacePath},
geometry::{CurveBoundary, GlobalPath, HalfEdgeGeom, SurfacePath},
operations::{build::BuildSurface, insert::Insert},
topology::{Curve, Surface},
Core,
Expand All @@ -196,7 +196,7 @@ mod tests {
let (path, boundary) =
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
let boundary = CurveBoundary::from(boundary);
let half_edge = HalfEdgeGeometry { path, boundary };
let half_edge = HalfEdgeGeom { path, boundary };
let surface = core.layers.topology.surfaces.xz_plane();

let tolerance = 1.;
Expand All @@ -214,7 +214,7 @@ mod tests {
let (path, boundary) =
SurfacePath::line_from_points([[1., 1.], [2., 1.]]);
let boundary = CurveBoundary::from(boundary);
let half_edge = HalfEdgeGeometry { path, boundary };
let half_edge = HalfEdgeGeom { path, boundary };
let surface = Surface::from_uv(
GlobalPath::circle_from_radius(1.),
[0., 0., 1.],
Expand All @@ -239,7 +239,7 @@ mod tests {
([TAU], [TAU, 1.]),
]);
let boundary = CurveBoundary::from([[0.], [TAU]]);
let half_edge = HalfEdgeGeometry { path, boundary };
let half_edge = HalfEdgeGeom { path, boundary };
let surface = Surface::from_uv(global_path, [0., 0., 1.], &mut core);

let tolerance = 1.;
Expand Down Expand Up @@ -269,7 +269,7 @@ mod tests {
let curve = Curve::new().insert(&mut core);
let path = SurfacePath::circle_from_center_and_radius([0., 0.], 1.);
let boundary = CurveBoundary::from([[0.], [TAU]]);
let half_edge = HalfEdgeGeometry { path, boundary };
let half_edge = HalfEdgeGeom { path, boundary };
let surface = core.layers.topology.surfaces.xz_plane();

let tolerance = 1.;
Expand Down
29 changes: 13 additions & 16 deletions crates/fj-core/src/geometry/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::{
topology::{HalfEdge, Surface, Topology},
};

use super::{GlobalPath, HalfEdgeGeometry, SurfaceGeometry};
use super::{GlobalPath, HalfEdgeGeom, SurfaceGeom};

/// Geometric data that is associated with topological objects
pub struct Geometry {
half_edge: BTreeMap<Handle<HalfEdge>, HalfEdgeGeometry>,
surface: BTreeMap<Handle<Surface>, SurfaceGeometry>,
half_edge: BTreeMap<Handle<HalfEdge>, HalfEdgeGeom>,
surface: BTreeMap<Handle<Surface>, SurfaceGeom>,

xy_plane: Handle<Surface>,
xz_plane: Handle<Surface>,
Expand All @@ -33,21 +33,21 @@ impl Geometry {

self_.define_surface_inner(
self_.xy_plane.clone(),
SurfaceGeometry {
SurfaceGeom {
u: GlobalPath::x_axis(),
v: Vector::unit_y(),
},
);
self_.define_surface_inner(
self_.xz_plane.clone(),
SurfaceGeometry {
SurfaceGeom {
u: GlobalPath::x_axis(),
v: Vector::unit_z(),
},
);
self_.define_surface_inner(
self_.yz_plane.clone(),
SurfaceGeometry {
SurfaceGeom {
u: GlobalPath::y_axis(),
v: Vector::unit_z(),
},
Expand All @@ -59,15 +59,15 @@ impl Geometry {
pub(crate) fn define_half_edge_inner(
&mut self,
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeometry,
geometry: HalfEdgeGeom,
) {
self.half_edge.insert(half_edge, geometry);
}

pub(crate) fn define_surface_inner(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeometry,
geometry: SurfaceGeom,
) {
self.surface.insert(surface, geometry);
}
Expand All @@ -77,10 +77,7 @@ impl Geometry {
/// ## Panics
///
/// Panics, if the geometry of the half-edge is not defined.
pub fn of_half_edge(
&self,
half_edge: &Handle<HalfEdge>,
) -> &HalfEdgeGeometry {
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")
Expand All @@ -91,24 +88,24 @@ impl Geometry {
/// ## Panics
///
/// Panics, if the geometry of the surface is not defined.
pub fn of_surface(&self, surface: &Handle<Surface>) -> &SurfaceGeometry {
pub fn of_surface(&self, surface: &Handle<Surface>) -> &SurfaceGeom {
self.surface
.get(surface)
.expect("Expected geometry of surface to be defined")
}

/// Access the geometry of the xy-plane
pub fn xy_plane(&self) -> &SurfaceGeometry {
pub fn xy_plane(&self) -> &SurfaceGeom {
self.of_surface(&self.xy_plane)
}

/// Access the geometry of the xz-plane
pub fn xz_plane(&self) -> &SurfaceGeometry {
pub fn xz_plane(&self) -> &SurfaceGeom {
self.of_surface(&self.xz_plane)
}

/// Access the geometry of the yz-plane
pub fn yz_plane(&self) -> &SurfaceGeometry {
pub fn yz_plane(&self) -> &SurfaceGeom {
self.of_surface(&self.yz_plane)
}
}
4 changes: 2 additions & 2 deletions crates/fj-core/src/geometry/half_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{CurveBoundary, SurfacePath};

/// The geometry of a half-edge
#[derive(Copy, Clone)]
pub struct HalfEdgeGeometry {
pub struct HalfEdgeGeom {
/// # The path of the half-edge
///
/// ## Implementation Note
Expand Down Expand Up @@ -36,7 +36,7 @@ pub struct HalfEdgeGeometry {
pub boundary: CurveBoundary<Point<1>>,
}

impl HalfEdgeGeometry {
impl HalfEdgeGeom {
/// Update the boundary
pub fn with_boundary(
mut self,
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-core/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod surface;
pub use self::{
boundary::{CurveBoundary, CurveBoundaryElement},
geometry::Geometry,
half_edge::HalfEdgeGeometry,
half_edge::HalfEdgeGeom,
path::{GlobalPath, SurfacePath},
surface::SurfaceGeometry,
surface::SurfaceGeom,
};
10 changes: 5 additions & 5 deletions crates/fj-core/src/geometry/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use super::GlobalPath;

/// The geometry that defines a surface
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceGeometry {
pub struct SurfaceGeom {
/// The u-axis of the surface
pub u: GlobalPath,

/// The v-axis of the surface
pub v: Vector<3>,
}

impl SurfaceGeometry {
impl SurfaceGeom {
/// Convert a point in surface coordinates to model coordinates
pub fn point_from_surface_coords(
&self,
Expand Down Expand Up @@ -64,11 +64,11 @@ mod tests {
use fj_math::{Line, Point, Vector};
use pretty_assertions::assert_eq;

use crate::geometry::{GlobalPath, SurfaceGeometry};
use crate::geometry::{GlobalPath, SurfaceGeom};

#[test]
fn point_from_surface_coords() {
let surface = SurfaceGeometry {
let surface = SurfaceGeom {
u: GlobalPath::Line(Line::from_origin_and_direction(
Point::from([1., 1., 1.]),
Vector::from([0., 2., 0.]),
Expand All @@ -84,7 +84,7 @@ mod tests {

#[test]
fn vector_from_surface_coords() {
let surface = SurfaceGeometry {
let surface = SurfaceGeom {
u: GlobalPath::Line(Line::from_origin_and_direction(
Point::from([1., 0., 0.]),
Vector::from([0., 2., 0.]),
Expand Down
10 changes: 5 additions & 5 deletions crates/fj-core/src/layers/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Layer infrastructure for [`Geometry`]

use crate::{
geometry::{Geometry, HalfEdgeGeometry, SurfaceGeometry},
geometry::{Geometry, HalfEdgeGeom, SurfaceGeom},
storage::Handle,
topology::{HalfEdge, Surface},
};
Expand All @@ -13,7 +13,7 @@ impl Layer<Geometry> {
pub fn define_half_edge(
&mut self,
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeometry,
geometry: HalfEdgeGeom,
) {
let mut events = Vec::new();
self.process(
Expand All @@ -29,7 +29,7 @@ impl Layer<Geometry> {
pub fn define_surface(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeometry,
geometry: SurfaceGeom,
) {
let mut events = Vec::new();
self.process(DefineSurface { surface, geometry }, &mut events);
Expand All @@ -39,7 +39,7 @@ impl Layer<Geometry> {
/// Define the geometry of a half-edge
pub struct DefineHalfEdge {
half_edge: Handle<HalfEdge>,
geometry: HalfEdgeGeometry,
geometry: HalfEdgeGeom,
}

impl Command<Geometry> for DefineHalfEdge {
Expand All @@ -64,7 +64,7 @@ impl Event<Geometry> for DefineHalfEdge {
/// Define the geometry of a surface
pub struct DefineSurface {
surface: Handle<Surface>,
geometry: SurfaceGeometry,
geometry: SurfaceGeom,
}

impl Command<Geometry> for DefineSurface {
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-core/src/operations/build/half_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_interop::ext::ArrayExt;
use fj_math::{Arc, Point, Scalar};

use crate::{
geometry::{HalfEdgeGeometry, SurfacePath},
geometry::{HalfEdgeGeom, SurfacePath},
operations::{geometry::UpdateHalfEdgeGeometry, insert::Insert},
storage::Handle,
topology::{Curve, HalfEdge, Vertex},
Expand Down Expand Up @@ -63,7 +63,7 @@ pub trait BuildHalfEdge {
let half_edge = HalfEdge::unjoined(core).insert(core);
core.layers.geometry.define_half_edge(
half_edge.clone(),
HalfEdgeGeometry {
HalfEdgeGeom {
path,
boundary: boundary.into(),
},
Expand All @@ -85,7 +85,7 @@ pub trait BuildHalfEdge {
let half_edge = HalfEdge::unjoined(core).insert(core);
core.layers.geometry.define_half_edge(
half_edge.clone(),
HalfEdgeGeometry {
HalfEdgeGeom {
path,
boundary: boundary.into(),
},
Expand All @@ -107,7 +107,7 @@ pub trait BuildHalfEdge {
);

HalfEdge::unjoined(core).insert(core).set_geometry(
HalfEdgeGeometry {
HalfEdgeGeom {
path,
boundary: boundary.into(),
},
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-core/src/operations/build/surface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fj_math::{Point, Scalar, Vector};

use crate::{
geometry::{GlobalPath, SurfaceGeometry},
geometry::{GlobalPath, SurfaceGeom},
operations::insert::Insert,
storage::Handle,
topology::Surface,
Expand Down Expand Up @@ -47,7 +47,7 @@ pub trait BuildSurface {

core.layers.geometry.define_surface(
surface.clone(),
SurfaceGeometry {
SurfaceGeom {
u: u.into(),
v: v.into(),
},
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-core/src/operations/geometry/half_edge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
geometry::{Geometry, HalfEdgeGeometry},
geometry::{Geometry, HalfEdgeGeom},
layers::Layer,
storage::Handle,
topology::HalfEdge,
Expand All @@ -10,15 +10,15 @@ pub trait UpdateHalfEdgeGeometry {
/// Set the path of the half-edge
fn set_geometry(
self,
geometry: HalfEdgeGeometry,
geometry: HalfEdgeGeom,
layer: &mut Layer<Geometry>,
) -> Self;
}

impl UpdateHalfEdgeGeometry for Handle<HalfEdge> {
fn set_geometry(
self,
geometry: HalfEdgeGeometry,
geometry: HalfEdgeGeom,
layer: &mut Layer<Geometry>,
) -> Self {
layer.define_half_edge(self.clone(), geometry);
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-core/src/operations/join/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
use itertools::Itertools;

use crate::{
geometry::HalfEdgeGeometry,
geometry::HalfEdgeGeom,
operations::{
build::BuildHalfEdge,
geometry::UpdateHalfEdgeGeometry,
Expand All @@ -21,7 +21,7 @@ pub trait JoinCycle {
#[must_use]
fn add_joined_edges<Es>(&self, edges: Es, core: &mut Core) -> Self
where
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeometry)>,
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
Es::IntoIter: Clone + ExactSizeIterator;

/// Join the cycle to another
Expand Down Expand Up @@ -78,7 +78,7 @@ pub trait JoinCycle {
impl JoinCycle for Cycle {
fn add_joined_edges<Es>(&self, edges: Es, core: &mut Core) -> Self
where
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeometry)>,
Es: IntoIterator<Item = (Handle<HalfEdge>, HalfEdgeGeom)>,
Es::IntoIter: Clone + ExactSizeIterator,
{
let half_edges = edges
Expand Down
Loading