Home > matGeom > meshes3d > meshFace.m

meshFace

PURPOSE ^

MESHFACE Return the vertex indices of a face in a mesh.

SYNOPSIS ^

function face = meshFace(faces, index)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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@inra.fr
0027 % Created: 2010-10-06,    using Matlab 7.9.0.529 (R2009b)
0028 % Copyright 2010 INRA - Cepia Software Platform.
0029 
0030 
0031 % process mesh given as structure
0032 if isstruct(faces)
0033     if isfield(faces, 'faces')
0034         faces = faces.faces;
0035     else
0036         error('Mesh structure should contains a field ''faces''');
0037     end
0038 end
0039 
0040 % switch between numeric or cell array
0041 if isnumeric(faces)
0042     face = faces(index, :);
0043 else
0044     face = faces{index};
0045 end
0046

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