Reference Curve from HalfEdge

The intention is to eventually replace `GlobalEdge`.
This commit is contained in:
Hanno Braun 2023-07-14 10:35:00 +02:00
parent bbfd1a5e50
commit a849efa3db
6 changed files with 21 additions and 4 deletions

View File

@ -18,6 +18,10 @@ impl TransformObject for HalfEdge {
// coordinates. // coordinates.
let path = self.path(); let path = self.path();
let boundary = self.boundary(); let boundary = self.boundary();
let curve = self
.curve()
.clone()
.transform_with_cache(transform, services, cache);
let start_vertex = self let start_vertex = self
.start_vertex() .start_vertex()
.clone() .clone()
@ -27,7 +31,7 @@ impl TransformObject for HalfEdge {
.clone() .clone()
.transform_with_cache(transform, services, cache); .transform_with_cache(transform, services, cache);
Self::new(path, boundary, start_vertex, global_form) Self::new(path, boundary, curve, start_vertex, global_form)
} }
} }

View File

@ -2,7 +2,7 @@ use fj_math::Point;
use crate::{ use crate::{
geometry::{BoundaryOnCurve, SurfacePath}, geometry::{BoundaryOnCurve, SurfacePath},
objects::Vertex, objects::{Curve, Vertex},
storage::{Handle, HandleWrapper}, storage::{Handle, HandleWrapper},
}; };
@ -42,6 +42,7 @@ use crate::{
pub struct HalfEdge { pub struct HalfEdge {
path: SurfacePath, path: SurfacePath,
boundary: BoundaryOnCurve, boundary: BoundaryOnCurve,
curve: HandleWrapper<Curve>,
start_vertex: HandleWrapper<Vertex>, start_vertex: HandleWrapper<Vertex>,
global_form: HandleWrapper<GlobalEdge>, global_form: HandleWrapper<GlobalEdge>,
} }
@ -51,12 +52,14 @@ impl HalfEdge {
pub fn new( pub fn new(
path: SurfacePath, path: SurfacePath,
boundary: impl Into<BoundaryOnCurve>, boundary: impl Into<BoundaryOnCurve>,
curve: Handle<Curve>,
start_vertex: Handle<Vertex>, start_vertex: Handle<Vertex>,
global_form: Handle<GlobalEdge>, global_form: Handle<GlobalEdge>,
) -> Self { ) -> Self {
Self { Self {
path, path,
boundary: boundary.into(), boundary: boundary.into(),
curve: curve.into(),
start_vertex: start_vertex.into(), start_vertex: start_vertex.into(),
global_form: global_form.into(), global_form: global_form.into(),
} }
@ -82,6 +85,11 @@ impl HalfEdge {
self.path.point_from_path_coords(start) self.path.point_from_path_coords(start)
} }
/// Access the curve of the half-edge
pub fn curve(&self) -> &Handle<Curve> {
&self.curve
}
/// Access the vertex from where this half-edge starts /// Access the vertex from where this half-edge starts
pub fn start_vertex(&self) -> &Handle<Vertex> { pub fn start_vertex(&self) -> &Handle<Vertex> {
&self.start_vertex &self.start_vertex

View File

@ -3,7 +3,7 @@ use fj_math::{Arc, Point, Scalar};
use crate::{ use crate::{
geometry::{BoundaryOnCurve, SurfacePath}, geometry::{BoundaryOnCurve, SurfacePath},
objects::{GlobalEdge, HalfEdge, Vertex}, objects::{Curve, GlobalEdge, HalfEdge, Vertex},
operations::Insert, operations::Insert,
services::Services, services::Services,
}; };
@ -16,10 +16,11 @@ pub trait BuildHalfEdge {
boundary: impl Into<BoundaryOnCurve>, boundary: impl Into<BoundaryOnCurve>,
services: &mut Services, services: &mut Services,
) -> HalfEdge { ) -> HalfEdge {
let curve = Curve::new().insert(services);
let start_vertex = Vertex::new().insert(services); let start_vertex = Vertex::new().insert(services);
let global_form = GlobalEdge::new().insert(services); let global_form = GlobalEdge::new().insert(services);
HalfEdge::new(path, boundary, start_vertex, global_form) HalfEdge::new(path, boundary, curve, start_vertex, global_form)
} }
/// Create an arc /// Create an arc

View File

@ -14,6 +14,7 @@ impl Reverse for Cycle {
HalfEdge::new( HalfEdge::new(
current.path(), current.path(),
current.boundary().reverse(), current.boundary().reverse(),
current.curve().clone(),
next.start_vertex().clone(), next.start_vertex().clone(),
current.global_form().clone(), current.global_form().clone(),
) )

View File

@ -19,6 +19,7 @@ impl UpdateHalfEdge for HalfEdge {
HalfEdge::new( HalfEdge::new(
self.path(), self.path(),
self.boundary(), self.boundary(),
self.curve().clone(),
start_vertex, start_vertex,
self.global_form().clone(), self.global_form().clone(),
) )
@ -28,6 +29,7 @@ impl UpdateHalfEdge for HalfEdge {
HalfEdge::new( HalfEdge::new(
self.path(), self.path(),
self.boundary(), self.boundary(),
self.curve().clone(),
self.start_vertex().clone(), self.start_vertex().clone(),
global_form, global_form,
) )

View File

@ -95,6 +95,7 @@ mod tests {
HalfEdge::new( HalfEdge::new(
valid.path(), valid.path(),
boundary, boundary,
valid.curve().clone(),
valid.start_vertex().clone(), valid.start_vertex().clone(),
valid.global_form().clone(), valid.global_form().clone(),
) )