Home > matGeom > meshes3d > meshBoundaryVertexIndices.m

meshBoundaryVertexIndices

PURPOSE ^

MESHBOUNDARYVERTEXINDICES Indices of boundary vertices of a mesh.

SYNOPSIS ^

function inds = meshBoundaryVertexIndices(varargin)

DESCRIPTION ^

MESHBOUNDARYVERTEXINDICES Indices of boundary vertices of a mesh.

   INDS = meshBoundaryVertexIndices(V, F)
   INDS = meshBoundaryVertexIndices(V, E, F)

   Example
     % create centered icosahedron
     [v, f] = createIcosahedron;
     v(:,3) = v(:,3) - mean(v(:,3));
     % convert to simili-sphere
     [v2, f2] = subdivideMesh(v, f, 3);
     v3 = normalizeVector3d(v2);
     % clip with plane
     plane = createPlane([0 0 0], [-1 -2 3]);
     [vc, fc] = clipMeshVertices(v3, f2, plane, 'shape', 'plane');
     figure; drawMesh(vc, fc); axis equal; view(3);
     % draw boundary vertices
     inds = meshBoundaryVertexIndices(vc, fc);
     hold on; drawPoint3d(vc(inds,:), 'k*');

   See also
     meshes3d, meshBoundary, meshBoundaryEdgeIndices, meshEdgeFaces

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function inds = meshBoundaryVertexIndices(varargin)
0002 %MESHBOUNDARYVERTEXINDICES Indices of boundary vertices of a mesh.
0003 %
0004 %   INDS = meshBoundaryVertexIndices(V, F)
0005 %   INDS = meshBoundaryVertexIndices(V, E, F)
0006 %
0007 %   Example
0008 %     % create centered icosahedron
0009 %     [v, f] = createIcosahedron;
0010 %     v(:,3) = v(:,3) - mean(v(:,3));
0011 %     % convert to simili-sphere
0012 %     [v2, f2] = subdivideMesh(v, f, 3);
0013 %     v3 = normalizeVector3d(v2);
0014 %     % clip with plane
0015 %     plane = createPlane([0 0 0], [-1 -2 3]);
0016 %     [vc, fc] = clipMeshVertices(v3, f2, plane, 'shape', 'plane');
0017 %     figure; drawMesh(vc, fc); axis equal; view(3);
0018 %     % draw boundary vertices
0019 %     inds = meshBoundaryVertexIndices(vc, fc);
0020 %     hold on; drawPoint3d(vc(inds,:), 'k*');
0021 %
0022 %   See also
0023 %     meshes3d, meshBoundary, meshBoundaryEdgeIndices, meshEdgeFaces
0024  
0025 % ------
0026 % Author: David Legland
0027 % e-mail: david.legland@inra.fr
0028 % Created: 2019-05-01,    using Matlab 8.6.0.267246 (R2015b)
0029 % Copyright 2019 INRA - Cepia Software Platform.
0030 
0031 [vertices, edges, faces] = parseMeshData(varargin{:});
0032 
0033 % Compute edge-vertex map if not specified
0034 if isempty(edges)
0035     edges = meshEdges(vertices, faces);
0036 end
0037 
0038 % compute edges to faces map
0039 edgeFaces = meshEdgeFaces(vertices, edges, faces);
0040 
0041 borderEdges = sum(edgeFaces == 0, 2) > 0;
0042 
0043 inds = edges(borderEdges, :);
0044 inds = unique(inds(:));

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