splitFV - Partition a mesh into its connected components.
Version 2.0.0.0 (2.91 KB) by
Sven
Splits a 2D or 3D mesh defined by faces and vertices into separately connected mesh pieces. [2025 update for vastly faster performance]
SPLITFV Partition a mesh into its connected components.
FVARRAY = SPLITFV(FV) - FV is a struct with .faces and .vertices
FVARRAY = SPLITFV(F, V) - F is faces matrix, V is vertices matrix
FVARRAY = SPLITFV(TR) - TR is a MATLAB triangulation object
DESCRIPTION:
Connectivity is determined by mapping vertices to "nodes" in a graph.
By default, connectivity is strict (index-based), but can be adjusted
to weld vertices that are spatially coincident but indexed separately.
NAME-VALUE OPTIONS:
Tolerance - Determines how vertices are "connected" into a graph:
NaN (Default): Strict index connectivity. Only faces
sharing the exact same vertex index are connected.
0: Exact spatial connectivity. Vertices at identical
[x,y,z] coordinates are treated as shared nodes.
>0: Fuzzy spatial connectivity. Vertices within this
Euclidean distance are treated as shared nodes.
Note: Original node counts will not change - Tolerance
values only affects how meshes are split
EXAMPLE:
fullpatch.vertices = [2 4; 2 8; 8 4; 8 0; 0 4; 2 6; 2 2; 4 2; 4 0; 5 2; 5 0];
fullpatch.faces = [1 2 3; 1 3 4; 5 6 1; 7 8 9; 11 10 4];
tiledlayout(2,1);
nexttile;
patch('Faces',fullpatch.faces,'Vertices',fullpatch.vertices,'FaceColor','r');
title('Unsplit Mesh'); axis tight equal; grid on;
splitpatch = splitFV(fullpatch);
nexttile; hold on;
colours = lines(length(splitpatch));
for i=1:length(splitpatch)
patch(splitpatch(i),'FaceColor',colours(i,:));
end
title('Split Mesh'); view(2); axis tight equal; grid on;
Cite As
Sven (2026). splitFV - Partition a mesh into its connected components. (https://au.mathworks.com/matlabcentral/fileexchange/27667-splitfv-partition-a-mesh-into-its-connected-components), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
Find more on Polygons in Help Center and MATLAB Answers
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 2.0.0.0 | Major overhaul to improve performance (graph logic instead of iterative loops), allow a tolerance to handle splitting while keeping adjacent meshes together, and including triangulation objects |
||
| 1.7.0.0 | Implemented Christopher's amendment to fix bug in following connectivity matrix. |
||
| 1.6.0.0 | Updated icon (thanks Tom Clark!) |
||
| 1.0.0.0 |
