Struct fj_core::objects::Vertex

source ·
pub struct Vertex {}
Expand description

§A vertex that identifies a point in space

§Purpose

Vertices are referenced by HalfEdges. They are topological objects, which means that their purpose is to define how parts of a shape relate to each other. They identify a point in space, but they do not define its position.

In fact, this struct does not contain any data at all which could define anything. As such, Vertex is solely intended to be used through a Handle, which provides the vertex with a unique identity, allowing it to do its job.

Having a unique identity for a point in space is very valuable, as we can’t just rely on the value of points to compare them. If two half-edges connect, we expect them to connect at a single point, not two points that are very close to each other.

Due to the realities of computing (and specifically, the realities of computing floating-point numbers), we might very well end up thinking that our code computed a single point, when in fact it does not, which only shows up outside of our testing environment. This can be a pervasive source of bugs, if left unchecked.

With Vertex, we can provide a unique identity to each point where it is computed. This allows validation code to exist, which can identify where our code generates multiple distinct points that might end up in slightly different positions in a real-life scenario.

§Positions

(Warning: If the following information is relevant to you, please double- check it by looking at the code that this section references. Everything here is true at the time of writing, but there are planned changes which could make this section obsolete.)

A vertex can exist in multiple distinct spaces, and can thus have multiple positions. Those positions are defined by the objects that reference the vertex. How exactly that happens depends on the overall shape.

If the shape is defined by a Sketch, it is 2D-only. The (2D) position of the vertex will then be defined by the half-edges that reference it. Validation code can make sure that those redundant definitions don’t result in wildly different values.

If the shape is defined by a Solid, then it it 3-dimensional. The referencing half-edges still define the surface-local 2D positions of the vertex. Since such half-edges could meet in the same surface, or exist where multiple surfaces meet, these positions could end up being in one or more surfaces.

The corresponding Surface objects can then be used to convert those 2D positions into global 3D positions.

As you might have noted, in each case, we still have redundant definitions of the vertex position, and might end up with multiple values for the position that are not exactly equal. However, since we know these positions belong to the same vertex, this is not a problem.

Validation code can make sure that the actual values are very close together, and where we lose this identity information(when generating a triangle mesh for a file export, for example), we can choose exactly one of those values.

§Equality

Vertex contains no data and exists purely to be referenced via a Handle, where Handle::id can be used to compare different instances of it.

If Vertex had Eq/PartialEq implementations, it containing no data would mean that all instances of Vertex would be considered equal. This would be very error-prone.

If you need to reference a Vertex from a struct that needs to derive Eq/Ord/…, you can use HandleWrapper<Vertex> to do that. It will use Handle::id to provide those Eq/Ord/… implementations.

Implementations§

source§

impl Vertex

source

pub fn new() -> Self

Construct a Vertex

Trait Implementations§

source§

impl Clone for Vertex

source§

fn clone(&self) -> Vertex

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CurveBoundaryElement for Vertex

§

type Repr = HandleWrapper<Vertex>

The representation the curve boundary element Read more
source§

impl Debug for Vertex

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Vertex

source§

fn default() -> Vertex

Returns the “default value” for a type. Read more
source§

impl From<Vertex> for AnyObject<Bare>

source§

fn from(object: Vertex) -> Self

Converts to this type from the input type.
source§

impl Hash for Vertex

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Insert for Vertex

§

type Inserted = Handle<Vertex>

The type of Self, once it has been inserted Read more
source§

fn insert(self, core: &mut Core) -> Self::Inserted

Insert the object into its respective store Read more
source§

impl IsObject for Vertex

§

type BareObject = Vertex

The type of the bare object
source§

impl TransformObject for Vertex

source§

fn transform_with_cache( &self, _: &Transform, _: &mut Core, _: &mut TransformCache ) -> Self

Transform the object using the provided cache
source§

fn transform(&self, transform: &Transform, core: &mut Core) -> Self

Transform the object
source§

fn translate(&self, offset: impl Into<Vector<3>>, core: &mut Core) -> Self

Translate the object Read more
source§

fn rotate(&self, axis_angle: impl Into<Vector<3>>, core: &mut Core) -> Self

Rotate the object Read more
source§

impl Validate for Vertex

source§

fn validate( &self, _: &ValidationConfig, _: &mut Vec<ValidationError>, _: &Geometry )

Validate the object
source§

fn validate_and_return_first_error( &self, geometry: &Geometry ) -> Result<(), ValidationError>

Validate the object using default config and return on first error
source§

impl Copy for Vertex

Auto Trait Implementations§

§

impl Freeze for Vertex

§

impl RefUnwindSafe for Vertex

§

impl Send for Vertex

§

impl Sync for Vertex

§

impl Unpin for Vertex

§

impl UnwindSafe for Vertex

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.