Rename SurfaceGeom to SweptCurve

Under the new geometry system, this is no longer "the surface geometry",
this is just one kind of surface geometry: A curve swept along a path.
This new name better reflects that.
This commit is contained in:
Hanno Braun 2024-10-11 18:05:47 +02:00
parent a08f4024c9
commit 251487f56d
8 changed files with 37 additions and 37 deletions

View File

@ -3,7 +3,7 @@ use std::collections::BTreeMap;
use fj_math::{Circle, Line, Point};
use crate::{
geometry::{CurveBoundary, Geometry, Path, SurfaceGeom, Tolerance},
geometry::{CurveBoundary, Geometry, Path, SweptCurve, Tolerance},
storage::Handle,
topology::{Curve, Surface},
};
@ -44,11 +44,11 @@ pub fn approx_curve_with_cache(
fn approx_curve(
path: &Path<2>,
surface: &SurfaceGeom,
surface: &SweptCurve,
boundary: CurveBoundary<Point<1>>,
tolerance: impl Into<Tolerance>,
) -> CurveApprox {
let SurfaceGeom { u, .. } = surface;
let SweptCurve { u, .. } = surface;
let points = match (path, u) {
(Path::Circle(_), Path::Circle(_)) => approx_circle_on_curved_surface(),
(Path::Circle(circle), Path::Line(_)) => {
@ -71,7 +71,7 @@ fn approx_circle_on_curved_surface() -> Vec<ApproxPoint<1>> {
fn approx_circle_on_straight_surface(
circle: &Circle<2>,
boundary: CurveBoundary<Point<1>>,
surface: &SurfaceGeom,
surface: &SweptCurve,
tolerance: impl Into<Tolerance>,
) -> Vec<ApproxPoint<1>> {
let tolerance = tolerance.into();
@ -103,7 +103,7 @@ fn approx_circle_on_straight_surface(
fn approx_line_on_any_surface(
line: &Line<2>,
boundary: CurveBoundary<Point<1>>,
surface: &SurfaceGeom,
surface: &SweptCurve,
tolerance: impl Into<Tolerance>,
) -> Vec<ApproxPoint<1>> {
let tolerance = tolerance.into();
@ -114,7 +114,7 @@ fn approx_line_on_any_surface(
.map(|point_curve| [line.point_from_line_coords(point_curve).u]),
);
let SurfaceGeom { u, .. } = surface;
let SweptCurve { u, .. } = surface;
let approx_u = match u {
Path::Circle(circle) => approx_circle(circle, range_u, tolerance),
Path::Line(line) => approx_line(line),
@ -197,7 +197,7 @@ mod tests {
algorithms::approx::{
circle::approx_circle, curve::approx_curve, ApproxPoint,
},
geometry::{CurveBoundary, Path, SurfaceGeom},
geometry::{CurveBoundary, Path, SweptCurve},
operations::build::BuildSurface,
topology::Surface,
Core,
@ -219,7 +219,7 @@ mod tests {
#[test]
fn approx_line_on_curved_surface_but_not_along_curve() {
let surface = SurfaceGeom {
let surface = SweptCurve {
u: Path::circle_from_radius(1.),
v: Vector::from([0., 0., 1.]),
};
@ -238,7 +238,7 @@ mod tests {
let circle = Circle::from_center_and_radius(Point::origin(), 1.);
let global_path = Path::Circle(circle);
let surface_geom = SurfaceGeom {
let surface_geom = SweptCurve {
u: global_path,
v: Vector::from([0., 0., 1.]),
};

View File

@ -3,7 +3,7 @@ use std::ops::Deref;
use fj_math::{Aabb, Vector};
use crate::{
geometry::{Geometry, Path, SurfaceGeom, Tolerance},
geometry::{Geometry, Path, SweptCurve, Tolerance},
topology::Face,
};
@ -14,7 +14,7 @@ impl super::BoundingVolume<3> for &Face {
.map(|aabb2| {
let surface = geometry.of_surface(self.surface());
let SurfaceGeom { u, v } = surface;
let SweptCurve { u, v } = surface;
match u {
Path::Circle(circle) => {
// This is not the most precise way to calculate the

View File

@ -9,14 +9,14 @@ use crate::{
use super::{
vertex::LocalVertexGeom, CurveGeom, CurveGeom2, LocalCurveGeom, Path,
SurfaceGeom, VertexGeom,
SweptCurve, VertexGeom,
};
/// Geometric data that is associated with topological objects
pub struct Geometry {
curve: BTreeMap<Handle<Curve>, CurveGeom>,
curve2: BTreeMap<Handle<Curve>, CurveGeom2>,
surface: BTreeMap<Handle<Surface>, SurfaceGeom>,
surface: BTreeMap<Handle<Surface>, SweptCurve>,
vertex: BTreeMap<Handle<Vertex>, VertexGeom>,
space_2d: Handle<Surface>,
@ -44,21 +44,21 @@ impl Geometry {
self_.define_surface_inner(
self_.xy_plane.clone(),
SurfaceGeom {
SweptCurve {
u: Path::x_axis(),
v: Vector::unit_y(),
},
);
self_.define_surface_inner(
self_.xz_plane.clone(),
SurfaceGeom {
SweptCurve {
u: Path::x_axis(),
v: Vector::unit_z(),
},
);
self_.define_surface_inner(
self_.yz_plane.clone(),
SurfaceGeom {
SweptCurve {
u: Path::y_axis(),
v: Vector::unit_z(),
},
@ -91,7 +91,7 @@ impl Geometry {
pub(crate) fn define_surface_inner(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeom,
geometry: SweptCurve,
) {
if surface == self.space_2d {
panic!("Attempting to define geometry for 2D space");
@ -143,7 +143,7 @@ impl Geometry {
/// ## Panics
///
/// Panics, if the geometry of the surface is not defined.
pub fn of_surface(&self, surface: &Handle<Surface>) -> &SurfaceGeom {
pub fn of_surface(&self, surface: &Handle<Surface>) -> &SweptCurve {
self.surface
.get(surface)
.expect("Expected geometry of surface to be defined")
@ -155,17 +155,17 @@ impl Geometry {
}
/// Access the geometry of the xy-plane
pub fn xy_plane(&self) -> &SurfaceGeom {
pub fn xy_plane(&self) -> &SweptCurve {
self.of_surface(&self.xy_plane)
}
/// Access the geometry of the xz-plane
pub fn xz_plane(&self) -> &SurfaceGeom {
pub fn xz_plane(&self) -> &SweptCurve {
self.of_surface(&self.xz_plane)
}
/// Access the geometry of the yz-plane
pub fn yz_plane(&self) -> &SurfaceGeom {
pub fn yz_plane(&self) -> &SweptCurve {
self.of_surface(&self.yz_plane)
}
}

View File

@ -17,7 +17,7 @@ pub use self::{
curve::{CurveGeom, CurveGeom2, LocalCurveGeom},
geometry::Geometry,
path::Path,
surface::SurfaceGeom,
surface::SweptCurve,
tolerance::{InvalidTolerance, Tolerance},
vertex::{LocalVertexGeom, VertexGeom},
};

View File

@ -6,7 +6,7 @@ use super::{traits::GenPolyline, Path, Tolerance};
/// The geometry that defines a surface
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceGeom {
pub struct SweptCurve {
/// The u-axis of the surface
pub u: Path<3>,
@ -14,7 +14,7 @@ pub struct SurfaceGeom {
pub v: Vector<3>,
}
impl SurfaceGeom {
impl SweptCurve {
/// # Access the origin of the surface
pub fn origin(&self) -> Point<3> {
self.u.origin()
@ -138,11 +138,11 @@ mod tests {
use fj_math::{Line, Point, Vector};
use pretty_assertions::assert_eq;
use crate::geometry::{Path, SurfaceGeom, Tolerance};
use crate::geometry::{Path, SweptCurve, Tolerance};
#[test]
fn point_from_surface_coords() {
let surface = SurfaceGeom {
let surface = SweptCurve {
u: Path::Line(Line::from_origin_and_direction(
Point::from([1., 1., 1.]),
Vector::from([0., 2., 0.]),
@ -161,7 +161,7 @@ mod tests {
#[test]
fn vector_from_surface_coords() {
let surface = SurfaceGeom {
let surface = SweptCurve {
u: Path::Line(Line::from_origin_and_direction(
Point::from([1., 0., 0.]),
Vector::from([0., 2., 0.]),

View File

@ -2,7 +2,7 @@
use crate::{
geometry::{
CurveGeom2, Geometry, LocalCurveGeom, LocalVertexGeom, SurfaceGeom,
CurveGeom2, Geometry, LocalCurveGeom, LocalVertexGeom, SweptCurve,
},
storage::Handle,
topology::{Curve, Surface, Vertex},
@ -55,7 +55,7 @@ impl Layer<Geometry> {
pub fn define_surface(
&mut self,
surface: Handle<Surface>,
geometry: SurfaceGeom,
geometry: SweptCurve,
) {
let mut events = Vec::new();
self.process(DefineSurface { surface, geometry }, &mut events);
@ -147,7 +147,7 @@ impl Event<Geometry> for DefineCurve2 {
/// Define the geometry of a surface
pub struct DefineSurface {
surface: Handle<Surface>,
geometry: SurfaceGeom,
geometry: SweptCurve,
}
impl Command<Geometry> for DefineSurface {

View File

@ -1,7 +1,7 @@
use fj_math::{Point, Scalar, Vector};
use crate::{
geometry::{Path, SurfaceGeom},
geometry::{Path, SweptCurve},
operations::insert::Insert,
storage::Handle,
topology::Surface,
@ -16,7 +16,7 @@ use crate::{
pub trait BuildSurface {
/// Build a surface from the provided geometry
fn from_geometry(
surface_geom: SurfaceGeom,
surface_geom: SweptCurve,
core: &mut Core,
) -> Handle<Surface> {
let surface = Surface::new().insert(core);
@ -35,7 +35,7 @@ pub trait BuildSurface {
core: &mut Core,
) -> Handle<Surface> {
Self::from_geometry(
SurfaceGeom {
SweptCurve {
u: u.into(),
v: v.into(),
},

View File

@ -1,7 +1,7 @@
use fj_math::{Circle, Line, Vector};
use crate::{
geometry::{Path, SurfaceGeom},
geometry::{Path, SweptCurve},
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: &SurfaceGeom,
surface: &SweptCurve,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface>;
@ -35,11 +35,11 @@ pub trait SweepSurfacePath {
impl SweepSurfacePath for Path<2> {
fn sweep_surface_path(
&self,
surface: &SurfaceGeom,
surface: &SweptCurve,
path: impl Into<Vector<3>>,
core: &mut Core,
) -> Handle<Surface> {
let SurfaceGeom { u, .. } = surface;
let SweptCurve { u, .. } = surface;
match u {
Path::Circle(_) => {
// Sweeping a `Curve` creates a `Surface`. The u-axis of that