mirror of https://github.com/hannobraun/Fornjot
Merge pull request #1617 from hannobraun/curve
Rename `SurfacePath` to `Curve`
This commit is contained in:
commit
bead9dbef3
|
@ -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},
|
||||
};
|
||||
|
@ -91,7 +91,7 @@ impl HalfEdgeApprox {
|
|||
}
|
||||
|
||||
fn approx_edge(
|
||||
curve: &SurfacePath,
|
||||
curve: &Curve,
|
||||
surface: &Surface,
|
||||
range: RangeOnPath,
|
||||
tolerance: impl Into<Tolerance>,
|
||||
|
@ -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()
|
||||
|
@ -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]
|
||||
|
@ -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,
|
||||
|
|
|
@ -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 = ();
|
||||
|
||||
|
@ -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![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ mod tests {
|
|||
|
||||
use crate::{
|
||||
builder::HalfEdgeBuilder,
|
||||
geometry::path::SurfacePath,
|
||||
geometry::curve::Curve,
|
||||
partial::{PartialHalfEdge, PartialObject},
|
||||
services::Services,
|
||||
};
|
||||
|
@ -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.]]);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.]]);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
@ -151,7 +151,7 @@ where
|
|||
mod tests {
|
||||
use crate::{
|
||||
builder::{CycleBuilder, FaceBuilder},
|
||||
geometry::path::SurfacePath,
|
||||
geometry::curve::Curve,
|
||||
partial::{Partial, PartialFace, PartialObject},
|
||||
services::Services,
|
||||
};
|
||||
|
@ -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 = [
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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 =
|
||||
|
|
|
@ -4,7 +4,7 @@ use fj_math::Segment;
|
|||
|
||||
use crate::{
|
||||
algorithms::intersect::{HorizontalRayToTheRight, Intersect},
|
||||
geometry::path::SurfacePath,
|
||||
geometry::curve::Curve,
|
||||
objects::HalfEdge,
|
||||
storage::Handle,
|
||||
};
|
||||
|
@ -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")
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
};
|
||||
|
||||
|
@ -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],),
|
||||
|
|
|
@ -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},
|
||||
|
@ -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(
|
||||
|
@ -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());
|
||||
|
@ -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
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -3,11 +3,11 @@ use fj_math::{Point, Scalar};
|
|||
|
||||
use crate::{
|
||||
geometry::{
|
||||
path::{GlobalPath, SurfacePath},
|
||||
curve::{Curve, GlobalPath},
|
||||
surface::SurfaceGeometry,
|
||||
},
|
||||
objects::{GlobalEdge, HalfEdge},
|
||||
partial::{MaybeSurfacePath, Partial, PartialGlobalEdge, PartialHalfEdge},
|
||||
partial::{MaybeCurve, Partial, PartialGlobalEdge, 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
|
||||
///
|
||||
/// 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
|
||||
///
|
||||
/// 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
|
||||
fn update_as_circle_from_radius(
|
||||
&mut self,
|
||||
radius: impl Into<Scalar>,
|
||||
) -> SurfacePath;
|
||||
) -> Curve;
|
||||
|
||||
/// Update partial half-edge to be an arc, spanning the given angle in
|
||||
/// radians
|
||||
|
@ -40,10 +40,10 @@ pub trait HalfEdgeBuilder {
|
|||
fn update_as_line_segment_from_points(
|
||||
&mut self,
|
||||
points: [impl Into<Point<2>>; 2],
|
||||
) -> SurfacePath;
|
||||
) -> Curve;
|
||||
|
||||
/// 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
|
||||
///
|
||||
|
@ -74,14 +74,14 @@ pub trait HalfEdgeBuilder {
|
|||
}
|
||||
|
||||
impl HalfEdgeBuilder for PartialHalfEdge {
|
||||
fn update_as_u_axis(&mut self) -> SurfacePath {
|
||||
let path = SurfacePath::u_axis();
|
||||
fn update_as_u_axis(&mut self) -> Curve {
|
||||
let path = Curve::u_axis();
|
||||
self.curve = Some(path.into());
|
||||
path
|
||||
}
|
||||
|
||||
fn update_as_v_axis(&mut self) -> SurfacePath {
|
||||
let path = SurfacePath::v_axis();
|
||||
fn update_as_v_axis(&mut self) -> Curve {
|
||||
let path = Curve::v_axis();
|
||||
self.curve = Some(path.into());
|
||||
path
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
fn update_as_circle_from_radius(
|
||||
&mut self,
|
||||
radius: impl Into<Scalar>,
|
||||
) -> SurfacePath {
|
||||
let path = SurfacePath::circle_from_radius(radius);
|
||||
) -> Curve {
|
||||
let path = Curve::circle_from_radius(radius);
|
||||
self.curve = Some(path.into());
|
||||
|
||||
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 path =
|
||||
SurfacePath::circle_from_center_and_radius(arc.center, arc.radius);
|
||||
let path = Curve::circle_from_center_and_radius(arc.center, arc.radius);
|
||||
self.curve = Some(path.into());
|
||||
|
||||
let [a_curve, b_curve] =
|
||||
|
@ -152,7 +151,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
fn update_as_line_segment_from_points(
|
||||
&mut self,
|
||||
points: [impl Into<Point<2>>; 2],
|
||||
) -> SurfacePath {
|
||||
) -> Curve {
|
||||
for (vertex, point) in self.vertices.each_mut_ext().zip_ext(points) {
|
||||
let mut surface_form = vertex.1.write();
|
||||
surface_form.position = Some(point.into());
|
||||
|
@ -161,7 +160,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
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 points_surface = self.vertices.each_ref_ext().map(|vertex| {
|
||||
vertex
|
||||
|
@ -174,12 +173,12 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
let path = if let [Some(start), Some(end)] = boundary {
|
||||
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());
|
||||
|
||||
path
|
||||
} else {
|
||||
let (path, _) = SurfacePath::line_from_points(points_surface);
|
||||
let (path, _) = Curve::line_from_points(points_surface);
|
||||
self.curve = Some(path.into());
|
||||
|
||||
for (vertex, position) in
|
||||
|
@ -212,7 +211,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
let path = self
|
||||
.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");
|
||||
};
|
||||
|
||||
|
@ -263,8 +262,8 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
// represented using our current curve/surface
|
||||
// representation.
|
||||
match path {
|
||||
MaybeSurfacePath::Defined(SurfacePath::Line(_))
|
||||
| MaybeSurfacePath::UndefinedLine => {
|
||||
MaybeCurve::Defined(Curve::Line(_))
|
||||
| MaybeCurve::UndefinedLine => {
|
||||
// We're dealing with a line on a rounded surface.
|
||||
//
|
||||
// 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/
|
||||
// surface representation before this becomes a
|
||||
// problem.
|
||||
Some(MaybeSurfacePath::UndefinedCircle {
|
||||
Some(MaybeCurve::UndefinedCircle {
|
||||
radius: circle.radius(),
|
||||
})
|
||||
}
|
||||
|
@ -308,11 +307,11 @@ impl HalfEdgeBuilder for PartialHalfEdge {
|
|||
GlobalPath::Line(_) => {
|
||||
// The other edge is defined on a plane.
|
||||
match path {
|
||||
MaybeSurfacePath::Defined(SurfacePath::Line(_))
|
||||
| MaybeSurfacePath::UndefinedLine => {
|
||||
MaybeCurve::Defined(Curve::Line(_))
|
||||
| MaybeCurve::UndefinedLine => {
|
||||
// The other edge is a line segment on a plane. That
|
||||
// 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
|
||||
|
|
|
@ -3,9 +3,9 @@ use std::{array, collections::VecDeque};
|
|||
use fj_interop::ext::ArrayExt;
|
||||
|
||||
use crate::{
|
||||
geometry::path::SurfacePath,
|
||||
geometry::curve::Curve,
|
||||
objects::{Cycle, Surface},
|
||||
partial::{MaybeSurfacePath, Partial, PartialFace},
|
||||
partial::{MaybeCurve, Partial, PartialFace},
|
||||
};
|
||||
|
||||
use super::SurfaceBuilder;
|
||||
|
@ -100,13 +100,13 @@ impl FaceBuilder for PartialFace {
|
|||
|
||||
if let Some(path) = &mut curve {
|
||||
match path {
|
||||
MaybeSurfacePath::Defined(_) => {
|
||||
MaybeCurve::Defined(_) => {
|
||||
// Path is already defined. Nothing to infer.
|
||||
}
|
||||
MaybeSurfacePath::UndefinedCircle { .. } => todo!(
|
||||
MaybeCurve::UndefinedCircle { .. } => todo!(
|
||||
"Inferring undefined circles is not supported yet"
|
||||
),
|
||||
MaybeSurfacePath::UndefinedLine => {
|
||||
MaybeCurve::UndefinedLine => {
|
||||
let points_surface =
|
||||
half_edge.vertices.each_ref_ext().map(|vertex| {
|
||||
vertex.1.read().position.expect(
|
||||
|
@ -114,9 +114,9 @@ impl FaceBuilder for PartialFace {
|
|||
)
|
||||
});
|
||||
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
|
||||
.vertices
|
||||
.each_mut_ext()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use fj_math::{Point, Scalar, Vector};
|
||||
|
||||
use crate::{
|
||||
geometry::{path::GlobalPath, surface::SurfaceGeometry},
|
||||
geometry::{curve::GlobalPath, surface::SurfaceGeometry},
|
||||
partial::PartialSurface,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
//! Paths through 2D and 3D space
|
||||
//!
|
||||
//! See [`SurfacePath`] and [`GlobalPath`].
|
||||
//! See [`Curve`] and [`GlobalPath`].
|
||||
|
||||
use fj_math::{Circle, Line, Point, Scalar, Transform, Vector};
|
||||
|
||||
/// A path through surface (2D) space
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub enum SurfacePath {
|
||||
pub enum Curve {
|
||||
/// A circle
|
||||
Circle(Circle<2>),
|
||||
|
||||
|
@ -14,7 +14,7 @@ pub enum SurfacePath {
|
|||
Line(Line<2>),
|
||||
}
|
||||
|
||||
impl SurfacePath {
|
||||
impl Curve {
|
||||
/// Build a circle from the given radius
|
||||
pub fn circle_from_radius(radius: impl Into<Scalar>) -> Self {
|
||||
Self::circle_from_center_and_radius(Point::origin(), radius)
|
|
@ -1,4 +1,4 @@
|
|||
//! Types that are tied to objects, but aren't objects themselves
|
||||
|
||||
pub mod path;
|
||||
pub mod curve;
|
||||
pub mod surface;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use fj_math::{Line, Plane, Point, Transform, Vector};
|
||||
|
||||
use super::path::GlobalPath;
|
||||
use super::curve::GlobalPath;
|
||||
|
||||
/// The geometry that defines a surface
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
|
@ -64,7 +64,7 @@ mod tests {
|
|||
use fj_math::{Line, Point, Vector};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::geometry::{path::GlobalPath, surface::SurfaceGeometry};
|
||||
use crate::geometry::{curve::GlobalPath, surface::SurfaceGeometry};
|
||||
|
||||
#[test]
|
||||
fn point_from_surface_coords() {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::slice;
|
|||
use fj_interop::ext::SliceExt;
|
||||
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
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
|
@ -56,8 +56,8 @@ impl Cycle {
|
|||
let edge_direction_positive = a < b;
|
||||
|
||||
let circle = match first.curve() {
|
||||
SurfacePath::Circle(circle) => circle,
|
||||
SurfacePath::Line(_) => unreachable!(
|
||||
Curve::Circle(circle) => circle,
|
||||
Curve::Line(_) => unreachable!(
|
||||
"Invalid cycle: less than 3 edges, but not all are circles"
|
||||
),
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ use fj_interop::ext::ArrayExt;
|
|||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
geometry::path::SurfacePath,
|
||||
geometry::curve::Curve,
|
||||
objects::{GlobalVertex, SurfaceVertex},
|
||||
storage::Handle,
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ use crate::{
|
|||
/// <https://github.com/hannobraun/Fornjot/issues/1608>
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct HalfEdge {
|
||||
curve: SurfacePath,
|
||||
curve: Curve,
|
||||
boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
|
||||
global_form: Handle<GlobalEdge>,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ pub struct HalfEdge {
|
|||
impl HalfEdge {
|
||||
/// Create an instance of `HalfEdge`
|
||||
pub fn new(
|
||||
curve: SurfacePath,
|
||||
curve: Curve,
|
||||
boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
|
||||
global_form: Handle<GlobalEdge>,
|
||||
) -> Self {
|
||||
|
@ -65,7 +65,7 @@ impl HalfEdge {
|
|||
}
|
||||
|
||||
/// Access the curve that defines the half-edge's geometry
|
||||
pub fn curve(&self) -> SurfacePath {
|
||||
pub fn curve(&self) -> Curve {
|
||||
self.curve
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use fj_math::Vector;
|
||||
|
||||
use crate::{
|
||||
geometry::{path::GlobalPath, surface::SurfaceGeometry},
|
||||
geometry::{curve::GlobalPath, surface::SurfaceGeometry},
|
||||
storage::{Handle, Store},
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ mod wrapper;
|
|||
|
||||
pub use self::{
|
||||
objects::{
|
||||
curve::MaybeSurfacePath,
|
||||
curve::MaybeCurve,
|
||||
cycle::PartialCycle,
|
||||
edge::{PartialGlobalEdge, PartialHalfEdge},
|
||||
face::PartialFace,
|
||||
|
|
|
@ -1,28 +1,25 @@
|
|||
use fj_math::Scalar;
|
||||
|
||||
use crate::geometry::path::SurfacePath;
|
||||
use crate::geometry::curve::Curve;
|
||||
|
||||
/// The definition of a surface path within a partial object
|
||||
///
|
||||
/// Can be a fully defined [`SurfacePath`], or just the type of path might be
|
||||
/// known.
|
||||
/// A possibly undefined curve
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum MaybeSurfacePath {
|
||||
/// The surface path is fully defined
|
||||
Defined(SurfacePath),
|
||||
pub enum MaybeCurve {
|
||||
/// The curve is fully defined
|
||||
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 {
|
||||
/// The radius of the undefined circle
|
||||
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,
|
||||
}
|
||||
|
||||
impl From<SurfacePath> for MaybeSurfacePath {
|
||||
fn from(path: SurfacePath) -> Self {
|
||||
impl From<Curve> for MaybeCurve {
|
||||
fn from(path: Curve) -> Self {
|
||||
Self::Defined(path)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use fj_math::Point;
|
|||
|
||||
use crate::{
|
||||
objects::{GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex},
|
||||
partial::{FullToPartialCache, MaybeSurfacePath, Partial, PartialObject},
|
||||
partial::{FullToPartialCache, MaybeCurve, Partial, PartialObject},
|
||||
services::Service,
|
||||
};
|
||||
|
||||
|
@ -13,7 +13,7 @@ use crate::{
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct PartialHalfEdge {
|
||||
/// 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
|
||||
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 {
|
||||
let curve = match self.curve.expect("Need path to build curve") {
|
||||
MaybeSurfacePath::Defined(path) => path,
|
||||
MaybeCurve::Defined(path) => path,
|
||||
undefined => {
|
||||
panic!(
|
||||
"Trying to build curve with undefined path: {undefined:?}"
|
||||
|
|
Loading…
Reference in New Issue