UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FMeshConnectedComponents Class Reference

#include <MeshConnectedComponents.h>

Classes

struct  FComponent
 

Public Member Functions

 FMeshConnectedComponents (const FDynamicMesh3 *MeshIn)
 
GEOMETRYCORE_API void FindConnectedTriangles (TFunction< bool(int32, int32)> TrisConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindConnectedTriangles (const TArray< int > &TriangleROI, TFunction< bool(int32, int32)> TrisConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindConnectedTriangles (TFunctionRef< bool(int)> IndexFilterFunc, TFunction< bool(int32, int32)> TrisConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindTrianglesConnectedToSeeds (const TArray< int > &SeedTriangles, TFunction< bool(int32, int32)> TrisConnectedPredicate=nullptr)
 
GEOMETRYCORE_API bool InitializeFromTriangleComponents (const TArray< TArray< int32 > > &ComponentLists, bool bValidateIDs)
 
GEOMETRYCORE_API bool InitializeFromTriangleComponents (TArray< TArray< int32 > > &ComponentLists, bool bMoveSubLists, bool bValidateIDs)
 
GEOMETRYCORE_API void FindConnectedVertices (TFunction< bool(int32, int32)> VertsConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindConnectedVertices (const TArray< int > &VertexROI, TFunction< bool(int32, int32)> VertsConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindConnectedVertices (TFunctionRef< bool(int)> IndexFilterFunc, TFunction< bool(int32, int32)>VertsConnectedPredicate=nullptr)
 
GEOMETRYCORE_API void FindVerticesConnectedToSeeds (const TArray< int > &SeedVertices, TFunction< bool(int32, int32)> VertsConnectedPredicate=nullptr)
 
GEOMETRYCORE_API bool InitializeFromVertexComponents (const TArray< TArray< int32 > > &ComponentLists, bool bValidateIDs)
 
GEOMETRYCORE_API bool InitializeFromVertexComponents (TArray< TArray< int32 > > &ComponentLists, bool bMoveSubLists, bool bValidateIDs)
 
int32 Num () const
 
const FComponentGetComponent (int32 Index) const
 
FComponentGetComponent (int32 Index)
 
const FComponentoperator[] (int32 Index) const
 
FComponentoperator[] (int32 Index)
 
GEOMETRYCORE_API int32 GetLargestIndexByCount () const
 
GEOMETRYCORE_API void SortByCount (bool bLargestFirst=true)
 
auto begin ()
 
auto begin () const
 
auto end ()
 
auto end () const
 

Static Public Member Functions

static GEOMETRYCORE_API void GrowToConnectedTriangles (const FDynamicMesh3 *Mesh, const TArray< int > &InputROI, TArray< int > &ResultROI, TArray< int32 > *QueueBuffer=nullptr, TSet< int32 > *DoneBuffer=nullptr, TFunctionRef< bool(int32, int32)> CanGrowPredicate=[](int32, int32) { return true;})
 
static GEOMETRYCORE_API void GrowToConnectedTriangles (const FDynamicMesh3 *Mesh, const TArray< int > &InputROI, TSet< int > &ResultROI, TArray< int32 > *QueueBuffer=nullptr, TFunctionRef< bool(int32, int32)> CanGrowPredicate=[](int32, int32) { return true;})
 
static GEOMETRYCORE_API void GrowToConnectedVertices (const FDynamicMesh3 &Mesh, const TArray< int > &InputROI, TSet< int > &ResultROI, TArray< int32 > *QueueBuffer=nullptr, TFunctionRef< bool(int32, int32)> CanGrowPredicate=[](int32, int32) { return true;})
 
static GEOMETRYCORE_API void GrowToConnectedEdges (const FDynamicMesh3 &Mesh, const TArray< int > &InputROI, TSet< int > &ResultROI, TArray< int32 > *QueueBuffer=nullptr, TFunctionRef< bool(int32, int32)> CanGrowPredicate=[](int32, int32) { return true;})
 

Public Attributes

const FDynamicMesh3Mesh
 
TIndirectArray< FComponentComponents
 

Protected Member Functions

GEOMETRYCORE_API void FindTriComponents (FInterval1i ActiveRange, TArray< uint8 > &ActiveSet, TFunction< bool(int32, int32)> TriConnectedPredicate)
 
GEOMETRYCORE_API void FindTriComponents (const TArray< int32 > &SeedList, TArray< uint8 > &ActiveSet, TFunction< bool(int32, int32)> TriConnectedPredicate)
 
GEOMETRYCORE_API void FindTriComponent (FComponent *Component, TArray< int32 > &ComponentQueue, TArray< uint8 > &ActiveSet)
 
GEOMETRYCORE_API void FindTriComponent (FComponent *Component, TArray< int32 > &ComponentQueue, TArray< uint8 > &ActiveSet, TFunctionRef< bool(int32, int32)> TriConnectedPredicate)
 
GEOMETRYCORE_API void RemoveFromActiveSet (const FComponent *Component, TArray< uint8 > &ActiveSet)
 
GEOMETRYCORE_API void FindVertComponents (FInterval1i ActiveRange, TArray< uint8 > &ActiveSet, TFunction< bool(int32, int32)> VertsConnectedPredicate)
 
GEOMETRYCORE_API void FindVertComponents (const TArray< int32 > &SeedList, TArray< uint8 > &ActiveSet, TFunction< bool(int32, int32)> VertsConnectedPredicate)
 
GEOMETRYCORE_API void FindVertComponent (FComponent *Component, TArray< int32 > &ComponentQueue, TArray< uint8 > &ActiveSet)
 
GEOMETRYCORE_API void FindVertComponent (FComponent *Component, TArray< int32 > &ComponentQueue, TArray< uint8 > &ActiveSet, TFunctionRef< bool(int32, int32)> VertsConnectedPredicate)
 

Detailed Description

FMeshConnectedComponents calculates Connected Components of a Mesh, or sub-regions of a Mesh. By default the actual mesh connectivity is used, but an optional connectivity predicate can be provided to specify when two elements should be considered connected.

Constructor & Destructor Documentation

◆ FMeshConnectedComponents()

UE::Geometry::FMeshConnectedComponents::FMeshConnectedComponents ( const FDynamicMesh3 MeshIn)
inline

Member Function Documentation

◆ begin() [1/2]

auto UE::Geometry::FMeshConnectedComponents::begin ( )
inline

DO NOT USE DIRECTLY STL-like iterators to enable ranged-based for loop support (forwarding TIndirectArray declarations)

◆ begin() [2/2]

auto UE::Geometry::FMeshConnectedComponents::begin ( ) const
inline

◆ end() [1/2]

auto UE::Geometry::FMeshConnectedComponents::end ( )
inline

◆ end() [2/2]

auto UE::Geometry::FMeshConnectedComponents::end ( ) const
inline

◆ FindConnectedTriangles() [1/3]

void FMeshConnectedComponents::FindConnectedTriangles ( const TArray< int > &  TriangleROI,
TFunction< bool(int32, int32)>  TrisConnectedPredicate = nullptr 
)

Find all connected triangle components of a subset of triangles of the Mesh and store in Components array. Triangle connectivity is based on edge connectivity, ie bowtie-vertices are not connections between triangles.

Parameters
TriangleROIlist of triangles to search across
TrisConnectedPredicateoptional function that specifies whether two edge-connected triangles should be considered connected by the search

◆ FindConnectedTriangles() [2/3]

void FMeshConnectedComponents::FindConnectedTriangles ( TFunction< bool(int32, int32)>  TrisConnectedPredicate = nullptr)

Find all connected triangle components of the Mesh and store in Components array. Triangle connectivity is based on edge connectivity, ie bowtie-vertices are not connections between triangles.

Parameters
TrisConnectedPredicateoptional function that specifies whether two edge-connected triangles should be considered connected by the search

◆ FindConnectedTriangles() [3/3]

void FMeshConnectedComponents::FindConnectedTriangles ( TFunctionRef< bool(int)>  IndexFilterFunc,
TFunction< bool(int32, int32)>  TrisConnectedPredicate = nullptr 
)

Find all connected triangle components of a subset of triangles of the Mesh and store in Components array. Triangle connectivity is based on edge connectivity, ie bowtie-vertices are not connections between triangles.

Parameters
IndexFilterFuncdefines set of triangles to search across, return true for triangle IDs that are to be considered
TrisConnectedPredicateoptional function that specifies whether two edge-connected triangles should be considered connected by the search

◆ FindConnectedVertices() [1/3]

void FMeshConnectedComponents::FindConnectedVertices ( const TArray< int > &  VertexROI,
TFunction< bool(int32, int32)>  VertsConnectedPredicate = nullptr 
)

Find all connected vertex components of a subset of vertices of the Mesh and store in Components array.

Parameters
VertexROIlist of vertices to search across
VertsConnectedPredicateoptional function that specifies whether two edge-connected vertices should be considered connected by the search

◆ FindConnectedVertices() [2/3]

void FMeshConnectedComponents::FindConnectedVertices ( TFunction< bool(int32, int32)>  VertsConnectedPredicate = nullptr)

Find all connected vertex components of the Mesh and store in Components array.

Parameters
VertsConnectedPredicateoptional function that specifies whether two edge-connected vertices should be considered connected by the search

◆ FindConnectedVertices() [3/3]

void FMeshConnectedComponents::FindConnectedVertices ( TFunctionRef< bool(int)>  IndexFilterFunc,
TFunction< bool(int32, int32)>  VertsConnectedPredicate = nullptr 
)

Find all connected vertex components of a subset of vertices of the Mesh and store in Components array.

Parameters
IndexFilterFuncdefines set of vertices to search across, return true for vertex IDs that are to be considered
VertsConnectedPredicateoptional function that specifies whether two edge-connected vertices should be considered connected by the search

◆ FindTrianglesConnectedToSeeds()

void FMeshConnectedComponents::FindTrianglesConnectedToSeeds ( const TArray< int > &  SeedTriangles,
TFunction< bool(int32, int32)>  TrisConnectedPredicate = nullptr 
)

Find all connected triangle components that contain one or more Seed Triangles and store in Components array. Search only starts from Seed Triangles. Triangle connectivity is based on edge connectivity, ie bowtie-vertices are not connections between triangles.

Parameters
SeedTriangleslist of start triangles, each component contains at least one of these triangles
TrisConnectedPredicateoptional function that specifies whether two edge-connected triangles should be considered connected by the search

◆ FindTriComponent() [1/2]

void FMeshConnectedComponents::FindTriComponent ( FComponent Component,
TArray< int32 > &  ComponentQueue,
TArray< uint8 > &  ActiveSet 
)
protected

◆ FindTriComponent() [2/2]

void FMeshConnectedComponents::FindTriComponent ( FComponent Component,
TArray< int32 > &  ComponentQueue,
TArray< uint8 > &  ActiveSet,
TFunctionRef< bool(int32, int32)>  TriConnectedPredicate 
)
protected

◆ FindTriComponents() [1/2]

void FMeshConnectedComponents::FindTriComponents ( const TArray< int32 > &  SeedList,
TArray< uint8 > &  ActiveSet,
TFunction< bool(int32, int32)>  TriConnectedPredicate 
)
protected

◆ FindTriComponents() [2/2]

void FMeshConnectedComponents::FindTriComponents ( FInterval1i  ActiveRange,
TArray< uint8 > &  ActiveSet,
TFunction< bool(int32, int32)>  TriConnectedPredicate 
)
protected

◆ FindVertComponent() [1/2]

void FMeshConnectedComponents::FindVertComponent ( FComponent Component,
TArray< int32 > &  ComponentQueue,
TArray< uint8 > &  ActiveSet 
)
protected

◆ FindVertComponent() [2/2]

void FMeshConnectedComponents::FindVertComponent ( FComponent Component,
TArray< int32 > &  ComponentQueue,
TArray< uint8 > &  ActiveSet,
TFunctionRef< bool(int32, int32)>  VertsConnectedPredicate 
)
protected

◆ FindVertComponents() [1/2]

void FMeshConnectedComponents::FindVertComponents ( const TArray< int32 > &  SeedList,
TArray< uint8 > &  ActiveSet,
TFunction< bool(int32, int32)>  VertsConnectedPredicate 
)
protected

◆ FindVertComponents() [2/2]

void FMeshConnectedComponents::FindVertComponents ( FInterval1i  ActiveRange,
TArray< uint8 > &  ActiveSet,
TFunction< bool(int32, int32)>  VertsConnectedPredicate 
)
protected

◆ FindVerticesConnectedToSeeds()

void FMeshConnectedComponents::FindVerticesConnectedToSeeds ( const TArray< int > &  SeedVertices,
TFunction< bool(int32, int32)>  VertsConnectedPredicate = nullptr 
)

Find all connected vertex components that contain one or more Seed Vertices and store in Components array. Search only starts from Seed Vertices.

Parameters
SeedVerticeslist of start vertices, each component contains at least one of these vertices
VertsConnectedPredicateoptional function that specifies whether two edge-connected vertices should be considered connected by the search

◆ GetComponent() [1/2]

FComponent & UE::Geometry::FMeshConnectedComponents::GetComponent ( int32  Index)
inline
Returns
element of Components array at given Index

◆ GetComponent() [2/2]

const FComponent & UE::Geometry::FMeshConnectedComponents::GetComponent ( int32  Index) const
inline
Returns
element of Components array at given Index

◆ GetLargestIndexByCount()

int32 FMeshConnectedComponents::GetLargestIndexByCount ( ) const
Returns
index of largest component by element count

◆ GrowToConnectedEdges()

void FMeshConnectedComponents::GrowToConnectedEdges ( const FDynamicMesh3 Mesh,
const TArray< int > &  InputROI,
TSet< int > &  ResultROI,
TArray< int32 > *  QueueBuffer = nullptr,
TFunctionRef< bool(int32, int32)>  CanGrowPredicate = [](int32int32) { return true; } 
)
static

Utility function to expand an edge selection to all edges considered "connected".

Parameters
MeshMesh to calculate on
InputROIinput set of edges
ResultROIoutput set of edges connected to InputROI
QueueBufferoptional buffer used as internal Queue. If passed as nullptr, a TArray will be locally allocated
CanGrowPredicatedetermines whether two connected mesh edges should be considered connected while growing

◆ GrowToConnectedTriangles() [1/2]

void FMeshConnectedComponents::GrowToConnectedTriangles ( const FDynamicMesh3 Mesh,
const TArray< int > &  InputROI,
TArray< int > &  ResultROI,
TArray< int32 > *  QueueBuffer = nullptr,
TSet< int32 > *  DoneBuffer = nullptr,
TFunctionRef< bool(int32, int32)>  CanGrowPredicate = [](int32int32) { return true; } 
)
static

Utility function to expand a triangle selection to all triangles considered "connected". More efficient than using full FMeshConnectedComponents instance if ROI is small relative to Mesh size (or if temp buffers can be re-used)

Parameters
MeshMesh to calculate on
InputROIinput set of triangles
ResultROIoutput set of triangles connected to InputROI
QueueBufferoptional buffer used as internal Queue. If passed as nullptr, a TArray will be locally allocated
DoneBufferoptional set used to track which triangles have already been processed. If passed as nullptr, an TSet will be locally allocated
CanGrowPredicatedetermines whether two connected mesh triangles should be considered connected while growing

◆ GrowToConnectedTriangles() [2/2]

void FMeshConnectedComponents::GrowToConnectedTriangles ( const FDynamicMesh3 Mesh,
const TArray< int > &  InputROI,
TSet< int > &  ResultROI,
TArray< int32 > *  QueueBuffer = nullptr,
TFunctionRef< bool(int32, int32)>  CanGrowPredicate = [](int32int32) { return true; } 
)
static

Utility function to expand a triangle selection to all triangles considered "connected". More efficient than using full FMeshConnectedComponents instance if ROI is small relative to Mesh size (or if temp buffers can be re-used) This version computes an output TSet instead of output TArray, which is preferable in some cases.

Parameters
MeshMesh to calculate on
InputROIinput set of triangles
ResultROIoutput set of triangles connected to InputROI
QueueBufferoptional buffer used as internal Queue. If passed as nullptr, a TArray will be locally allocated
CanGrowPredicatedetermines whether two connected mesh triangles should be considered connected while growing

◆ GrowToConnectedVertices()

void FMeshConnectedComponents::GrowToConnectedVertices ( const FDynamicMesh3 Mesh,
const TArray< int > &  InputROI,
TSet< int > &  ResultROI,
TArray< int32 > *  QueueBuffer = nullptr,
TFunctionRef< bool(int32, int32)>  CanGrowPredicate = [](int32int32) { return true; } 
)
static

Utility function to expand a vertex selection to all vertices considered "connected".

Parameters
MeshMesh to calculate on
InputROIinput set of vertices
ResultROIoutput set of vertices connected to InputROI
QueueBufferoptional buffer used as internal Queue. If passed as nullptr, a TArray will be locally allocated
CanGrowPredicatedetermines whether two connected mesh vertices should be considered connected while growing

◆ InitializeFromTriangleComponents() [1/2]

bool FMeshConnectedComponents::InitializeFromTriangleComponents ( const TArray< TArray< int32 > > &  ComponentLists,
bool  bValidateIDs 
)

Initialize the internal FComponent list from the input ComponentLists, skipping any empty input lists

Parameters
bValidateIDsif true, test that each value corresponds to a valid triangle ID on the Mesh
Returns
true if all IDs are valid, or if check was skipped

◆ InitializeFromTriangleComponents() [2/2]

bool FMeshConnectedComponents::InitializeFromTriangleComponents ( TArray< TArray< int32 > > &  ComponentLists,
bool  bMoveSubLists,
bool  bValidateIDs 
)

Initialize the internal FComponent list from the input ComponentLists, skipping any empty input lists

Parameters
bMoveSubListsif true, steal the arrays inside the ComponentLists (via MoveTemp), to avoid memory copies
bValidateIDsif true, test that each value corresponds to a valid triangle ID on the Mesh
Returns
true if all IDs are valid, or if check was skipped

◆ InitializeFromVertexComponents() [1/2]

bool FMeshConnectedComponents::InitializeFromVertexComponents ( const TArray< TArray< int32 > > &  ComponentLists,
bool  bValidateIDs 
)

Initialize the internal FComponent list from the input ComponentLists, skipping any empty input lists

Parameters
bValidateIDsif true, test that each value corresponds to a valid vertex ID on the Mesh
Returns
true if all IDs are valid, or if check was skipped

◆ InitializeFromVertexComponents() [2/2]

bool FMeshConnectedComponents::InitializeFromVertexComponents ( TArray< TArray< int32 > > &  ComponentLists,
bool  bMoveSubLists,
bool  bValidateIDs 
)

Initialize the internal FComponent list from the input ComponentLists, skipping any empty input lists

Parameters
bMoveSubListsif true, steal the arrays inside the ComponentLists (via MoveTemp), to avoid memory copies
bValidateIDsif true, test that each value corresponds to a valid vertex ID on the Mesh
Returns
true if all IDs are valid, or if check was skipped

◆ Num()

int32 UE::Geometry::FMeshConnectedComponents::Num ( ) const
inline
Returns
Number of Components that were found

◆ operator[]() [1/2]

FComponent & UE::Geometry::FMeshConnectedComponents::operator[] ( int32  Index)
inline
Returns
element of Components array at given Index

◆ operator[]() [2/2]

const FComponent & UE::Geometry::FMeshConnectedComponents::operator[] ( int32  Index) const
inline
Returns
element of Components array at given Index

◆ RemoveFromActiveSet()

void FMeshConnectedComponents::RemoveFromActiveSet ( const FComponent Component,
TArray< uint8 > &  ActiveSet 
)
protected

◆ SortByCount()

void FMeshConnectedComponents::SortByCount ( bool  bLargestFirst = true)

Sort the Components array by component element count

Parameters
bLargestFirstif true, sort by decreasing count, otherwise by increasing count

Member Data Documentation

◆ Components

TIndirectArray<FComponent> UE::Geometry::FMeshConnectedComponents::Components

List of Connected Components that have been found by one of the calculation functions

◆ Mesh

const FDynamicMesh3* UE::Geometry::FMeshConnectedComponents::Mesh

The documentation for this class was generated from the following files: