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

Rename SurfacePath to Curve #1617

Merged
merged 4 commits into from
Feb 24, 2023
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
12 changes: 6 additions & 6 deletions crates/fj-kernel/src/algorithms/approx/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use std::collections::BTreeMap;

use crate::{
geometry::path::{GlobalPath, SurfacePath},
geometry::curve::{Curve, GlobalPath},
objects::{GlobalEdge, HalfEdge, Surface},
storage::{Handle, ObjectId},
};
Expand Down Expand Up @@ -91,7 +91,7 @@ impl HalfEdgeApprox {
}

fn approx_edge(
curve: &SurfacePath,
curve: &Curve,
surface: &Surface,
range: RangeOnPath,
tolerance: impl Into<Tolerance>,
Expand All @@ -103,12 +103,12 @@ fn approx_edge(
// `GlobalPath` grow APIs that are better suited to implementing this code
// in a more abstract way.
let points = match (curve, surface.geometry().u) {
(SurfacePath::Circle(_), GlobalPath::Circle(_)) => {
(Curve::Circle(_), GlobalPath::Circle(_)) => {
todo!(
"Approximating a circle on a curved surface not supported yet."
)
}
(SurfacePath::Circle(_), GlobalPath::Line(_)) => {
(Curve::Circle(_), GlobalPath::Line(_)) => {
(curve, range)
.approx_with_cache(tolerance, &mut ())
.into_iter()
Expand All @@ -135,7 +135,7 @@ fn approx_edge(
})
.collect()
}
(SurfacePath::Line(line), _) => {
(Curve::Line(line), _) => {
let range_u =
RangeOnPath::from(range.boundary.map(|point_curve| {
[curve.point_from_path_coords(point_curve).u]
Expand Down Expand Up @@ -232,7 +232,7 @@ mod tests {
use crate::{
algorithms::approx::{path::RangeOnPath, Approx, ApproxPoint},
builder::{HalfEdgeBuilder, SurfaceBuilder},
geometry::path::GlobalPath,
geometry::curve::GlobalPath,
insert::Insert,
partial::{PartialHalfEdge, PartialObject, PartialSurface},
services::Services,
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/approx/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ use std::iter;

use fj_math::{Circle, Point, Scalar, Sign};

use crate::geometry::path::{GlobalPath, SurfacePath};
use crate::geometry::curve::{Curve, GlobalPath};

use super::{Approx, Tolerance};

impl Approx for (&SurfacePath, RangeOnPath) {
impl Approx for (&Curve, RangeOnPath) {
type Approximation = Vec<(Point<1>, Point<2>)>;
type Cache = ();

Expand All @@ -48,10 +48,10 @@ impl Approx for (&SurfacePath, RangeOnPath) {
let (path, range) = self;

match path {
SurfacePath::Circle(circle) => {
Curve::Circle(circle) => {
approx_circle(circle, range, tolerance.into())
}
SurfacePath::Line(_) => vec![],
Curve::Line(_) => vec![],
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions crates/fj-kernel/src/algorithms/intersect/curve_edge.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use fj_math::{Point, Segment};

use crate::{geometry::path::SurfacePath, objects::HalfEdge};
use crate::{geometry::curve::Curve, objects::HalfEdge};

use super::LineSegmentIntersection;

Expand Down Expand Up @@ -28,15 +28,15 @@ impl CurveEdgeIntersection {
/// Currently, only intersections between lines and line segments can be
/// computed. Panics, if a different type of curve or [`HalfEdge`] is
/// 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 {
SurfacePath::Line(line) => line,
Curve::Line(line) => line,
_ => todo!("Curve-edge intersection only supports lines"),
};

let edge_as_segment = {
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")
}
Expand Down Expand Up @@ -73,7 +73,7 @@ mod tests {

use crate::{
builder::HalfEdgeBuilder,
geometry::path::SurfacePath,
geometry::curve::Curve,
partial::{PartialHalfEdge, PartialObject},
services::Services,
};
Expand All @@ -85,7 +85,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis();
let curve = Curve::u_axis();
let half_edge = {
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points([[1., -1.], [1., 1.]]);
Expand All @@ -109,7 +109,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis();
let curve = Curve::u_axis();
let half_edge = {
let mut half_edge = PartialHalfEdge::default();
half_edge
Expand All @@ -134,7 +134,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis();
let curve = Curve::u_axis();
let half_edge = {
let mut half_edge = PartialHalfEdge::default();
half_edge
Expand All @@ -154,7 +154,7 @@ mod tests {
let mut services = Services::new();

let surface = services.objects.surfaces.xy_plane();
let curve = SurfacePath::u_axis();
let curve = Curve::u_axis();
let half_edge = {
let mut half_edge = PartialHalfEdge::default();
half_edge.update_as_line_segment_from_points([[-1., 0.], [1., 0.]]);
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/intersect/curve_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::vec;
use fj_interop::ext::SliceExt;
use fj_math::Point;

use crate::{geometry::path::SurfacePath, objects::Face};
use crate::{geometry::curve::Curve, objects::Face};

use super::CurveEdgeIntersection;

Expand All @@ -28,7 +28,7 @@ impl CurveFaceIntersection {
}

/// 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 mut intersections = Vec::new();
Expand Down Expand Up @@ -151,7 +151,7 @@ where
mod tests {
use crate::{
builder::{CycleBuilder, FaceBuilder},
geometry::path::SurfacePath,
geometry::curve::Curve,
partial::{Partial, PartialFace, PartialObject},
services::Services,
};
Expand All @@ -162,7 +162,7 @@ mod tests {
fn compute() {
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]
let exterior = [
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/intersect/face_face.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fj_interop::ext::ArrayExt;
use iter_fixed::IntoIteratorFixed;

use crate::{geometry::path::SurfacePath, objects::Face};
use crate::{geometry::curve::Curve, objects::Face};

use super::{CurveFaceIntersection, SurfaceSurfaceIntersection};

Expand All @@ -14,7 +14,7 @@ pub struct FaceFaceIntersection {
/// representation of the intersection on the respective face's surface.
///
/// 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
///
Expand Down Expand Up @@ -63,7 +63,7 @@ mod tests {
use crate::{
algorithms::intersect::CurveFaceIntersection,
builder::CycleBuilder,
geometry::path::SurfacePath,
geometry::curve::Curve,
partial::{Partial, PartialFace, PartialObject},
services::Services,
};
Expand Down Expand Up @@ -128,7 +128,7 @@ mod tests {
let intersection = FaceFaceIntersection::compute([&a, &b]);

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
});
let expected_intervals =
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/intersect/ray_edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fj_math::Segment;

use crate::{
algorithms::intersect::{HorizontalRayToTheRight, Intersect},
geometry::path::SurfacePath,
geometry::curve::Curve,
objects::HalfEdge,
storage::Handle,
};
Expand All @@ -18,8 +18,8 @@ impl Intersect for (&HorizontalRayToTheRight<2>, &Handle<HalfEdge>) {
let (ray, edge) = self;

let line = match edge.curve() {
SurfacePath::Line(line) => line,
SurfacePath::Circle(_) => {
Curve::Line(line) => line,
Curve::Circle(_) => {
todo!("Casting rays against circles is not supported yet")
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/intersect/ray_face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use fj_math::{Plane, Point, Scalar};

use crate::{
algorithms::intersect::face_point::FacePointIntersection,
geometry::path::GlobalPath,
geometry::curve::GlobalPath,
objects::{Face, HalfEdge, SurfaceVertex},
storage::Handle,
};
Expand Down
13 changes: 6 additions & 7 deletions crates/fj-kernel/src/algorithms/intersect/surface_surface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fj_math::{Line, Plane, Point, Scalar};

use crate::{
geometry::path::{GlobalPath, SurfacePath},
geometry::curve::{Curve, GlobalPath},
objects::Surface,
storage::Handle,
};
Expand All @@ -10,7 +10,7 @@ use crate::{
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceSurfaceIntersection {
/// The intersection curves
pub intersection_curves: [SurfacePath; 2],
pub intersection_curves: [Curve; 2],
}

impl SurfaceSurfaceIntersection {
Expand Down Expand Up @@ -48,8 +48,7 @@ impl SurfaceSurfaceIntersection {

let line = Line::from_origin_and_direction(origin, direction);

let curves =
planes.map(|plane| SurfacePath::Line(plane.project_line(&line)));
let curves = planes.map(|plane| Curve::Line(plane.project_line(&line)));

Some(Self {
intersection_curves: curves,
Expand All @@ -76,7 +75,7 @@ mod tests {
use pretty_assertions::assert_eq;

use crate::{
algorithms::transform::TransformObject, geometry::path::SurfacePath,
algorithms::transform::TransformObject, geometry::curve::Curve,
services::Services,
};

Expand All @@ -101,8 +100,8 @@ mod tests {
None,
);

let expected_xy = SurfacePath::u_axis();
let expected_xz = SurfacePath::u_axis();
let expected_xy = Curve::u_axis();
let expected_xz = Curve::u_axis();

assert_eq!(
SurfaceSurfaceIntersection::compute([xy, xz],),
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/algorithms/sweep/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fj_math::{Circle, Line, Vector};

use crate::{
builder::SurfaceBuilder,
geometry::path::{GlobalPath, SurfacePath},
geometry::curve::{Curve, GlobalPath},
insert::Insert,
objects::{Objects, Surface},
partial::{PartialObject, PartialSurface},
Expand All @@ -12,7 +12,7 @@ use crate::{

use super::{Sweep, SweepCache};

impl Sweep for (SurfacePath, &Surface) {
impl Sweep for (Curve, &Surface) {
type Swept = Handle<Surface>;

fn sweep_with_cache(
Expand Down Expand Up @@ -48,7 +48,7 @@ impl Sweep for (SurfacePath, &Surface) {
}

let u = match curve {
SurfacePath::Circle(circle) => {
Curve::Circle(circle) => {
let center = surface
.geometry()
.point_from_surface_coords(circle.center());
Expand All @@ -61,7 +61,7 @@ impl Sweep for (SurfacePath, &Surface) {

GlobalPath::Circle(circle)
}
SurfacePath::Line(line) => {
Curve::Line(line) => {
let origin =
surface.geometry().point_from_surface_coords(line.origin());
let direction = surface
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/algorithms/sweep/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use fj_math::{Scalar, Vector};
use crate::{
algorithms::{reverse::Reverse, transform::TransformObject},
builder::{CycleBuilder, FaceBuilder},
geometry::path::GlobalPath,
geometry::curve::GlobalPath,
insert::Insert,
objects::{Face, Objects, Shell},
partial::{Partial, PartialFace, PartialObject, PartialShell},
Expand Down
Loading