Struct fj_kernel::objects::GlobalVertex
source · pub struct GlobalVertex { /* private fields */ }Expand description
A vertex, defined in global (3D) coordinates
This struct exists to distinguish between vertices and points at the type level. This is a relevant distinction, as vertices are part of a shape that help define its topology.
Points, on the other hand, might be used to approximate a shape for various purposes, without presenting any deeper truth about the shape’s structure.
Validation
Vertices must be unique within a shape, meaning an identical vertex must not
exist in the same shape. In the context of vertex uniqueness, points that
are close to each other are considered identical. The minimum distance
between distinct vertices can be configured using the respective field in
ValidationConfig.
Implementations§
source§impl GlobalVertex
impl GlobalVertex
sourcepub fn new(position: impl Into<Point<3>>) -> Self
pub fn new(position: impl Into<Point<3>>) -> Self
Construct a GlobalVertex from a position
Examples found in repository?
More examples
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
fn sweep_with_cache(
self,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
objects: &mut Service<Objects>,
) -> Self::Swept {
let curve = GlobalCurve.insert(objects);
let a = self.clone();
let b = cache
.global_vertex
.entry(self.id())
.or_insert_with(|| {
GlobalVertex::new(self.position() + path.into()).insert(objects)
})
.clone();
let vertices = [a, b];
let global_edge =
GlobalEdge::new(curve, vertices.clone()).insert(objects);
// The vertices of the returned `GlobalEdge` are in normalized order,
// which means the order can't be relied upon by the caller. Return the
// ordered vertices in addition.
(global_edge, vertices)
}sourcepub fn position(&self) -> Point<3>
pub fn position(&self) -> Point<3>
Access the position of the vertex
Examples found in repository?
More examples
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
fn approx_with_cache(
self,
tolerance: impl Into<Tolerance>,
cache: &mut Self::Cache,
) -> Self::Approximation {
let [a, b] = self.vertices();
let boundary = [a, b].map(|vertex| vertex.position());
let range = RangeOnPath { boundary };
let first = ApproxPoint::new(
a.surface_form().position(),
a.global_form().position(),
);
let curve_approx =
(self.curve(), range).approx_with_cache(tolerance, cache);
HalfEdgeApprox {
first,
curve_approx,
}
}155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
fn check_position(
surface_vertex: &SurfaceVertex,
config: &ValidationConfig,
) -> Result<(), Self> {
let surface_position_as_global = surface_vertex
.surface()
.geometry()
.point_from_surface_coords(surface_vertex.position());
let global_position = surface_vertex.global_form().position();
let distance = surface_position_as_global.distance_to(&global_position);
if distance > config.identical_max_distance {
return Err(Self::PositionMismatch {
surface_vertex: surface_vertex.clone(),
global_vertex: surface_vertex.global_form().clone_object(),
surface_position_as_global,
distance,
});
}
Ok(())
}126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
fn sweep_with_cache(
self,
path: impl Into<Vector<3>>,
cache: &mut SweepCache,
objects: &mut Service<Objects>,
) -> Self::Swept {
let curve = GlobalCurve.insert(objects);
let a = self.clone();
let b = cache
.global_vertex
.entry(self.id())
.or_insert_with(|| {
GlobalVertex::new(self.position() + path.into()).insert(objects)
})
.clone();
let vertices = [a, b];
let global_edge =
GlobalEdge::new(curve, vertices.clone()).insert(objects);
// The vertices of the returned `GlobalEdge` are in normalized order,
// which means the order can't be relied upon by the caller. Return the
// ordered vertices in addition.
(global_edge, vertices)
}Trait Implementations§
source§impl Clone for GlobalVertex
impl Clone for GlobalVertex
source§fn clone(&self) -> GlobalVertex
fn clone(&self) -> GlobalVertex
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for GlobalVertex
impl Debug for GlobalVertex
source§impl From<GlobalVertex> for Object<Bare>
impl From<GlobalVertex> for Object<Bare>
source§fn from(object: GlobalVertex) -> Self
fn from(object: GlobalVertex) -> Self
source§impl HasPartial for GlobalVertex
impl HasPartial for GlobalVertex
§type Partial = PartialGlobalVertex
type Partial = PartialGlobalVertex
source§impl Hash for GlobalVertex
impl Hash for GlobalVertex
source§impl Insert for GlobalVertex
impl Insert for GlobalVertex
source§impl Ord for GlobalVertex
impl Ord for GlobalVertex
source§fn cmp(&self, other: &GlobalVertex) -> Ordering
fn cmp(&self, other: &GlobalVertex) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<GlobalVertex> for GlobalVertex
impl PartialEq<GlobalVertex> for GlobalVertex
source§fn eq(&self, other: &GlobalVertex) -> bool
fn eq(&self, other: &GlobalVertex) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd<GlobalVertex> for GlobalVertex
impl PartialOrd<GlobalVertex> for GlobalVertex
source§fn partial_cmp(&self, other: &GlobalVertex) -> Option<Ordering>
fn partial_cmp(&self, other: &GlobalVertex) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl TransformObject for GlobalVertex
impl TransformObject for GlobalVertex
source§fn transform_with_cache(
self,
transform: &Transform,
_: &mut Service<Objects>,
_: &mut TransformCache
) -> Self
fn transform_with_cache(
self,
transform: &Transform,
_: &mut Service<Objects>,
_: &mut TransformCache
) -> Self
source§fn transform(self, transform: &Transform, objects: &mut Service<Objects>) -> Self
fn transform(self, transform: &Transform, objects: &mut Service<Objects>) -> Self
source§impl Validate for GlobalVertex
impl Validate for GlobalVertex
impl Copy for GlobalVertex
impl Eq for GlobalVertex
impl StructuralEq for GlobalVertex
impl StructuralPartialEq for GlobalVertex
Auto Trait Implementations§
impl RefUnwindSafe for GlobalVertex
impl Send for GlobalVertex
impl Sync for GlobalVertex
impl Unpin for GlobalVertex
impl UnwindSafe for GlobalVertex
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.