Home > matGeom > meshes3d > removeMeshEars.m

removeMeshEars

PURPOSE ^

REMOVEMESHEARS Remove vertices that are connected to only one face.

SYNOPSIS ^

function varargout = removeMeshEars(varargin)

DESCRIPTION ^

REMOVEMESHEARS Remove vertices that are connected to only one face.

   [V, F] = removeMeshEars(V, F)
   [V, F] = removeMeshEars(MESH)
   Remove vertices that are connected to only one face. This removes also
   "pending" faces.
   Note that if the mesh has boundary, this may remove some regular faces
   located on the boundary.

   Example
   removeMeshEars

   See also
     meshes3d, ensureManifoldMesh

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = removeMeshEars(varargin)
0002 %REMOVEMESHEARS Remove vertices that are connected to only one face.
0003 %
0004 %   [V, F] = removeMeshEars(V, F)
0005 %   [V, F] = removeMeshEars(MESH)
0006 %   Remove vertices that are connected to only one face. This removes also
0007 %   "pending" faces.
0008 %   Note that if the mesh has boundary, this may remove some regular faces
0009 %   located on the boundary.
0010 %
0011 %   Example
0012 %   removeMeshEars
0013 %
0014 %   See also
0015 %     meshes3d, ensureManifoldMesh
0016 %
0017  
0018 % ------
0019 % Author: David Legland
0020 % e-mail: david.legland@inra.fr
0021 % Created: 2019-01-08,    using Matlab 8.6.0.267246 (R2015b)
0022 % Copyright 2019 INRA - Cepia Software Platform.
0023 
0024 [vertices, faces] = parseMeshData(varargin{:});
0025 
0026 nVertices = size(vertices, 1);
0027 
0028 % for each vertex, determine the number of faces it belongs to
0029 vertexDegree = zeros(nVertices, 1);
0030 for iv = 1:nVertices
0031     vertexDegree(iv) = sum(sum(faces == iv, 2) > 0);
0032 end
0033 
0034 % remove vertices with degree 1
0035 inds = find(vertexDegree == 1);
0036 [vertices, faces] = removeMeshVertices(vertices, faces, inds);
0037 
0038 
0039 %% Format output
0040 
0041 varargout = formatMeshOutput(nargout, vertices, faces);

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019