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 GlobalVertex to Vertex #1642

Merged
merged 15 commits into from
Mar 2, 2023
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/sweep/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use itertools::Itertools;
use crate::{
builder::{CycleBuilder, HalfEdgeBuilder},
insert::Insert,
objects::{Face, GlobalVertex, HalfEdge, Objects, Surface},
objects::{Face, HalfEdge, Objects, Surface, Vertex},
partial::{Partial, PartialFace, PartialObject},
services::Service,
storage::Handle,
};

use super::{Sweep, SweepCache};

impl Sweep for (Handle<HalfEdge>, &Handle<GlobalVertex>, &Surface, Color) {
impl Sweep for (Handle<HalfEdge>, &Handle<Vertex>, &Surface, Color) {
type Swept = (Handle<Face>, Handle<HalfEdge>);

fn sweep_with_cache(
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/sweep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::collections::BTreeMap;
use fj_math::Vector;

use crate::{
objects::{GlobalVertex, Objects},
objects::{Objects, Vertex},
services::Service,
storage::{Handle, ObjectId},
};
Expand Down Expand Up @@ -46,5 +46,5 @@ pub trait Sweep: Sized {
#[derive(Default)]
pub struct SweepCache {
/// Cache for global vertices
pub global_vertex: BTreeMap<ObjectId, Handle<GlobalVertex>>,
pub global_vertex: BTreeMap<ObjectId, Handle<Vertex>>,
}
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/sweep/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use fj_math::Vector;

use crate::{
insert::Insert,
objects::{GlobalEdge, GlobalVertex, Objects},
objects::{GlobalEdge, Objects, Vertex},
services::Service,
storage::Handle,
};

use super::{Sweep, SweepCache};

impl Sweep for Handle<GlobalVertex> {
impl Sweep for Handle<Vertex> {
type Swept = (Handle<GlobalEdge>, [Self; 2]);

fn sweep_with_cache(
Expand All @@ -23,7 +23,7 @@ impl Sweep for Handle<GlobalVertex> {
.global_vertex
.entry(self.id())
.or_insert_with(|| {
GlobalVertex::new(self.position() + path.into()).insert(objects)
Vertex::new(self.position() + path.into()).insert(objects)
})
.clone();

Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/transform/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use fj_math::Transform;

use crate::{
objects::{GlobalVertex, Objects},
objects::{Objects, Vertex},
services::Service,
};

use super::{TransformCache, TransformObject};

impl TransformObject for GlobalVertex {
impl TransformObject for Vertex {
fn transform_with_cache(
self,
transform: &Transform,
Expand Down
10 changes: 5 additions & 5 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
curve::{Curve, GlobalPath},
surface::SurfaceGeometry,
},
objects::{GlobalEdge, GlobalVertex, HalfEdge},
objects::{GlobalEdge, HalfEdge, Vertex},
partial::{MaybeCurve, Partial, PartialGlobalEdge, PartialHalfEdge},
};

Expand Down Expand Up @@ -44,14 +44,14 @@ pub trait HalfEdgeBuilder {
/// it.
fn infer_global_form(
&mut self,
next_vertex: Partial<GlobalVertex>,
next_vertex: Partial<Vertex>,
) -> Partial<GlobalEdge>;

/// Infer the vertex positions (surface and global), if not already set
fn infer_vertex_positions_if_necessary(
&mut self,
surface: &SurfaceGeometry,
next_vertex: Partial<GlobalVertex>,
next_vertex: Partial<Vertex>,
);

/// Update this edge from another
Expand Down Expand Up @@ -153,7 +153,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {

fn infer_global_form(
&mut self,
next_vertex: Partial<GlobalVertex>,
next_vertex: Partial<Vertex>,
) -> Partial<GlobalEdge> {
self.global_form.write().vertices =
[&self.start_vertex, &next_vertex].map(|vertex| vertex.clone());
Expand All @@ -164,7 +164,7 @@ impl HalfEdgeBuilder for PartialHalfEdge {
fn infer_vertex_positions_if_necessary(
&mut self,
surface: &SurfaceGeometry,
next_vertex: Partial<GlobalVertex>,
next_vertex: Partial<Vertex>,
) {
let path = self
.curve
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use self::{
sketch::SketchBuilder,
solid::SolidBuilder,
surface::SurfaceBuilder,
vertex::GlobalVertexBuilder,
vertex::VertexBuilder,
};

/// Pass objects to a builder method
Expand Down
8 changes: 4 additions & 4 deletions crates/fj-kernel/src/builder/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::partial::PartialGlobalVertex;
use crate::partial::PartialVertex;

/// Builder API for [`PartialGlobalVertex`]
pub trait GlobalVertexBuilder {
/// Builder API for [`PartialVertex`]
pub trait VertexBuilder {
// No methods are currently defined. This trait serves as a placeholder, to
// make it clear where to add such methods, once necessary.
}

impl GlobalVertexBuilder for PartialGlobalVertex {}
impl VertexBuilder for PartialVertex {}
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use crate::{
objects::{
Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Objects, Shell,
Sketch, Solid, Surface,
Cycle, Face, GlobalEdge, HalfEdge, Objects, Shell, Sketch, Solid,
Surface, Vertex,
},
services::{Service, ServiceObjectsExt},
storage::Handle,
Expand Down Expand Up @@ -37,10 +37,10 @@ impl_insert!(
Cycle, cycles;
Face, faces;
GlobalEdge, global_edges;
GlobalVertex, global_vertices;
HalfEdge, half_edges;
Shell, shells;
Sketch, sketches;
Solid, solids;
Surface, surfaces;
Vertex, vertices;
);
16 changes: 8 additions & 8 deletions crates/fj-kernel/src/objects/full/edge.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use fj_math::Point;

use crate::{geometry::curve::Curve, objects::GlobalVertex, storage::Handle};
use crate::{geometry::curve::Curve, objects::Vertex, storage::Handle};

/// A directed edge, defined in a surface's 2D space
///
Expand Down Expand Up @@ -42,7 +42,7 @@ use crate::{geometry::curve::Curve, objects::GlobalVertex, storage::Handle};
pub struct HalfEdge {
curve: Curve,
boundary: [Point<1>; 2],
start_vertex: Handle<GlobalVertex>,
start_vertex: Handle<Vertex>,
global_form: Handle<GlobalEdge>,
}

Expand All @@ -51,7 +51,7 @@ impl HalfEdge {
pub fn new(
curve: Curve,
boundary: [Point<1>; 2],
start_vertex: Handle<GlobalVertex>,
start_vertex: Handle<Vertex>,
global_form: Handle<GlobalEdge>,
) -> Self {
Self {
Expand Down Expand Up @@ -83,7 +83,7 @@ impl HalfEdge {
}

/// Access the vertex from where this half-edge starts
pub fn start_vertex(&self) -> &Handle<GlobalVertex> {
pub fn start_vertex(&self) -> &Handle<Vertex> {
&self.start_vertex
}

Expand Down Expand Up @@ -113,7 +113,7 @@ impl GlobalEdge {
/// The order of `vertices` is irrelevant. Two `GlobalEdge`s with the same
/// `curve` and `vertices` will end up being equal, regardless of the order
/// of `vertices` here.
pub fn new(vertices: [Handle<GlobalVertex>; 2]) -> Self {
pub fn new(vertices: [Handle<Vertex>; 2]) -> Self {
let (vertices, _) = VerticesInNormalizedOrder::new(vertices);

Self { vertices }
Expand All @@ -137,14 +137,14 @@ impl GlobalEdge {
/// possible to construct two [`GlobalEdge`] instances that are meant to
/// represent the same edge, but aren't equal.
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct VerticesInNormalizedOrder([Handle<GlobalVertex>; 2]);
pub struct VerticesInNormalizedOrder([Handle<Vertex>; 2]);

impl VerticesInNormalizedOrder {
/// Construct a new instance of `VerticesInNormalizedOrder`
///
/// The provided vertices can be in any order. The returned `bool` value
/// indicates whether the normalization changed the order of the vertices.
pub fn new([a, b]: [Handle<GlobalVertex>; 2]) -> (Self, bool) {
pub fn new([a, b]: [Handle<Vertex>; 2]) -> (Self, bool) {
if a < b {
(Self([a, b]), false)
} else {
Expand All @@ -155,7 +155,7 @@ impl VerticesInNormalizedOrder {
/// Access the vertices
///
/// The vertices in the returned array will be in normalized order.
pub fn access_in_normalized_order(&self) -> [Handle<GlobalVertex>; 2] {
pub fn access_in_normalized_order(&self) -> [Handle<Vertex>; 2] {
self.0.clone()
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/objects/full/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use fj_math::Point;
///
/// [`ValidationConfig`]: crate::validate::ValidationConfig
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct GlobalVertex {
pub struct Vertex {
position: Point<3>,
}

impl GlobalVertex {
/// Construct a `GlobalVertex` from a position
impl Vertex {
/// Construct a `Vertex` from a position
pub fn new(position: impl Into<Point<3>>) -> Self {
let position = position.into();
Self { position }
Expand Down
24 changes: 12 additions & 12 deletions crates/fj-kernel/src/objects/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! Objects of a shape
//!
//! Objects, in Fornjot parlance, are the elements that make up shapes. An
//! object can be simple and just contain data (like [`GlobalVertex`], for
//! example), or they can be quite complex and refer to other objects (which is
//! actually most of them).
//! object can be simple and just contain data (like [`Vertex`], for example),
//! or they can be quite complex and refer to other objects (which is actually
//! most of them).
//!
//! # Object Identity vs Object Equality
//!
//! Two objects are *equal*, if they contain the same data. For example, two
//! instances of [`GlobalVertex`] are equal, if they have the same position.
//! This doesn't mean those objects are *identical*. They might have been
//! created by different pieces of code. Or maybe by the same piece of code, but
//! at different times, maybe even based on different inputs.
//! instances of [`Vertex`] are equal, if they have the same position. This
//! doesn't mean those objects are *identical*. They might have been created by
//! different pieces of code. Or maybe by the same piece of code, but at
//! different times, maybe even based on different inputs.
//!
//! This distinction is relevant, because non-identical objects that are
//! *supposed* to be equal can end up being equal, if they are created based on
Expand All @@ -28,8 +28,8 @@
//!
//! If you compute the global coordinates from each of the line-local
//! coordinates, you'll end up with the same result for sure. If we create two
//! [`GlobalVertex`] instances from these global coordinates, any validation
//! code that expects those two instances to be equal, will be happy.
//! [`Vertex`] instances from these global coordinates, any validation code that
//! expects those two instances to be equal, will be happy.
//!
//! But what if the situation is not so simple? Let's say the curves are circles
//! instead of lines, and instead of being all neat, they are at some arbitrary
Expand All @@ -52,8 +52,8 @@
//! identity, not equality. That way, this problem can never happen, because we
//! never expect non-identical objects to be the same.
//!
//! For our example, this would mean we compute *one* [`GlobalVertex`] from
//! *one* of the local coordinates.
//! For our example, this would mean we compute *one* [`Vertex`] from *one* of
//! the local coordinates.
//!
//! ## How Identity Works
//!
Expand Down Expand Up @@ -86,7 +86,7 @@ pub use self::{
sketch::Sketch,
solid::Solid,
surface::Surface,
vertex::GlobalVertex,
vertex::Vertex,
},
object::{Bare, BehindHandle, Form, Object, WithHandle},
stores::{Objects, Surfaces},
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/objects/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::any::Any;

use crate::{
objects::{
Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Objects, Shell,
Sketch, Solid, Surface,
Cycle, Face, GlobalEdge, HalfEdge, Objects, Shell, Sketch, Solid,
Surface, Vertex,
},
storage::{Handle, ObjectId},
validate::{Validate, ValidationError},
Expand Down Expand Up @@ -111,12 +111,12 @@ object!(
Cycle, "cycle", cycles;
Face, "face", faces;
GlobalEdge, "global edge", global_edges;
GlobalVertex, "global vertex", global_vertices;
HalfEdge, "half-edge", half_edges;
Shell, "shell", shells;
Sketch, "sketch", sketches;
Solid, "solid", solids;
Surface, "surface", surfaces;
Vertex, "vertex", vertices;
);

/// The form that an object can take
Expand Down
9 changes: 4 additions & 5 deletions crates/fj-kernel/src/objects/stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use crate::{
};

use super::{
Cycle, Face, GlobalEdge, GlobalVertex, HalfEdge, Shell, Sketch, Solid,
Surface,
Cycle, Face, GlobalEdge, HalfEdge, Shell, Sketch, Solid, Surface, Vertex,
};

/// The available object stores
Expand All @@ -22,9 +21,6 @@ pub struct Objects {
/// Store for [`GlobalEdge`]s
pub global_edges: Store<GlobalEdge>,

/// Store for [`GlobalVertex`] objects
pub global_vertices: Store<GlobalVertex>,

/// Store for [`HalfEdge`]s
pub half_edges: Store<HalfEdge>,

Expand All @@ -39,6 +35,9 @@ pub struct Objects {

/// Store for [`Surface`]s
pub surfaces: Surfaces,

/// Store for [`Vertex`] objects
pub vertices: Store<Vertex>,
}

impl Objects {
Expand Down
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/partial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use self::{
sketch::PartialSketch,
solid::PartialSolid,
surface::PartialSurface,
vertex::PartialGlobalVertex,
vertex::PartialVertex,
},
traits::{HasPartial, PartialObject},
wrapper::{FullToPartialCache, Partial},
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/partial/objects/edge.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fj_math::Point;

use crate::{
objects::{GlobalEdge, GlobalVertex, HalfEdge, Objects},
objects::{GlobalEdge, HalfEdge, Objects, Vertex},
partial::{FullToPartialCache, MaybeCurve, Partial, PartialObject},
services::Service,
};
Expand All @@ -16,7 +16,7 @@ pub struct PartialHalfEdge {
pub boundary: [Option<Point<1>>; 2],

/// The surface vertex where the half-edge starts
pub start_vertex: Partial<GlobalVertex>,
pub start_vertex: Partial<Vertex>,

/// The global form of the half-edge
pub global_form: Partial<GlobalEdge>,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl Default for PartialHalfEdge {
#[derive(Clone, Debug, Default)]
pub struct PartialGlobalEdge {
/// The vertices that bound the edge on the curve
pub vertices: [Partial<GlobalVertex>; 2],
pub vertices: [Partial<Vertex>; 2],
}

impl PartialObject for PartialGlobalEdge {
Expand Down
Loading