Remove GlobalCurve reference from GlobalEdge

This commit is contained in:
Hanno Braun 2023-02-22 13:45:54 +01:00
parent 2e8320699b
commit abfc679374
5 changed files with 9 additions and 37 deletions

View File

@ -2,7 +2,7 @@ use fj_math::Vector;
use crate::{ use crate::{
insert::Insert, insert::Insert,
objects::{GlobalCurve, GlobalEdge, GlobalVertex, Objects}, objects::{GlobalEdge, GlobalVertex, Objects},
services::Service, services::Service,
storage::Handle, storage::Handle,
}; };
@ -18,8 +18,6 @@ impl Sweep for Handle<GlobalVertex> {
cache: &mut SweepCache, cache: &mut SweepCache,
objects: &mut Service<Objects>, objects: &mut Service<Objects>,
) -> Self::Swept { ) -> Self::Swept {
let curve = GlobalCurve.insert(objects);
let a = self.clone(); let a = self.clone();
let b = cache let b = cache
.global_vertex .global_vertex
@ -30,8 +28,7 @@ impl Sweep for Handle<GlobalVertex> {
.clone(); .clone();
let vertices = [a, b]; let vertices = [a, b];
let global_edge = let global_edge = GlobalEdge::new(vertices.clone()).insert(objects);
GlobalEdge::new(curve, vertices.clone()).insert(objects);
// The vertices of the returned `GlobalEdge` are in normalized order, // The vertices of the returned `GlobalEdge` are in normalized order,
// which means the order can't be relied upon by the caller. Return the // which means the order can't be relied upon by the caller. Return the

View File

@ -43,15 +43,11 @@ impl TransformObject for GlobalEdge {
objects: &mut Service<Objects>, objects: &mut Service<Objects>,
cache: &mut TransformCache, cache: &mut TransformCache,
) -> Self { ) -> Self {
let curve = self
.curve()
.clone()
.transform_with_cache(transform, objects, cache);
let vertices = let vertices =
self.vertices().access_in_normalized_order().map(|vertex| { self.vertices().access_in_normalized_order().map(|vertex| {
vertex.transform_with_cache(transform, objects, cache) vertex.transform_with_cache(transform, objects, cache)
}); });
Self::new(curve, vertices) Self::new(vertices)
} }
} }

View File

@ -223,9 +223,6 @@ impl HalfEdgeBuilder for PartialHalfEdge {
other: &Partial<HalfEdge>, other: &Partial<HalfEdge>,
surface: &SurfaceGeometry, surface: &SurfaceGeometry,
) { ) {
let global_curve = other.read().global_form.read().curve.clone();
self.global_form.write().curve = global_curve;
self.curve.write().path = self.curve.write().path =
other.read().curve.read().path.as_ref().and_then(|path| { other.read().curve.read().path.as_ref().and_then(|path| {
// We have information about the other edge's surface available. // We have information about the other edge's surface available.

View File

@ -2,8 +2,8 @@ use fj_interop::ext::ArrayExt;
use fj_math::Point; use fj_math::Point;
use crate::{ use crate::{
objects::{Curve, GlobalCurve, GlobalVertex, SurfaceVertex}, objects::{Curve, GlobalVertex, SurfaceVertex},
storage::{Handle, HandleWrapper}, storage::Handle,
}; };
/// A directed edge, defined in a surface's 2D space /// A directed edge, defined in a surface's 2D space
@ -104,7 +104,6 @@ impl HalfEdge {
/// between [`HalfEdge`] and `GlobalEdge`. /// between [`HalfEdge`] and `GlobalEdge`.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct GlobalEdge { pub struct GlobalEdge {
curve: HandleWrapper<GlobalCurve>,
vertices: VerticesInNormalizedOrder, vertices: VerticesInNormalizedOrder,
} }
@ -114,19 +113,10 @@ impl GlobalEdge {
/// The order of `vertices` is irrelevant. Two `GlobalEdge`s with the same /// The order of `vertices` is irrelevant. Two `GlobalEdge`s with the same
/// `curve` and `vertices` will end up being equal, regardless of the order /// `curve` and `vertices` will end up being equal, regardless of the order
/// of `vertices` here. /// of `vertices` here.
pub fn new( pub fn new(vertices: [Handle<GlobalVertex>; 2]) -> Self {
curve: impl Into<HandleWrapper<GlobalCurve>>,
vertices: [Handle<GlobalVertex>; 2],
) -> Self {
let curve = curve.into();
let (vertices, _) = VerticesInNormalizedOrder::new(vertices); let (vertices, _) = VerticesInNormalizedOrder::new(vertices);
Self { curve, vertices } Self { vertices }
}
/// Access the curve that defines the edge's geometry
pub fn curve(&self) -> &Handle<GlobalCurve> {
&self.curve
} }
/// Access the vertices that bound the edge on the curve /// Access the vertices that bound the edge on the curve

View File

@ -5,8 +5,7 @@ use fj_math::Point;
use crate::{ use crate::{
objects::{ objects::{
Curve, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Objects, Curve, GlobalEdge, GlobalVertex, HalfEdge, Objects, SurfaceVertex,
SurfaceVertex,
}, },
partial::{FullToPartialCache, Partial, PartialObject}, partial::{FullToPartialCache, Partial, PartialObject},
services::Service, services::Service,
@ -84,7 +83,6 @@ impl Default for PartialHalfEdge {
let global_form = Partial::from_partial(PartialGlobalEdge { let global_form = Partial::from_partial(PartialGlobalEdge {
vertices: global_vertices, vertices: global_vertices,
..Default::default()
}); });
Self { Self {
@ -98,9 +96,6 @@ impl Default for PartialHalfEdge {
/// A partial [`GlobalEdge`] /// A partial [`GlobalEdge`]
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct PartialGlobalEdge { pub struct PartialGlobalEdge {
/// The curve that defines the edge's geometry
pub curve: Partial<GlobalCurve>,
/// The vertices that bound the edge on the curve /// The vertices that bound the edge on the curve
pub vertices: [Partial<GlobalVertex>; 2], pub vertices: [Partial<GlobalVertex>; 2],
} }
@ -113,7 +108,6 @@ impl PartialObject for PartialGlobalEdge {
cache: &mut FullToPartialCache, cache: &mut FullToPartialCache,
) -> Self { ) -> Self {
Self { Self {
curve: Partial::from_full(global_edge.curve().clone(), cache),
vertices: global_edge vertices: global_edge
.vertices() .vertices()
.access_in_normalized_order() .access_in_normalized_order()
@ -122,9 +116,7 @@ impl PartialObject for PartialGlobalEdge {
} }
fn build(self, objects: &mut Service<Objects>) -> Self::Full { fn build(self, objects: &mut Service<Objects>) -> Self::Full {
let curve = self.curve.build(objects);
let vertices = self.vertices.map(|vertex| vertex.build(objects)); let vertices = self.vertices.map(|vertex| vertex.build(objects));
GlobalEdge::new(vertices)
GlobalEdge::new(curve, vertices)
} }
} }