Trait meshx::algo::connectivity::Connectivity
source · pub trait Connectivity<Src: ElementIndex<usize>, Via: ElementIndex<usize>> {
type Topo: Default;
// Required methods
fn num_elements(&self) -> usize;
fn push_neighbours<T: Default + PartialEq>(
&self,
index: Src,
stack: &mut Vec<Src>,
topo: &Self::Topo,
attribute: Option<&[T]>
);
// Provided methods
fn precompute_topo(&self) -> Self::Topo { ... }
fn connectivity(&self) -> (Vec<usize>, usize) { ... }
fn connectivity_via_attrib<T>(
&self,
attrib: Option<&str>
) -> (Vec<usize>, usize)
where Self: Attrib,
Src: AttribIndex<Self>,
T: Default + PartialEq + 'static { ... }
fn connectivity_via_attrib_fn<'a, T, F>(&self, f: F) -> (Vec<usize>, usize)
where T: Default + PartialEq + 'a,
F: FnOnce() -> Option<&'a [T]> { ... }
}
Expand description
A trait defining the primary method for determining connectivity in a mesh.
Src
specifies the element index for which to determine connectivity.
Via
specifies a secondary element index which identifies elements through which the
connectivity is determined.
Required Associated Types§
Required Methods§
sourcefn num_elements(&self) -> usize
fn num_elements(&self) -> usize
Get the number of elements which are considered for connectivity
E.g. triangles in triangle meshes or tets in a tetmesh.
sourcefn push_neighbours<T: Default + PartialEq>(
&self,
index: Src,
stack: &mut Vec<Src>,
topo: &Self::Topo,
attribute: Option<&[T]>
)
fn push_neighbours<T: Default + PartialEq>( &self, index: Src, stack: &mut Vec<Src>, topo: &Self::Topo, attribute: Option<&[T]> )
Push all neighbours of the element at the given index
to the given stack
.
Additionally, topology data topo
computed using precomute_topo
and an
optional attribute
on the Src
topology is provided to help determine connectivity.
Provided Methods§
sourcefn precompute_topo(&self) -> Self::Topo
fn precompute_topo(&self) -> Self::Topo
Precompute additional topology information prior to determining connectivity.
An optional function that allows implementers to precompute topology information to help
with the implementation of push_neighbours
when the mesh doesn’t already support a
certain type of topology.
sourcefn connectivity(&self) -> (Vec<usize>, usize)
fn connectivity(&self) -> (Vec<usize>, usize)
Determine the connectivity of a set of meshes.
Return a Vec
with the size of self.num_elements()
indicating a unique ID of the
connected component each element belongs to. For instance, if two triangles in a triangle
mesh blong to the same connected component, they will have the same ID. Also return the
total number of components generated.
sourcefn connectivity_via_attrib<T>(
&self,
attrib: Option<&str>
) -> (Vec<usize>, usize)
fn connectivity_via_attrib<T>( &self, attrib: Option<&str> ) -> (Vec<usize>, usize)
Determine the connectivity of a set of meshes.
Return a Vec
with the size of self.num_elements()
indicating a unique ID of the
connected component each element belongs to. For instance, if two triangles in a triangle
mesh blong to the same connected component, they will have the same ID. Also return the
total number of components generated.
This is a more general version of connectivity
that accepts an optional attribute of type
T
on the Src
topology to determine connectivity.
sourcefn connectivity_via_attrib_fn<'a, T, F>(&self, f: F) -> (Vec<usize>, usize)
fn connectivity_via_attrib_fn<'a, T, F>(&self, f: F) -> (Vec<usize>, usize)
Determine the connectivity of a set of meshes.
Return a Vec
with the size of self.num_elements()
indicating a unique ID of the
connected component each element belongs to. For instance, if two triangles in a triangle
mesh blong to the same connected component, they will have the same ID. Also return the
total number of components generated.
This is the most general version of connectivity
that accepts a function that providees
attribute data of type T
on the Src
topology to determine connectivity.
Note that the provided slice must have the same length as the number of Src
indices.
Object Safety§
Implementors§
source§impl<M: FaceVertex + NumFaces + NumVertices> Connectivity<FaceVertexIndex, VertexIndex> for M
impl<M: FaceVertex + NumFaces + NumVertices> Connectivity<FaceVertexIndex, VertexIndex> for M
Implement face vertex connectivity for face based meshes (e.g. PolyMesh, TriMesh and QuadMesh).
This can be useful for splitting meshes based on texture coordinates, so that they can be exported in formats that don’t support additional face-vertex topologies like glTF.
source§impl<M: FaceVertex + NumVertices + NumFaces> Connectivity<VertexIndex, FaceIndex> for M
impl<M: FaceVertex + NumVertices + NumFaces> Connectivity<VertexIndex, FaceIndex> for M
Implement vertex connectivity for face based meshes (e.g. PolyMesh, TriMesh and QuadMesh).
source§impl<M: VertexCell + CellVertex + NumVertices> Connectivity<VertexIndex, CellIndex> for M
impl<M: VertexCell + CellVertex + NumVertices> Connectivity<VertexIndex, CellIndex> for M
Implement vertex connectivity for cell based meshes (e.g. TetMesh).