Shorten SurfaceGeometry to SurfaceGeom

Geometry is a very common concept within `fj-core`, and
`SurfaceGeometry` is used in many places. A shorthand seems justified.
This commit is contained in:
Hanno Braun 2024-03-27 12:17:44 +01:00
parent 2b49b57faf
commit a8559a074b
8 changed files with 32 additions and 32 deletions

View File

@ -6,7 +6,7 @@ use fj_math::Point;
use crate::{
geometry::{
CurveBoundary, Geometry, GlobalPath, HalfEdgeGeom, SurfaceGeometry,
CurveBoundary, Geometry, GlobalPath, HalfEdgeGeom, SurfaceGeom,
SurfacePath,
},
storage::Handle,
@ -46,7 +46,7 @@ impl Approx for (&Handle<Curve>, &HalfEdgeGeom, &Handle<Surface>) {
fn approx_curve(
path: &SurfacePath,
surface: &SurfaceGeometry,
surface: &SurfaceGeom,
boundary: CurveBoundary<Point<1>>,
tolerance: impl Into<Tolerance>,
geometry: &Geometry,

View File

@ -7,12 +7,12 @@ use crate::{
topology::{HalfEdge, Surface, Topology},
};
use super::{GlobalPath, HalfEdgeGeom, SurfaceGeometry};
use super::{GlobalPath, HalfEdgeGeom, SurfaceGeom};
/// Geometric data that is associated with topological objects
pub struct Geometry {
half_edge: BTreeMap<Handle<HalfEdge>, HalfEdgeGeom>,
surface: BTreeMap<Handle<Surface>, SurfaceGeometry>,
surface: BTreeMap<Handle<Surface>, SurfaceGeom>,
xy_plane: Handle<Surface>,
xz_plane: Handle<Surface>,
@ -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(),
},
@ -67,7 +67,7 @@ impl Geometry {
pub(crate) fn define_surface_inner(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeometry,
geometry: SurfaceGeom,
) {
self.surface.insert(surface, geometry);
}
@ -88,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)
}
}

View File

@ -11,5 +11,5 @@ pub use self::{
geometry::Geometry,
half_edge::HalfEdgeGeom,
path::{GlobalPath, SurfacePath},
surface::SurfaceGeometry,
surface::SurfaceGeom,
};

View File

@ -6,7 +6,7 @@ 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,
@ -14,7 +14,7 @@ pub struct SurfaceGeometry {
pub v: Vector<3>,
}
impl SurfaceGeometry {
impl SurfaceGeom {
/// Convert a point in surface coordinates to model coordinates
pub fn point_from_surface_coords(
&self,
@ -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.]),
@ -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.]),

View File

@ -1,7 +1,7 @@
//! Layer infrastructure for [`Geometry`]
use crate::{
geometry::{Geometry, HalfEdgeGeom, SurfaceGeometry},
geometry::{Geometry, HalfEdgeGeom, SurfaceGeom},
storage::Handle,
topology::{HalfEdge, Surface},
};
@ -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);
@ -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 {

View File

@ -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,
@ -47,7 +47,7 @@ pub trait BuildSurface {
core.layers.geometry.define_surface(
surface.clone(),
SurfaceGeometry {
SurfaceGeom {
u: u.into(),
v: v.into(),
},

View File

@ -1,7 +1,7 @@
use fj_math::{Circle, Line, Vector};
use crate::{
geometry::{GlobalPath, SurfaceGeometry, SurfacePath},
geometry::{GlobalPath, SurfaceGeom, SurfacePath},
operations::build::BuildSurface,
storage::Handle,
topology::Surface,
@ -26,7 +26,7 @@ pub trait SweepSurfacePath {
/// <https://github.com/hannobraun/fornjot/issues/1112>
fn sweep_surface_path(
&self,
surface: &SurfaceGeometry,
surface: &SurfaceGeom,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface>;
@ -35,7 +35,7 @@ pub trait SweepSurfacePath {
impl SweepSurfacePath for SurfacePath {
fn sweep_surface_path(
&self,
surface: &SurfaceGeometry,
surface: &SurfaceGeom,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface> {

View File

@ -3,7 +3,7 @@ use std::{collections::BTreeMap, fmt};
use fj_math::{Point, Scalar};
use crate::{
geometry::{CurveBoundary, Geometry, SurfaceGeometry},
geometry::{CurveBoundary, Geometry, SurfaceGeom},
queries::{
AllHalfEdgesWithSurface, BoundingVerticesOfHalfEdge, SiblingOfHalfEdge,
},
@ -101,9 +101,9 @@ impl ShellValidationError {
fn compare_curve_coords(
edge_a: &Handle<HalfEdge>,
surface_a: &SurfaceGeometry,
surface_a: &SurfaceGeom,
edge_b: &Handle<HalfEdge>,
surface_b: &SurfaceGeometry,
surface_b: &SurfaceGeom,
geometry: &Geometry,
config: &ValidationConfig,
mismatches: &mut Vec<CurveCoordinateSystemMismatch>,
@ -382,14 +382,14 @@ impl fmt::Display for CoincidentHalfEdgeVertices {
/// Returns an [`Iterator`] of the distance at each sample.
fn distances(
edge_a: Handle<HalfEdge>,
surface_a: &SurfaceGeometry,
surface_a: &SurfaceGeom,
edge_b: Handle<HalfEdge>,
surface_b: &SurfaceGeometry,
surface_b: &SurfaceGeom,
geometry: &Geometry,
) -> impl Iterator<Item = Scalar> {
fn sample(
percent: f64,
(edge, surface): (&Handle<HalfEdge>, &SurfaceGeometry),
(edge, surface): (&Handle<HalfEdge>, &SurfaceGeom),
geometry: &Geometry,
) -> Point<3> {
let [start, end] = geometry.of_half_edge(edge).boundary.inner;