Merge pull request #1617 from hannobraun/curve

Rename `SurfacePath` to `Curve`
This commit is contained in:
Hanno Braun 2023-02-24 16:35:33 +01:00 committed by GitHub
commit bead9dbef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 102 additions and 107 deletions

View File

@ -8,7 +8,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use crate::{ use crate::{
geometry::path::{GlobalPath, SurfacePath}, geometry::curve::{Curve, GlobalPath},
objects::{GlobalEdge, HalfEdge, Surface}, objects::{GlobalEdge, HalfEdge, Surface},
storage::{Handle, ObjectId}, storage::{Handle, ObjectId},
}; };
@ -91,7 +91,7 @@ impl HalfEdgeApprox {
} }
fn approx_edge( fn approx_edge(
curve: &SurfacePath, curve: &Curve,
surface: &Surface, surface: &Surface,
range: RangeOnPath, range: RangeOnPath,
tolerance: impl Into<Tolerance>, tolerance: impl Into<Tolerance>,
@ -103,12 +103,12 @@ fn approx_edge(
// `GlobalPath` grow APIs that are better suited to implementing this code // `GlobalPath` grow APIs that are better suited to implementing this code
// in a more abstract way. // in a more abstract way.
let points = match (curve, surface.geometry().u) { let points = match (curve, surface.geometry().u) {
(SurfacePath::Circle(_), GlobalPath::Circle(_)) => { (Curve::Circle(_), GlobalPath::Circle(_)) => {
todo!( todo!(
"Approximating a circle on a curved surface not supported yet." "Approximating a circle on a curved surface not supported yet."
) )
} }
(SurfacePath::Circle(_), GlobalPath::Line(_)) => { (Curve::Circle(_), GlobalPath::Line(_)) => {
(curve, range) (curve, range)
.approx_with_cache(tolerance, &mut ()) .approx_with_cache(tolerance, &mut ())
.into_iter() .into_iter()
@ -135,7 +135,7 @@ fn approx_edge(
}) })
.collect() .collect()
} }
(SurfacePath::Line(line), _) => { (Curve::Line(line), _) => {
let range_u = let range_u =
RangeOnPath::from(range.boundary.map(|point_curve| { RangeOnPath::from(range.boundary.map(|point_curve| {
[curve.point_from_path_coords(point_curve).u] [curve.point_from_path_coords(point_curve).u]
@ -232,7 +232,7 @@ mod tests {
use crate::{ use crate::{
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint}, algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
builder::{HalfEdgeBuilder, SurfaceBuilder}, builder::{HalfEdgeBuilder, SurfaceBuilder},
geometry::path::GlobalPath, geometry::curve::GlobalPath,
insert::Insert, insert::Insert,
partial::{PartialHalfEdge, PartialObject, PartialSurface}, partial::{PartialHalfEdge, PartialObject, PartialSurface},
services::Services, services::Services,

View File

@ -32,11 +32,11 @@ use std::iter;
use fj_math::{Circle, Point, Scalar, Sign}; use fj_math::{Circle, Point, Scalar, Sign};
use crate::geometry::path::{GlobalPath, SurfacePath}; use crate::geometry::curve::{Curve, GlobalPath};
use super::{Approx, Tolerance}; use super::{Approx, Tolerance};
impl Approx for (&SurfacePath, RangeOnPath) { impl Approx for (&Curve, RangeOnPath) {
type Approximation = Vec<(Point<1>, Point<2>)>; type Approximation = Vec<(Point<1>, Point<2>)>;
type Cache = (); type Cache = ();
@ -48,10 +48,10 @@ impl Approx for (&SurfacePath, RangeOnPath) {
let (path, range) = self; let (path, range) = self;
match path { match path {
SurfacePath::Circle(circle) => { Curve::Circle(circle) => {
approx_circle(circle, range, tolerance.into()) approx_circle(circle, range, tolerance.into())
} }
SurfacePath::Line(_) => vec![], Curve::Line(_) => vec![],
} }
} }
} }

View File

@ -1,6 +1,6 @@
use fj_math::{Point, Segment}; use fj_math::{Point, Segment};
use crate::{geometry::path::SurfacePath, objects::HalfEdge}; use crate::{geometry::curve::Curve, objects::HalfEdge};
use super::LineSegmentIntersection; use super::LineSegmentIntersection;
@ -28,15 +28,15 @@ impl CurveEdgeIntersection {
/// Currently, only intersections between lines and line segments can be /// Currently, only intersections between lines and line segments can be
/// computed. Panics, if a different type of curve or [`HalfEdge`] is /// computed. Panics, if a different type of curve or [`HalfEdge`] is
/// passed. /// passed.
pub fn compute(curve: &SurfacePath, half_edge: &HalfEdge) -> Option<Self> { pub fn compute(curve: &Curve, half_edge: &HalfEdge) -> Option<Self> {
let curve_as_line = match curve { let curve_as_line = match curve {
SurfacePath::Line(line) => line, Curve::Line(line) => line,
_ => todo!("Curve-edge intersection only supports lines"), _ => todo!("Curve-edge intersection only supports lines"),
}; };
let edge_as_segment = { let edge_as_segment = {
let edge_curve_as_line = match half_edge.curve() { let edge_curve_as_line = match half_edge.curve() {
SurfacePath::Line(line) => line, Curve::Line(line) => line,
_ => { _ => {
todo!("Curve-edge intersection only supports line segments") todo!("Curve-edge intersection only supports line segments")
} }
@ -73,7 +73,7 @@ mod tests {
use crate::{ use crate::{
builder::HalfEdgeBuilder, builder::HalfEdgeBuilder,
geometry::path::SurfacePath, geometry::curve::Curve,
partial::{PartialHalfEdge, PartialObject}, partial::{PartialHalfEdge, PartialObject},
services::Services, services::Services,
}; };
@ -85,7 +85,7 @@ mod tests {
let mut services = Services::new(); let mut services = Services::new();
let surface = services.objects.surfaces.xy_plane(); let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis(); let curve = Curve::u_axis();
let half_edge = { let half_edge = {
let mut half_edge = PartialHalfEdge::default(); let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points([[1., -1.], [1., 1.]]); half_edge.update_as_line_segment_from_points([[1., -1.], [1., 1.]]);
@ -109,7 +109,7 @@ mod tests {
let mut services = Services::new(); let mut services = Services::new();
let surface = services.objects.surfaces.xy_plane(); let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis(); let curve = Curve::u_axis();
let half_edge = { let half_edge = {
let mut half_edge = PartialHalfEdge::default(); let mut half_edge = PartialHalfEdge::default();
half_edge half_edge
@ -134,7 +134,7 @@ mod tests {
let mut services = Services::new(); let mut services = Services::new();
let surface = services.objects.surfaces.xy_plane(); let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis(); let curve = Curve::u_axis();
let half_edge = { let half_edge = {
let mut half_edge = PartialHalfEdge::default(); let mut half_edge = PartialHalfEdge::default();
half_edge half_edge
@ -154,7 +154,7 @@ mod tests {
let mut services = Services::new(); let mut services = Services::new();
let surface = services.objects.surfaces.xy_plane(); let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis(); let curve = Curve::u_axis();
let half_edge = { let half_edge = {
let mut half_edge = PartialHalfEdge::default(); let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points([[-1., 0.], [1., 0.]]); half_edge.update_as_line_segment_from_points([[-1., 0.], [1., 0.]]);

View File

@ -3,7 +3,7 @@ use std::vec;
use fj_interop::ext::SliceExt; use fj_interop::ext::SliceExt;
use fj_math::Point; use fj_math::Point;
use crate::{geometry::path::SurfacePath, objects::Face}; use crate::{geometry::curve::Curve, objects::Face};
use super::CurveEdgeIntersection; use super::CurveEdgeIntersection;
@ -28,7 +28,7 @@ impl CurveFaceIntersection {
} }
/// Compute the intersection /// Compute the intersection
pub fn compute(curve: &SurfacePath, face: &Face) -> Self { pub fn compute(curve: &Curve, face: &Face) -> Self {
let half_edges = face.all_cycles().flat_map(|cycle| cycle.half_edges()); let half_edges = face.all_cycles().flat_map(|cycle| cycle.half_edges());
let mut intersections = Vec::new(); let mut intersections = Vec::new();
@ -151,7 +151,7 @@ where
mod tests { mod tests {
use crate::{ use crate::{
builder::{CycleBuilder, FaceBuilder}, builder::{CycleBuilder, FaceBuilder},
geometry::path::SurfacePath, geometry::curve::Curve,
partial::{Partial, PartialFace, PartialObject}, partial::{Partial, PartialFace, PartialObject},
services::Services, services::Services,
}; };
@ -162,7 +162,7 @@ mod tests {
fn compute() { fn compute() {
let mut services = Services::new(); let mut services = Services::new();
let (curve, _) = SurfacePath::line_from_points([[-3., 0.], [-2., 0.]]); let (curve, _) = Curve::line_from_points([[-3., 0.], [-2., 0.]]);
#[rustfmt::skip] #[rustfmt::skip]
let exterior = [ let exterior = [

View File

@ -1,7 +1,7 @@
use fj_interop::ext::ArrayExt; use fj_interop::ext::ArrayExt;
use iter_fixed::IntoIteratorFixed; use iter_fixed::IntoIteratorFixed;
use crate::{geometry::path::SurfacePath, objects::Face}; use crate::{geometry::curve::Curve, objects::Face};
use super::{CurveFaceIntersection, SurfaceSurfaceIntersection}; use super::{CurveFaceIntersection, SurfaceSurfaceIntersection};
@ -14,7 +14,7 @@ pub struct FaceFaceIntersection {
/// representation of the intersection on the respective face's surface. /// representation of the intersection on the respective face's surface.
/// ///
/// They both represent the same global curve. /// They both represent the same global curve.
pub intersection_curves: [SurfacePath; 2], pub intersection_curves: [Curve; 2],
/// The interval of this intersection, in curve coordinates /// The interval of this intersection, in curve coordinates
/// ///
@ -63,7 +63,7 @@ mod tests {
use crate::{ use crate::{
algorithms::intersect::CurveFaceIntersection, algorithms::intersect::CurveFaceIntersection,
builder::CycleBuilder, builder::CycleBuilder,
geometry::path::SurfacePath, geometry::curve::Curve,
partial::{Partial, PartialFace, PartialObject}, partial::{Partial, PartialFace, PartialObject},
services::Services, services::Services,
}; };
@ -128,7 +128,7 @@ mod tests {
let intersection = FaceFaceIntersection::compute([&a, &b]); let intersection = FaceFaceIntersection::compute([&a, &b]);
let expected_curves = surfaces.map(|_| { let expected_curves = surfaces.map(|_| {
let (path, _) = SurfacePath::line_from_points([[0., 0.], [1., 0.]]); let (path, _) = Curve::line_from_points([[0., 0.], [1., 0.]]);
path path
}); });
let expected_intervals = let expected_intervals =

View File

@ -4,7 +4,7 @@ use fj_math::Segment;
use crate::{ use crate::{
algorithms::intersect::{HorizontalRayToTheRight, Intersect}, algorithms::intersect::{HorizontalRayToTheRight, Intersect},
geometry::path::SurfacePath, geometry::curve::Curve,
objects::HalfEdge, objects::HalfEdge,
storage::Handle, storage::Handle,
}; };
@ -18,8 +18,8 @@ impl Intersect for (&HorizontalRayToTheRight<2>, &Handle<HalfEdge>) {
let (ray, edge) = self; let (ray, edge) = self;
let line = match edge.curve() { let line = match edge.curve() {
SurfacePath::Line(line) => line, Curve::Line(line) => line,
SurfacePath::Circle(_) => { Curve::Circle(_) => {
todo!("Casting rays against circles is not supported yet") todo!("Casting rays against circles is not supported yet")
} }
}; };

View File

@ -4,7 +4,7 @@ use fj_math::{Plane, Point, Scalar};
use crate::{ use crate::{
algorithms::intersect::face_point::FacePointIntersection, algorithms::intersect::face_point::FacePointIntersection,
geometry::path::GlobalPath, geometry::curve::GlobalPath,
objects::{Face, HalfEdge, SurfaceVertex}, objects::{Face, HalfEdge, SurfaceVertex},
storage::Handle, storage::Handle,
}; };

View File

@ -1,7 +1,7 @@
use fj_math::{Line, Plane, Point, Scalar}; use fj_math::{Line, Plane, Point, Scalar};
use crate::{ use crate::{
geometry::path::{GlobalPath, SurfacePath}, geometry::curve::{Curve, GlobalPath},
objects::Surface, objects::Surface,
storage::Handle, storage::Handle,
}; };
@ -10,7 +10,7 @@ use crate::{
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceSurfaceIntersection { pub struct SurfaceSurfaceIntersection {
/// The intersection curves /// The intersection curves
pub intersection_curves: [SurfacePath; 2], pub intersection_curves: [Curve; 2],
} }
impl SurfaceSurfaceIntersection { impl SurfaceSurfaceIntersection {
@ -48,8 +48,7 @@ impl SurfaceSurfaceIntersection {
let line = Line::from_origin_and_direction(origin, direction); let line = Line::from_origin_and_direction(origin, direction);
let curves = let curves = planes.map(|plane| Curve::Line(plane.project_line(&line)));
planes.map(|plane| SurfacePath::Line(plane.project_line(&line)));
Some(Self { Some(Self {
intersection_curves: curves, intersection_curves: curves,
@ -76,7 +75,7 @@ mod tests {
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use crate::{ use crate::{
algorithms::transform::TransformObject, geometry::path::SurfacePath, algorithms::transform::TransformObject, geometry::curve::Curve,
services::Services, services::Services,
}; };
@ -101,8 +100,8 @@ mod tests {
None, None,
); );
let expected_xy = SurfacePath::u_axis(); let expected_xy = Curve::u_axis();
let expected_xz = SurfacePath::u_axis(); let expected_xz = Curve::u_axis();
assert_eq!( assert_eq!(
SurfaceSurfaceIntersection::compute([xy, xz],), SurfaceSurfaceIntersection::compute([xy, xz],),

View File

@ -2,7 +2,7 @@ use fj_math::{Circle, Line, Vector};
use crate::{ use crate::{
builder::SurfaceBuilder, builder::SurfaceBuilder,
geometry::path::{GlobalPath, SurfacePath}, geometry::curve::{Curve, GlobalPath},
insert::Insert, insert::Insert,
objects::{Objects, Surface}, objects::{Objects, Surface},
partial::{PartialObject, PartialSurface}, partial::{PartialObject, PartialSurface},
@ -12,7 +12,7 @@ use crate::{
use super::{Sweep, SweepCache}; use super::{Sweep, SweepCache};
impl Sweep for (SurfacePath, &Surface) { impl Sweep for (Curve, &Surface) {
type Swept = Handle<Surface>; type Swept = Handle<Surface>;
fn sweep_with_cache( fn sweep_with_cache(
@ -48,7 +48,7 @@ impl Sweep for (SurfacePath, &Surface) {
} }
let u = match curve { let u = match curve {
SurfacePath::Circle(circle) => { Curve::Circle(circle) => {
let center = surface let center = surface
.geometry() .geometry()
.point_from_surface_coords(circle.center()); .point_from_surface_coords(circle.center());
@ -61,7 +61,7 @@ impl Sweep for (SurfacePath, &Surface) {
GlobalPath::Circle(circle) GlobalPath::Circle(circle)
} }
SurfacePath::Line(line) => { Curve::Line(line) => {
let origin = let origin =
surface.geometry().point_from_surface_coords(line.origin()); surface.geometry().point_from_surface_coords(line.origin());
let direction = surface let direction = surface

View File

@ -6,7 +6,7 @@ use fj_math::{Scalar, Vector};
use crate::{ use crate::{
algorithms::{reverse::Reverse, transform::TransformObject}, algorithms::{reverse::Reverse, transform::TransformObject},
builder::{CycleBuilder, FaceBuilder}, builder::{CycleBuilder, FaceBuilder},
geometry::path::GlobalPath, geometry::curve::GlobalPath,
insert::Insert, insert::Insert,
objects::{Face, Objects, Shell}, objects::{Face, Objects, Shell},
partial::{Partial, PartialFace, PartialObject, PartialShell}, partial::{Partial, PartialFace, PartialObject, PartialShell},

View File

@ -3,11 +3,11 @@ use fj_math::{Point, Scalar};
use crate::{ use crate::{
geometry::{ geometry::{
path::{GlobalPath, SurfacePath}, curve::{Curve, GlobalPath},
surface::SurfaceGeometry, surface::SurfaceGeometry,
}, },
objects::{GlobalEdge, HalfEdge}, objects::{GlobalEdge, HalfEdge},
partial::{MaybeSurfacePath, Partial, PartialGlobalEdge, PartialHalfEdge}, partial::{MaybeCurve, Partial, PartialGlobalEdge, PartialHalfEdge},
}; };
/// Builder API for [`PartialHalfEdge`] /// Builder API for [`PartialHalfEdge`]
@ -15,18 +15,18 @@ pub trait HalfEdgeBuilder {
/// Update partial half-edge to represent the u-axis of the surface it is on /// Update partial half-edge to represent the u-axis of the surface it is on
/// ///
/// Returns the updated path. /// Returns the updated path.
fn update_as_u_axis(&mut self) -> SurfacePath; fn update_as_u_axis(&mut self) -> Curve;
/// Update partial curve to represent the v-axis of the surface it is on /// Update partial curve to represent the v-axis of the surface it is on
/// ///
/// Returns the updated path. /// Returns the updated path.
fn update_as_v_axis(&mut self) -> SurfacePath; fn update_as_v_axis(&mut self) -> Curve;
/// Update partial half-edge to be a circle, from the given radius /// Update partial half-edge to be a circle, from the given radius
fn update_as_circle_from_radius( fn update_as_circle_from_radius(
&mut self, &mut self,
radius: impl Into<Scalar>, radius: impl Into<Scalar>,
) -> SurfacePath; ) -> Curve;
/// Update partial half-edge to be an arc, spanning the given angle in /// Update partial half-edge to be an arc, spanning the given angle in
/// radians /// radians
@ -40,10 +40,10 @@ pub trait HalfEdgeBuilder {
fn update_as_line_segment_from_points( fn update_as_line_segment_from_points(
&mut self, &mut self,
points: [impl Into<Point<2>>; 2], points: [impl Into<Point<2>>; 2],
) -> SurfacePath; ) -> Curve;
/// Update partial half-edge to be a line segment /// Update partial half-edge to be a line segment
fn update_as_line_segment(&mut self) -> SurfacePath; fn update_as_line_segment(&mut self) -> Curve;
/// Infer the global form of the half-edge /// Infer the global form of the half-edge
/// ///
@ -74,14 +74,14 @@ pub trait HalfEdgeBuilder {
} }
impl HalfEdgeBuilder for PartialHalfEdge { impl HalfEdgeBuilder for PartialHalfEdge {
fn update_as_u_axis(&mut self) -> SurfacePath { fn update_as_u_axis(&mut self) -> Curve {
let path = SurfacePath::u_axis(); let path = Curve::u_axis();
self.curve = Some(path.into()); self.curve = Some(path.into());
path path
} }
fn update_as_v_axis(&mut self) -> SurfacePath { fn update_as_v_axis(&mut self) -> Curve {
let path = SurfacePath::v_axis(); let path = Curve::v_axis();
self.curve = Some(path.into()); self.curve = Some(path.into());
path path
} }
@ -89,8 +89,8 @@ impl HalfEdgeBuilder for PartialHalfEdge {
fn update_as_circle_from_radius( fn update_as_circle_from_radius(
&mut self, &mut self,
radius: impl Into<Scalar>, radius: impl Into<Scalar>,
) -> SurfacePath { ) -> Curve {
let path = SurfacePath::circle_from_radius(radius); let path = Curve::circle_from_radius(radius);
self.curve = Some(path.into()); self.curve = Some(path.into());
let [a_curve, b_curve] = let [a_curve, b_curve] =
@ -131,8 +131,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
let arc = fj_math::Arc::from_endpoints_and_angle(start, end, angle_rad); let arc = fj_math::Arc::from_endpoints_and_angle(start, end, angle_rad);
let path = let path = Curve::circle_from_center_and_radius(arc.center, arc.radius);
SurfacePath::circle_from_center_and_radius(arc.center, arc.radius);
self.curve = Some(path.into()); self.curve = Some(path.into());
let [a_curve, b_curve] = let [a_curve, b_curve] =
@ -152,7 +151,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
fn update_as_line_segment_from_points( fn update_as_line_segment_from_points(
&mut self, &mut self,
points: [impl Into<Point<2>>; 2], points: [impl Into<Point<2>>; 2],
) -> SurfacePath { ) -> Curve {
for (vertex, point) in self.vertices.each_mut_ext().zip_ext(points) { for (vertex, point) in self.vertices.each_mut_ext().zip_ext(points) {
let mut surface_form = vertex.1.write(); let mut surface_form = vertex.1.write();
surface_form.position = Some(point.into()); surface_form.position = Some(point.into());
@ -161,7 +160,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
self.update_as_line_segment() self.update_as_line_segment()
} }
fn update_as_line_segment(&mut self) -> SurfacePath { fn update_as_line_segment(&mut self) -> Curve {
let boundary = self.vertices.each_ref_ext().map(|vertex| vertex.0); let boundary = self.vertices.each_ref_ext().map(|vertex| vertex.0);
let points_surface = self.vertices.each_ref_ext().map(|vertex| { let points_surface = self.vertices.each_ref_ext().map(|vertex| {
vertex vertex
@ -174,12 +173,12 @@ impl HalfEdgeBuilder for PartialHalfEdge {
let path = if let [Some(start), Some(end)] = boundary { let path = if let [Some(start), Some(end)] = boundary {
let points = [start, end].zip_ext(points_surface); let points = [start, end].zip_ext(points_surface);
let path = SurfacePath::from_points_with_line_coords(points); let path = Curve::from_points_with_line_coords(points);
self.curve = Some(path.into()); self.curve = Some(path.into());
path path
} else { } else {
let (path, _) = SurfacePath::line_from_points(points_surface); let (path, _) = Curve::line_from_points(points_surface);
self.curve = Some(path.into()); self.curve = Some(path.into());
for (vertex, position) in for (vertex, position) in
@ -212,7 +211,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
let path = self let path = self
.curve .curve
.expect("Can't infer vertex positions without curve"); .expect("Can't infer vertex positions without curve");
let MaybeSurfacePath::Defined(path) = path else { let MaybeCurve::Defined(path) = path else {
panic!("Can't infer vertex positions with undefined path"); panic!("Can't infer vertex positions with undefined path");
}; };
@ -263,8 +262,8 @@ impl HalfEdgeBuilder for PartialHalfEdge {
// represented using our current curve/surface // represented using our current curve/surface
// representation. // representation.
match path { match path {
MaybeSurfacePath::Defined(SurfacePath::Line(_)) MaybeCurve::Defined(Curve::Line(_))
| MaybeSurfacePath::UndefinedLine => { | MaybeCurve::UndefinedLine => {
// We're dealing with a line on a rounded surface. // We're dealing with a line on a rounded surface.
// //
// Based on the current uses of this method, we can // Based on the current uses of this method, we can
@ -291,7 +290,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
// I hope that I'll come up with a better curve/ // I hope that I'll come up with a better curve/
// surface representation before this becomes a // surface representation before this becomes a
// problem. // problem.
Some(MaybeSurfacePath::UndefinedCircle { Some(MaybeCurve::UndefinedCircle {
radius: circle.radius(), radius: circle.radius(),
}) })
} }
@ -308,11 +307,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {
GlobalPath::Line(_) => { GlobalPath::Line(_) => {
// The other edge is defined on a plane. // The other edge is defined on a plane.
match path { match path {
MaybeSurfacePath::Defined(SurfacePath::Line(_)) MaybeCurve::Defined(Curve::Line(_))
| MaybeSurfacePath::UndefinedLine => { | MaybeCurve::UndefinedLine => {
// The other edge is a line segment on a plane. That // The other edge is a line segment on a plane. That
// means our edge must be a line segment too. // means our edge must be a line segment too.
Some(MaybeSurfacePath::UndefinedLine) Some(MaybeCurve::UndefinedLine)
} }
_ => { _ => {
// The other edge is a circle or arc on a plane. I'm // The other edge is a circle or arc on a plane. I'm

View File

@ -3,9 +3,9 @@ use std::{array, collections::VecDeque};
use fj_interop::ext::ArrayExt; use fj_interop::ext::ArrayExt;
use crate::{ use crate::{
geometry::path::SurfacePath, geometry::curve::Curve,
objects::{Cycle, Surface}, objects::{Cycle, Surface},
partial::{MaybeSurfacePath, Partial, PartialFace}, partial::{MaybeCurve, Partial, PartialFace},
}; };
use super::SurfaceBuilder; use super::SurfaceBuilder;
@ -100,13 +100,13 @@ impl FaceBuilder for PartialFace {
if let Some(path) = &mut curve { if let Some(path) = &mut curve {
match path { match path {
MaybeSurfacePath::Defined(_) => { MaybeCurve::Defined(_) => {
// Path is already defined. Nothing to infer. // Path is already defined. Nothing to infer.
} }
MaybeSurfacePath::UndefinedCircle { .. } => todo!( MaybeCurve::UndefinedCircle { .. } => todo!(
"Inferring undefined circles is not supported yet" "Inferring undefined circles is not supported yet"
), ),
MaybeSurfacePath::UndefinedLine => { MaybeCurve::UndefinedLine => {
let points_surface = let points_surface =
half_edge.vertices.each_ref_ext().map(|vertex| { half_edge.vertices.each_ref_ext().map(|vertex| {
vertex.1.read().position.expect( vertex.1.read().position.expect(
@ -114,9 +114,9 @@ impl FaceBuilder for PartialFace {
) )
}); });
let (line, points_curve) = let (line, points_curve) =
SurfacePath::line_from_points(points_surface); Curve::line_from_points(points_surface);
*path = MaybeSurfacePath::Defined(line); *path = MaybeCurve::Defined(line);
for (vertex, point) in half_edge for (vertex, point) in half_edge
.vertices .vertices
.each_mut_ext() .each_mut_ext()

View File

@ -1,7 +1,7 @@
use fj_math::{Point, Scalar, Vector}; use fj_math::{Point, Scalar, Vector};
use crate::{ use crate::{
geometry::{path::GlobalPath, surface::SurfaceGeometry}, geometry::{curve::GlobalPath, surface::SurfaceGeometry},
partial::PartialSurface, partial::PartialSurface,
}; };

View File

@ -1,12 +1,12 @@
//! Paths through 2D and 3D space //! Paths through 2D and 3D space
//! //!
//! See [`SurfacePath`] and [`GlobalPath`]. //! See [`Curve`] and [`GlobalPath`].
use fj_math::{Circle, Line, Point, Scalar, Transform, Vector}; use fj_math::{Circle, Line, Point, Scalar, Transform, Vector};
/// A path through surface (2D) space /// A path through surface (2D) space
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum SurfacePath { pub enum Curve {
/// A circle /// A circle
Circle(Circle<2>), Circle(Circle<2>),
@ -14,7 +14,7 @@ pub enum SurfacePath {
Line(Line<2>), Line(Line<2>),
} }
impl SurfacePath { impl Curve {
/// Build a circle from the given radius /// Build a circle from the given radius
pub fn circle_from_radius(radius: impl Into<Scalar>) -> Self { pub fn circle_from_radius(radius: impl Into<Scalar>) -> Self {
Self::circle_from_center_and_radius(Point::origin(), radius) Self::circle_from_center_and_radius(Point::origin(), radius)

View File

@ -1,4 +1,4 @@
//! Types that are tied to objects, but aren't objects themselves //! Types that are tied to objects, but aren't objects themselves
pub mod path; pub mod curve;
pub mod surface; pub mod surface;

View File

@ -2,7 +2,7 @@
use fj_math::{Line, Plane, Point, Transform, Vector}; use fj_math::{Line, Plane, Point, Transform, Vector};
use super::path::GlobalPath; use super::curve::GlobalPath;
/// The geometry that defines a surface /// The geometry that defines a surface
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
@ -64,7 +64,7 @@ mod tests {
use fj_math::{Line, Point, Vector}; use fj_math::{Line, Point, Vector};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use crate::geometry::{path::GlobalPath, surface::SurfaceGeometry}; use crate::geometry::{curve::GlobalPath, surface::SurfaceGeometry};
#[test] #[test]
fn point_from_surface_coords() { fn point_from_surface_coords() {

View File

@ -3,7 +3,7 @@ use std::slice;
use fj_interop::ext::SliceExt; use fj_interop::ext::SliceExt;
use fj_math::{Scalar, Winding}; use fj_math::{Scalar, Winding};
use crate::{geometry::path::SurfacePath, objects::HalfEdge, storage::Handle}; use crate::{geometry::curve::Curve, objects::HalfEdge, storage::Handle};
/// A cycle of connected half-edges /// A cycle of connected half-edges
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
@ -56,8 +56,8 @@ impl Cycle {
let edge_direction_positive = a < b; let edge_direction_positive = a < b;
let circle = match first.curve() { let circle = match first.curve() {
SurfacePath::Circle(circle) => circle, Curve::Circle(circle) => circle,
SurfacePath::Line(_) => unreachable!( Curve::Line(_) => unreachable!(
"Invalid cycle: less than 3 edges, but not all are circles" "Invalid cycle: less than 3 edges, but not all are circles"
), ),
}; };

View File

@ -2,7 +2,7 @@ use fj_interop::ext::ArrayExt;
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
geometry::path::SurfacePath, geometry::curve::Curve,
objects::{GlobalVertex, SurfaceVertex}, objects::{GlobalVertex, SurfaceVertex},
storage::Handle, storage::Handle,
}; };
@ -45,7 +45,7 @@ use crate::{
/// <https://github.com/hannobraun/Fornjot/issues/1608> /// <https://github.com/hannobraun/Fornjot/issues/1608>
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct HalfEdge { pub struct HalfEdge {
curve: SurfacePath, curve: Curve,
boundary: [(Point<1>, Handle<SurfaceVertex>); 2], boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
global_form: Handle<GlobalEdge>, global_form: Handle<GlobalEdge>,
} }
@ -53,7 +53,7 @@ pub struct HalfEdge {
impl HalfEdge { impl HalfEdge {
/// Create an instance of `HalfEdge` /// Create an instance of `HalfEdge`
pub fn new( pub fn new(
curve: SurfacePath, curve: Curve,
boundary: [(Point<1>, Handle<SurfaceVertex>); 2], boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
global_form: Handle<GlobalEdge>, global_form: Handle<GlobalEdge>,
) -> Self { ) -> Self {
@ -65,7 +65,7 @@ impl HalfEdge {
} }
/// Access the curve that defines the half-edge's geometry /// Access the curve that defines the half-edge's geometry
pub fn curve(&self) -> SurfacePath { pub fn curve(&self) -> Curve {
self.curve self.curve
} }

View File

@ -1,7 +1,7 @@
use fj_math::Vector; use fj_math::Vector;
use crate::{ use crate::{
geometry::{path::GlobalPath, surface::SurfaceGeometry}, geometry::{curve::GlobalPath, surface::SurfaceGeometry},
storage::{Handle, Store}, storage::{Handle, Store},
}; };

View File

@ -16,7 +16,7 @@ mod wrapper;
pub use self::{ pub use self::{
objects::{ objects::{
curve::MaybeSurfacePath, curve::MaybeCurve,
cycle::PartialCycle, cycle::PartialCycle,
edge::{PartialGlobalEdge, PartialHalfEdge}, edge::{PartialGlobalEdge, PartialHalfEdge},
face::PartialFace, face::PartialFace,

View File

@ -1,28 +1,25 @@
use fj_math::Scalar; use fj_math::Scalar;
use crate::geometry::path::SurfacePath; use crate::geometry::curve::Curve;
/// The definition of a surface path within a partial object /// A possibly undefined curve
///
/// Can be a fully defined [`SurfacePath`], or just the type of path might be
/// known.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub enum MaybeSurfacePath { pub enum MaybeCurve {
/// The surface path is fully defined /// The curve is fully defined
Defined(SurfacePath), Defined(Curve),
/// The surface path is undefined, but we know it is a circle /// The curve is undefined, but we know it is a circle
UndefinedCircle { UndefinedCircle {
/// The radius of the undefined circle /// The radius of the undefined circle
radius: Scalar, radius: Scalar,
}, },
/// The surface path is undefined, but we know it is a line /// The curve is undefined, but we know it is a line
UndefinedLine, UndefinedLine,
} }
impl From<SurfacePath> for MaybeSurfacePath { impl From<Curve> for MaybeCurve {
fn from(path: SurfacePath) -> Self { fn from(path: Curve) -> Self {
Self::Defined(path) Self::Defined(path)
} }
} }

View File

@ -5,7 +5,7 @@ use fj_math::Point;
use crate::{ use crate::{
objects::{GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex}, objects::{GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex},
partial::{FullToPartialCache, MaybeSurfacePath, Partial, PartialObject}, partial::{FullToPartialCache, MaybeCurve, Partial, PartialObject},
services::Service, services::Service,
}; };
@ -13,7 +13,7 @@ use crate::{
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct PartialHalfEdge { pub struct PartialHalfEdge {
/// The curve that the half-edge is defined in /// The curve that the half-edge is defined in
pub curve: Option<MaybeSurfacePath>, pub curve: Option<MaybeCurve>,
/// The vertices that bound the half-edge on the curve /// The vertices that bound the half-edge on the curve
pub vertices: [(Option<Point<1>>, Partial<SurfaceVertex>); 2], pub vertices: [(Option<Point<1>>, Partial<SurfaceVertex>); 2],
@ -49,7 +49,7 @@ impl PartialObject for PartialHalfEdge {
fn build(self, objects: &mut Service<Objects>) -> Self::Full { fn build(self, objects: &mut Service<Objects>) -> Self::Full {
let curve = match self.curve.expect("Need path to build curve") { let curve = match self.curve.expect("Need path to build curve") {
MaybeSurfacePath::Defined(path) => path, MaybeCurve::Defined(path) => path,
undefined => { undefined => {
panic!( panic!(
"Trying to build curve with undefined path: {undefined:?}" "Trying to build curve with undefined path: {undefined:?}"