mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-27 10:29:28 +00:00
Merge Curve
into HalfEdge
This commit is contained in:
parent
2322ab9ddc
commit
34d251ce8f
@ -41,7 +41,7 @@ impl Approx for (&Handle<HalfEdge>, &Surface) {
|
||||
Some(approx) => approx,
|
||||
None => {
|
||||
let approx = approx_edge(
|
||||
&half_edge.curve().path(),
|
||||
&half_edge.curve(),
|
||||
surface,
|
||||
range,
|
||||
tolerance,
|
||||
@ -56,7 +56,6 @@ impl Approx for (&Handle<HalfEdge>, &Surface) {
|
||||
.map(|point| {
|
||||
let point_surface = half_edge
|
||||
.curve()
|
||||
.path()
|
||||
.point_from_path_coords(point.local_form);
|
||||
|
||||
ApproxPoint::new(point_surface, point.global_form)
|
||||
@ -320,10 +319,8 @@ mod tests {
|
||||
.approx(tolerance)
|
||||
.into_iter()
|
||||
.map(|(point_local, _)| {
|
||||
let point_surface = half_edge
|
||||
.curve()
|
||||
.path()
|
||||
.point_from_path_coords(point_local);
|
||||
let point_surface =
|
||||
half_edge.curve().point_from_path_coords(point_local);
|
||||
let point_global =
|
||||
surface.geometry().point_from_surface_coords(point_surface);
|
||||
ApproxPoint::new(point_surface, point_global)
|
||||
@ -352,7 +349,7 @@ mod tests {
|
||||
let approx = (&half_edge, surface.deref()).approx(tolerance);
|
||||
|
||||
let expected_approx =
|
||||
(&half_edge.curve().path(), RangeOnPath::from([[0.], [TAU]]))
|
||||
(&half_edge.curve(), RangeOnPath::from([[0.], [TAU]]))
|
||||
.approx(tolerance)
|
||||
.into_iter()
|
||||
.map(|(_, point_surface)| {
|
||||
|
@ -35,7 +35,7 @@ impl CurveEdgeIntersection {
|
||||
};
|
||||
|
||||
let edge_as_segment = {
|
||||
let edge_curve_as_line = match half_edge.curve().path() {
|
||||
let edge_curve_as_line = match half_edge.curve() {
|
||||
SurfacePath::Line(line) => line,
|
||||
_ => {
|
||||
todo!("Curve-edge intersection only supports line segments")
|
||||
|
@ -17,7 +17,7 @@ impl Intersect for (&HorizontalRayToTheRight<2>, &Handle<HalfEdge>) {
|
||||
fn intersect(self) -> Option<Self::Intersection> {
|
||||
let (ray, edge) = self;
|
||||
|
||||
let line = match edge.curve().path() {
|
||||
let line = match edge.curve() {
|
||||
SurfacePath::Line(line) => line,
|
||||
SurfacePath::Circle(_) => {
|
||||
todo!("Casting rays against circles is not supported yet")
|
||||
|
@ -35,8 +35,7 @@ impl Sweep for (Handle<HalfEdge>, &Surface, Color) {
|
||||
// we're sweeping.
|
||||
{
|
||||
let surface = Partial::from(
|
||||
(edge.curve().path(), surface)
|
||||
.sweep_with_cache(path, cache, objects),
|
||||
(edge.curve(), surface).sweep_with_cache(path, cache, objects),
|
||||
);
|
||||
face.surface = surface;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl Sweep for Handle<Face> {
|
||||
.into_iter()
|
||||
.zip(top_cycle.write().half_edges.iter_mut())
|
||||
{
|
||||
top.write().curve = Some(bottom.curve().path().into());
|
||||
top.write().curve = Some(bottom.curve().into());
|
||||
|
||||
let boundary = bottom.boundary();
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
use crate::geometry::path::SurfacePath;
|
||||
|
||||
/// A curve, defined in local surface coordinates
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct Curve {
|
||||
path: SurfacePath,
|
||||
}
|
||||
|
||||
impl Curve {
|
||||
/// Construct a new instance of `Curve`
|
||||
pub fn new(path: SurfacePath) -> Self {
|
||||
Self { path }
|
||||
}
|
||||
|
||||
/// Access the path that defines the curve
|
||||
pub fn path(&self) -> SurfacePath {
|
||||
self.path
|
||||
}
|
||||
}
|
@ -55,7 +55,7 @@ impl Cycle {
|
||||
let [a, b] = first.boundary();
|
||||
let edge_direction_positive = a < b;
|
||||
|
||||
let circle = match first.curve().path() {
|
||||
let circle = match first.curve() {
|
||||
SurfacePath::Circle(circle) => circle,
|
||||
SurfacePath::Line(_) => unreachable!(
|
||||
"Invalid cycle: less than 3 edges, but not all are circles"
|
||||
|
@ -2,7 +2,8 @@ use fj_interop::ext::ArrayExt;
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
objects::{Curve, GlobalVertex, SurfaceVertex},
|
||||
geometry::path::SurfacePath,
|
||||
objects::{GlobalVertex, SurfaceVertex},
|
||||
storage::Handle,
|
||||
};
|
||||
|
||||
@ -44,7 +45,7 @@ use crate::{
|
||||
/// <https://github.com/hannobraun/Fornjot/issues/1608>
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
|
||||
pub struct HalfEdge {
|
||||
curve: Curve,
|
||||
curve: SurfacePath,
|
||||
boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
|
||||
global_form: Handle<GlobalEdge>,
|
||||
}
|
||||
@ -52,7 +53,7 @@ pub struct HalfEdge {
|
||||
impl HalfEdge {
|
||||
/// Create an instance of `HalfEdge`
|
||||
pub fn new(
|
||||
curve: Curve,
|
||||
curve: SurfacePath,
|
||||
boundary: [(Point<1>, Handle<SurfaceVertex>); 2],
|
||||
global_form: Handle<GlobalEdge>,
|
||||
) -> Self {
|
||||
@ -64,7 +65,7 @@ impl HalfEdge {
|
||||
}
|
||||
|
||||
/// Access the curve that defines the half-edge's geometry
|
||||
pub fn curve(&self) -> Curve {
|
||||
pub fn curve(&self) -> SurfacePath {
|
||||
self.curve
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
pub mod curve;
|
||||
pub mod cycle;
|
||||
pub mod edge;
|
||||
pub mod face;
|
||||
|
@ -79,7 +79,6 @@ mod stores;
|
||||
|
||||
pub use self::{
|
||||
full::{
|
||||
curve::Curve,
|
||||
cycle::{Cycle, HalfEdgesOfCycle},
|
||||
edge::{GlobalEdge, HalfEdge, VerticesInNormalizedOrder},
|
||||
face::{Face, FaceSet, Handedness},
|
||||
|
@ -4,9 +4,7 @@ use fj_interop::ext::ArrayExt;
|
||||
use fj_math::Point;
|
||||
|
||||
use crate::{
|
||||
objects::{
|
||||
Curve, GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex,
|
||||
},
|
||||
objects::{GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex},
|
||||
partial::{FullToPartialCache, MaybeSurfacePath, Partial, PartialObject},
|
||||
services::Service,
|
||||
};
|
||||
@ -32,7 +30,7 @@ impl PartialObject for PartialHalfEdge {
|
||||
cache: &mut FullToPartialCache,
|
||||
) -> Self {
|
||||
Self {
|
||||
curve: Some(half_edge.curve().path().into()),
|
||||
curve: Some(half_edge.curve().into()),
|
||||
vertices: half_edge
|
||||
.boundary()
|
||||
.zip_ext(half_edge.surface_vertices())
|
||||
@ -50,8 +48,7 @@ impl PartialObject for PartialHalfEdge {
|
||||
}
|
||||
|
||||
fn build(self, objects: &mut Service<Objects>) -> Self::Full {
|
||||
let curve = {
|
||||
let path = match self.curve.expect("Need path to build curve") {
|
||||
let curve = match self.curve.expect("Need path to build curve") {
|
||||
MaybeSurfacePath::Defined(path) => path,
|
||||
undefined => {
|
||||
panic!(
|
||||
@ -59,9 +56,6 @@ impl PartialObject for PartialHalfEdge {
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
Curve::new(path)
|
||||
};
|
||||
let vertices = self.vertices.map(|vertex| {
|
||||
let position_curve = vertex
|
||||
.0
|
||||
|
@ -101,10 +101,8 @@ impl CycleValidationError {
|
||||
.boundary()
|
||||
.zip_ext([half_edge.start_vertex(), next.start_vertex()]);
|
||||
for (position_on_curve, surface_vertex) in boundary_and_vertices {
|
||||
let curve_position_on_surface = half_edge
|
||||
.curve()
|
||||
.path()
|
||||
.point_from_path_coords(position_on_curve);
|
||||
let curve_position_on_surface =
|
||||
half_edge.curve().point_from_path_coords(position_on_curve);
|
||||
let surface_position_from_vertex = surface_vertex.position();
|
||||
|
||||
let distance = curve_position_on_surface
|
||||
|
Loading…
Reference in New Issue
Block a user