clusterConnectedFaces
Description
[
clusters the connected faces in the surface mesh faceClusterIdx
,clusterNumFaces
,clusterArea
] = clusterConnectedFaces(surfaceMeshIn
)surfaceMeshIn
, and
returns the cluster index for each face faceClusterIdx
, the number of
connected faces in each cluster clusterNumFaces
, and the surface area
of each cluster clusterArea
.
Examples
Cluster Connected Faces of Surface Mesh
Define 12 mesh vertices in a 12-by-3 matrix vertices
. Each row of vertices
specifies the [x y z]
coordinates of a vertex. Each vertex has a vertex ID equal to its row number in vertices
.
vertices = [1 -1 1; 1 1 1; -1 1 1; -1 -1 1; 1 -1 -1; 1 1 -1; -1 1 -1; -1 -1 -1; 2 0 0; 2 2 0; 1 0 0; -1 0 -2];
Use the vertices to define triangular mesh faces in the matrix faces
. Each row of the matrix is in the form [V1 V2 V3]
, specifying the vertex IDs of the vertices that define the triangular face.
faces = [6 2 1; 1 5 6; 8 4 3; 3 7 8; 6 7 3; 3 2 6; 5 1 4; 4 8 5; 4 1 2; 2 3 4; 7 6 5; 5 8 7; 9 10 11; 9 10 12; 9 11 12; 10 11 12];
Create a surface mesh from the vertices and faces.
mesh = surfaceMesh(vertices,faces);
Cluster the connected triangular faces of the mesh.
[faceClusterIdx,clusterNumFaces,clusterArea] = clusterConnectedFaces(mesh);
Visualize the surface mesh.
surfaceMeshShow(mesh,Title="Original Mesh")
Extract the first cluster of the surface mesh.
idx = 1:size(vertices,1); firstFaces = faces(faceClusterIdx==1,:); idx(unique(firstFaces))=[]; firstMesh = surfaceMesh(vertices,firstFaces); removeVertices(firstMesh,idx)
Visualize the first cluster of the surface mesh.
surfaceMeshShow(firstMesh,Title="First Cluster Mesh")
Extract the second cluster of the surface mesh.
idx = 1:size(vertices,1); secondFaces = faces(faceClusterIdx==2,:); idx(unique(secondFaces))=[]; secondMesh = surfaceMesh(vertices,secondFaces); removeVertices(secondMesh,idx)
Visualize the second cluster of the surface mesh.
surfaceMeshShow(secondMesh,Title="Second Cluster Mesh")
Input Arguments
surfaceMeshIn
— Input surface mesh
surfaceMesh
object
Input surface mesh, specified as a surfaceMesh
object.
Output Arguments
faceClusterIdx
— Cluster indices of faces
numeric vector
Cluster indices of faces, returned as a numeric vector. Each element of the vector
specifies the cluster index of a face in the surface mesh. The length of the
faceClusterIdx
vector is equal to the number of faces in
surfaceMeshIn
.
Data Types: uint64
clusterNumFaces
— Number of connected faces in each cluster
numeric vector
Number of connected faces in each cluster, returned as a numeric vector. Each
element of the vector specifies the number of connected faces in a cluster. The length
of the clusterNumFaces
vector is equal to the number of clusters
created from the connected faces of surfaceMeshIn
.
Data Types: uint64
clusterArea
— Surface area of clusters
numeric vector
Surface area of clusters, returned as a numeric vector. Each element of the vector
specifies the surface area of a cluster of connected faces. The length of the
clusterArea
vector is equal to the number of clusters created from
the connected faces of surfaceMeshIn
.
Data Types: double
Version History
Introduced in R2023a
See Also
surfaceMesh
| readSurfaceMesh
| writeSurfaceMesh
| surfaceMeshShow
| pc2surfacemesh
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)