pub enum Selector<K> {
ByKey(K),
ByIndex(usize),
}
Expand description
Entity selector.
Identifies an entity by key or index. Keys behave as an absolute selector
and uniquely identify a single entity within a MeshGraph
. Indices behave
as a relative selector and identify an entity relative to some other entity.
Selector
is used by operations that support both of these selection
mechanisms.
An index is typically used to select an adjacent entity or contained (and ordered) entity, such as an adjacent face.
Examples
Splitting a face by index (of its contained vertices):
use decorum::R64;
use nalgebra::Point3;
use plexus::graph::MeshGraph;
use plexus::prelude::*;
use plexus::primitive::cube::Cube;
use plexus::primitive::generate::Position;
type E3 = Point3<R64>;
let mut graph: MeshGraph<E3> = Cube::new().polygons::<Position<E3>>().collect();
let key = graph.faces().nth(0).unwrap().key();
graph
.face_mut(key)
.unwrap()
.split(ByIndex(0), ByIndex(2))
.unwrap();
Variants
ByKey(K)
ByIndex(usize)
Implementations
sourceimpl<K> Selector<K>
impl<K> Selector<K>
sourcepub fn key_or_else<E, F>(self, f: F) -> Result<K, GraphError> where
E: Into<GraphError>,
F: Fn(usize) -> Result<K, E>,
pub fn key_or_else<E, F>(self, f: F) -> Result<K, GraphError> where
E: Into<GraphError>,
F: Fn(usize) -> Result<K, E>,
Gets the selector’s key or passes its index to a function to resolve the key.
sourcepub fn index_or_else<E, F>(self, f: F) -> Result<usize, GraphError> where
E: Into<GraphError>,
F: Fn(K) -> Result<usize, E>,
pub fn index_or_else<E, F>(self, f: F) -> Result<usize, GraphError> where
E: Into<GraphError>,
F: Fn(K) -> Result<usize, E>,
Gets the selector’s index or passes its key to a function to resolve the index.
Trait Implementations
impl<K: Copy> Copy for Selector<K>
impl<K: Eq> Eq for Selector<K>
impl<K> StructuralEq for Selector<K>
impl<K> StructuralPartialEq for Selector<K>
Auto Trait Implementations
impl<K> RefUnwindSafe for Selector<K> where
K: RefUnwindSafe,
impl<K> Send for Selector<K> where
K: Send,
impl<K> Sync for Selector<K> where
K: Sync,
impl<K> Unpin for Selector<K> where
K: Unpin,
impl<K> UnwindSafe for Selector<K> where
K: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> FromGeometry<T> for T
impl<T> FromGeometry<T> for T
fn from_geometry(other: T) -> T
sourceimpl<T, U> IntoGeometry<U> for T where
U: FromGeometry<T>,
impl<T, U> IntoGeometry<U> for T where
U: FromGeometry<T>,
fn into_geometry(self) -> U
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if 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
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.