MESHFACE Return the vertex indices of a face in a mesh. FACE = meshFace(FACES, INDEX) Return the vertex indices of the i-th face in the face array. This is mainly an utility function that manages faces stored either as int array (when all faces have same number of sides) or cell array (when faces may have different number of edges). Example [v, f] = createCubeOctahedron; % some faces are squares meshFace(f, 1) ans = 1 2 3 4 % other are triangles meshFace(f, 2) ans = 1 5 2 See also meshes3d, meshFaceCentroid, meshFaceNormals, meshFaceAreas
0001 function face = meshFace(faces, index) 0002 %MESHFACE Return the vertex indices of a face in a mesh. 0003 % 0004 % FACE = meshFace(FACES, INDEX) 0005 % Return the vertex indices of the i-th face in the face array. This is 0006 % mainly an utility function that manages faces stored either as int 0007 % array (when all faces have same number of sides) or cell array (when 0008 % faces may have different number of edges). 0009 % 0010 % Example 0011 % [v, f] = createCubeOctahedron; 0012 % % some faces are squares 0013 % meshFace(f, 1) 0014 % ans = 0015 % 1 2 3 4 0016 % % other are triangles 0017 % meshFace(f, 2) 0018 % ans = 0019 % 1 5 2 0020 % 0021 % See also 0022 % meshes3d, meshFaceCentroid, meshFaceNormals, meshFaceAreas 0023 0024 % ------ 0025 % Author: David Legland 0026 % E-mail: david.legland@inrae.fr 0027 % Created: 2010-10-06, using Matlab 7.9.0.529 (R2009b) 0028 % Copyright 2010-2024 INRA - Cepia Software Platform 0029 0030 % process mesh given as structure 0031 if isstruct(faces) 0032 if isfield(faces, 'faces') 0033 faces = faces.faces; 0034 else 0035 error('Mesh structure should contains a field ''faces'''); 0036 end 0037 end 0038 0039 % switch between numeric or cell array 0040 if isnumeric(faces) 0041 face = faces(index, :); 0042 else 0043 face = faces{index}; 0044 end 0045